- This topic has 1 reply, 2 voices, and was last updated 7 years, 5 months ago by henrik.
-
AuthorPosts
-
-
June 6, 2017 at 11:40 GMT+0000 #81Andrew StewartParticipant
Hi Henrik – I’ve been trying to run some repeated measures ANOVAs using afex and notice that when I have multiple observations per participant per condition, afex ignores a participant completely if just one observation is missing – even though the condition means for the participant can still be calculated from the observations that are present. You can see in the following code where two observations for participant 10 are missing – participant 10 is then entirely removed even though the condition means can still be calculated. Is there a way to specify in afex that condition means should still be calculated even if the occasional observation is missing? Many thanks. Andrew.
require(afex) data(sk2011.1) sk2011.1[c(3,4),"response"] <- NA # Table 1 (p. 264): aov_ez("id", "response", sk2011.1[ sk2011.1$what == "affirmation",], within = c("inference", "type"), between = "instruction")
This gives the error:
2: Missing values for following ID(s): 10 Removing those cases from the analysis.
- This topic was modified 7 years, 5 months ago by henrik. Reason: formatted code as code
-
June 6, 2017 at 11:48 GMT+0000 #83henrikKeymaster
Great question as I was honestly surprised
afex
does not do that automatically. I guess I always remove myNA
s from the data before running analyses and hadn’t encountered that before.Fortunately, the solution is super simple. We can simply pass
na.rm=TRUE
to the call of the ANOVA function and this will be passed on tomean()
which does the automatic aggregation. Then the mean for each participant and cell are calculated excludingNA
s:aov_ez("id", "response", sk2011.1[ sk2011.1$what == "affirmation",], within = c("inference", "type"), between = "instruction", na.rm=TRUE) # Contrasts set to contr.sum for the following variables: instruction # Anova Table (Type 3 tests) # # Response: response # Effect df MSE F ges p.value # 1 instruction 1, 38 1072.56 0.12 .001 .73 # 2 inference 1, 38 995.53 12.68 ** .11 .001 # 3 instruction:inference 1, 38 995.53 13.07 *** .11 .0009 # 4 type 1, 38 188.61 0.06 .0001 .81 # 5 instruction:type 1, 38 188.61 3.04 + .005 .09 # 6 inference:type 1, 38 499.82 30.59 *** .13 <.0001 # 7 instruction:inference:type 1, 38 499.82 11.33 ** .05 .002 # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1 # Warning message: # More than one observation per cell, aggregating the data using mean (i.e, fun_aggregate = mean)!
-
-
AuthorPosts
- You must be logged in to reply to this topic.