6
$\begingroup$

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?

$\endgroup$
1

1 Answer 1

14
$\begingroup$

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.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.