aov() error term in R: what's the difference bw Error(id) and Error(id/timevar) specification?

前端 未结 2 1509
天涯浪人
天涯浪人 2021-02-01 23:46

What is the difference between the aov(depvar~timevar+Error(id)) and the aov(depvar~timevar+Error(id/timevar)) formula specifications? These two varian

2条回答
  •  臣服心动
    2021-02-02 00:02

    Here's a blog post that'll help break down what each means under the "Random Effects in Classical ANOVA" section.

    From the blog, here's a summary for what "dividing" in the Error term means.

    aov(Y ~ Error(A), data=d)               # Lone random effect
    aov(Y ~ B + Error(A/B), data=d)         # A random, B fixed, B nested within A
    aov(Y ~ (B*X) + Error(A/(B*X)), data=d) # B and X interact within levels of A
    

    So from your question,

    aov(depvar~timevar+Error(id/timevar))
    

    means you have a random effect from id but then fix timevar with timevar nested within id levels versus

    aov(depvar~timevar+Error(id))
    

    which is just taking id as the random effects with no constraint on other variables.

    Source: http://conjugateprior.org/2013/01/formulae-in-r-anova/

    This might prove useful as well, which is some code going over analysis of variance that has some recommendations on learning ANOVA.

提交回复
热议问题