I need an help because I don´t know if the command for the ANOVA analysis I am
performing in R is correct. Indeed using the function aov I get the following error:
In aov (......) Error() model is singular
The structure of my table is the following: subject, stimulus, condition, sex, response
subject stimulus condition sex response subject1 gravel EXP1 M 59.8060 subject2 gravel EXP1 M 49.9880 subject3 gravel EXP1 M 73.7420 subject4 gravel EXP1 M 45.5190 subject5 gravel EXP1 M 51.6770 subject6 gravel EXP1 M 42.1760 subject7 gravel EXP1 M 56.1110 subject8 gravel EXP1 M 54.9500 subject9 gravel EXP1 M 62.6920 subject10 gravel EXP1 M 50.7270 subject1 gravel EXP2 M 70.9270 subject2 gravel EXP2 M 61.3200 subject3 gravel EXP2 M 70.2930 subject4 gravel EXP2 M 49.9880 subject5 gravel EXP2 M 69.1670 subject6 gravel EXP2 M 62.2700 subject7 gravel EXP2 M 70.9270 subject8 gravel EXP2 M 63.6770 subject9 gravel EXP2 M 72.4400 subject10 gravel EXP2 M 58.8560 subject11 gravel EXP1 F 46.5750 subject12 gravel EXP1 F 58.1520 subject13 gravel EXP1 F 57.4490 subject14 gravel EXP1 F 59.8770 subject15 gravel EXP1 F 55.5480 subject16 gravel EXP1 F 46.2230 subject17 gravel EXP1 F 63.3260 subject18 gravel EXP1 F 60.6860 subject19 gravel EXP1 F 59.4900 subject20 gravel EXP1 F 52.6630 subject11 gravel EXP2 F 55.7240 subject12 gravel EXP2 F 66.4220 subject13 gravel EXP2 F 65.9300 subject14 gravel EXP2 F 61.8120 subject15 gravel EXP2 F 62.5160 subject16 gravel EXP2 F 65.5780 subject17 gravel EXP2 F 59.5600 subject18 gravel EXP2 F 63.8180 subject19 gravel EXP2 F 61.4250 ..... ..... ..... .....
As you can notice each subject repeated the evaluation in 2 conditions (EXP1 and EXP2).
What I am interested in is to know if there are significant differences between the evaluations of the males and the females.
This is the command I used to perform the ANOVA with repeated measures:
aov1 = aov(response ~ stimulus*sex + Error(subject/(stimulus*sex)), data=scrd) summary(aov1)
I get the following error:
> aov1 = aov(response ~ stimulus*sex + Error(subject/(stimulus*sex)), data=scrd) Warning message: In aov(response ~ stimulus * sex + Error(subject/(stimulus * sex)), : Error() model is singular > summary(aov1) Error: subject Df Sum Sq Mean Sq F value Pr(>F) sex 1 166.71 166.72 1.273 0.274 Residuals 18 2357.29 130.96 Error: subject:stimulus Df Sum Sq Mean Sq F value Pr(>F) stimulus 6 7547.9 1257.98 35.9633 <2e-16 *** stimulus:sex 6 94.2 15.70 0.4487 0.8445 Residuals 108 3777.8 34.98 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals 420 9620.6 22.906 >
The thing is that looking at the data it is evident for me that there is a difference between male and females, because for each stimulus I always get a mean higher for the males rather than the females. Therefore the ANOVA should indicate significant differences....
Is there anyone who can suggest me where I am wrong?
Finally, I know that in R there are two libraries on linear mixed models called nlme and lme4, but I have never used it so far and I don´t know if I have to utilize it for my case. Is it the case to utilize it? If yes, could you please provide a quick R example of a command which could solve my problem?
Thanks in advance!
Dear all, I am stuck now ;-( Indeed I understood everything you suggested me but still I don´t get significance in the ANOVA results, and definitively there is an error, because results cannot be non-significant. Indeed looking at the means for each stimulus, it is possible to notice that males gave always higher evaluations than females.
To prove this I discarded for a moment the effect of the repeated measures, and I performed an ANOVA separately on both the two conditions (EXP1 and EXP2) during which the evaluations were given. What I get is significant differences between males and female, in both EXP1 and EXP2.
Now, why when I perform the ANOVA with repeated measures I don´t get the same behavior?
My design is the following: -sex is a between-subjects factor (with two levels) -stimulus is a within-subjects factor (with 3 assumed levels) -condition is a within-subjects factor (with 2 levels) -all factors are fully crossed
I tried, both the ways suggested but without achieving significance:
mDf <- aggregate(response ~ subject + sex, data=scrd, FUN=mean) summary(aov(response ~ sex, data=mDf)) # ANOVA with just the between-effect
aov1 = aov(response ~ sex*stimulus*condition + Error(subject/(stimulus*condition)), data=scrd) summary(aov1)
Instead if I perform the ANOVA on the two subtables of EXP 1 and 2 I get significant differences.
table_EXP1 <- subset(scrd, condition == "EXP1") table_EXP2 <- subset(scrd, condition == "EXP2") fit_table_EXP1 <- lm(response ~ stimulus*sex, data=table_EXP1) summary(fit_table_EXP1 ) anova(fit_table_EXP1 ) fit_table_EXP2 <- lm(response ~ stimulus*sex, data=table_EXP2) summary(fit_table_EXP2) anova(fit_table_EXP2)
....how can this be possible?...it is a contraddiction....
Please enlighten me!
Thanks in advance