session_lecture.Rmd
For more detail: Vittinghoff section 4.2
Assumption:
* STATA and R code dummy variables automatically, behind-the-scenes
Interaction is modeled as the product of two covariates:
Image credit: http://personal.stevens.edu/~ysakamot/
aov()
,
lm()
, glm()
, and coxph()
all
accept the “model formula” interface.response variable ~ explanatory variables
y ~ x
Additional explanatory variables would be added as follows:
y ~ x + z
Note that “+” does not have its usual meaning, which would be achieved by:
y ~ I(x + z)
lm( y ~ u + v)
u
and v
factors:
ANOVAu
and v
numeric: multiple
regression
one factor, one numeric: ANCOVA
symbol | example | meaning |
---|---|---|
+ | + x | include this variable |
- | - x | delete this variable |
: | x : z | include the interaction |
* | x * z | include these variables and their interactions |
/ | x / z | nesting: include z nested within x |
| | x | z | conditioning: include x given z |
^ | (u + v + w)^3 | include these variables and |
all interactions up to three way | ||
1 | -1 | intercept: delete the intercept |