# What is the meaning of operators in regression or anova formulas in R

I was wondering, what is the meaning of operators in anova or regression formulas in R

For example

• "+" aov <- aov(x~time+sample, data=data) -> repeated mesures anova?
• "*" aov <- aov(x~time*sample, data=data) -> two way anova?
• "/" aov <- aov(x~time/sample, data=data) -> ?
• ":" aov <- aov(x~time:sample, data=data) -> ?

And also are there more operators for this kind of formulas?

-

The formulas in R have their own mini-language. You can have some detailed information in the R session with

help(formula)


which you can also find here.

For the sake of the example, let's say that you predict $Z$ from $X$ and $Y$ and let's drop the error terms.

$Z \sim X + Y$ means that you fit and additive model $Z_i = X_i + Y_i$

$Z \sim X * Y$ means that you fit a model with interactions $Z_i = X_i + Y_i + X_i Y_i$

$Z \sim X / Y$ means that you fit a model with "nested" interactions $Z_i = X_i + X_i Y_i$

$Z \sim X : Y$ means that you fit a model with only interactions $Z_i = X_i Y_i$

You also have the $-$, ^ and $\%in\%$ operators described in the help page. The $-$ operator is mostly used for removing the intercept and the others are redundant with the ones shown above.

-
Thank you so much!!! –  friveroll May 28 '12 at 20:30