LoslegenKostenlos loslegen

Multiple slopes

You learned about model.matrix() and its relationship to glm() during the video. Now, you can "peek under the hood" of R and see how formulas work. The input to model.matrix() is similar to formula inputs of lm() and glm() with one key difference: model.matrix() does not have a left-hand side (e.g. y ~), only the right-hand side (e.g., ~ x).

For example, model.matrix( ~ x1) or model.matrix( ~ x1 + x2) both would be valid inputs. The output from model.matrix() is called a prediction matrix because it is the prediction (or right-hand side) of a formula in R.

During this exercise, you will use model.matrix() with 2 vectors: size and count. First, build a simple formula that only includes size. Second, build a formula that includes both size and count.

Diese Übung ist Teil des Kurses

Generalized Linear Models in R

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Use model.matrix() with size
___
Code bearbeiten und ausführen