Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

up vote 6 down vote accepted

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.

share|improve this answer
Thank you so much!!! – friveroll May 28 '12 at 20:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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