Eveliina Glogan
Eveliina Glogan

Reputation: 11

R - degrees of freedom totally off in planned comparisons (used afex - aov_ez - emmeans - pairs)?

In our task participants provide subjective fear ratings for stimuli (Trajectories) differing in likelihood of being paired with an aversive stimulus (thus the DV is fear ratings). There are two groups, three blocks, and three trajectories resulting in a 2 (Group: Experimental/Yoked control) x 3 (Block: GEN1-3) x 3 (Trajectory: G1/G2/G3) RM ANOVA. For this I use the following code:

a_Fear_ratings <- aov_ez("PP", "Fear", HM2_fear_gen_K, between="Group", within=c("Block", "Trajectory"), anova_table = list(es = "pes"))

And get these results:

Response: Fear
                  Effect           df     MSE         F   pes p.value
1                  Group        1, 62 3552.21      0.03 <.001    .861
2                  Block  1.41, 87.43  293.76 37.96 ***  .380   <.001
3            Group:Block  1.41, 87.43  293.76      0.68  .011    .462
4             Trajectory  1.43, 88.52  737.20    3.36 +  .051    .055
5       Group:Trajectory  1.43, 88.52  737.20    5.18 *  .077    .015
6       Block:Trajectory 3.30, 204.62   89.27      2.02  .031    .107
7 Group:Block:Trajectory 3.30, 204.62   89.27      0.67  .011    .584
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1

Sphericity correction method: GG 

I have a priori hypotheses to test for which I need to compare ratings to the different trajectories within groups so I run planned comparisons using the code

a_Fear_ratings1 <- emmeans(a_Fear_ratings, ~Trajectory|Group + Block)

and

pairs(a_Fear_ratings1, adjust="holm")

and get the following results:

Group = Experimental, Block = GEN1:
 contrast estimate   SE  df t.ratio p.value
 G1 - G2      2.38 3.75 195  0.634  0.5268 
 G1 - G3      8.92 3.75 195  2.380  0.0548 
 G2 - G3      6.54 3.75 195  1.746  0.1647 

Group = Yoked, Block = GEN1:
 contrast estimate   SE  df t.ratio p.value
 G1 - G2     -2.99 3.75 195 -0.798  1.0000 
 G1 - G3     -3.48 3.75 195 -0.929  1.0000 
 G2 - G3     -0.49 3.75 195 -0.131  1.0000 

P value adjustment: holm method for 3 tests

I'm showing only first block (GEN1) for both groups here, but the DFs are exactly the same in the other blocks.

Could someone explain to me how these degrees of freedom are calculated and if they are correct? I can't seem to find an answer that directly applies to my problem. Also, I ran a similar analysis about a year ago and did not get such large DFs?

Thank you in advance!

Upvotes: 0

Views: 190

Answers (1)

Russ Lenth
Russ Lenth

Reputation: 6810

This looks right to me. You say there are 32 subjects per group (in a nested arrangement), so in a case where there are no missing observations, you would have 32*2*3*3=576 observations total. There are 31 df for subjects in each group for a total of 62. So the df count in the model is:

Groups: 1 d.f.
Subj: 62
Blocks: 2
Traj: 2

G*B: 2
G*T: 2
S*B: 124
S*T: 124
B*T: 4
G*B*T: 4
S*B*T: 248  (residual d.f)
-----------
total: 575 = 576 - 1

So in a straight ANOVA approach, which is pretty much what is used by aov_ez by default, you should have 248 df for those within-subjects comparisons. The output shows only 195, so I guess a few observations are missing?

Upvotes: 0

Related Questions