gianni lavaredo
2015-Jun-19 00:42 UTC
[R] Repeated Measures ANOVA and Missing Values in the data set
I am doing Repeated Measures ANOVA with missing values. When i run my model i get this error message. *aov.out = aov(values ~ time + Error(subject/time), data=mydata2)Warning message:In aov(values ~ time + Error(subject/time), data = mydata2) : Error() model is singular* The missing Values are not a error of my instrument. They mean the element of my analysis is absent and i want to consider this. thanks in advance these are my data: subject <- c(1,2,3,4,5,6,7,8,9,10) time1 <- c(5040,3637,6384,5309,5420,3549,NA,5140,3890,3910) time2 <- c(5067, 3668, NA, 6489, NA, 3922, 3408, 6613, 4063, 3937) time3 <- c( 3278, 3814, 8745, 4760, 4911, 5716, 5547, 5844, 4914, 4390) time4 <- c( 0, 2971, 0, 2776, 2128, 1208, 2935, 2739, 3054, 3363) time5 <- c(4161, 3483, 6728, 5008, 5562, 4380, 4006, 7536, 3805, 3923) time6 <- c( 3604, 3411, 2523, 3264, 3578, 2941, 2939, NA, 3612, 3604) mydata <- data.frame(time1, time2, time3, time4, time5, time6) mydata2 = stack(mydata) subject = factor(rep(subject,6)) mydata2[3] = subject colnames(mydata2) = c("values", "time", "subject") aov.out = aov(values ~ time + Error(subject/time), data=mydata2) summary(aov.out) model.tables(aov.out,"means") [[alternative HTML version deleted]]
Stéphane Adamowicz
2015-Jun-19 08:06 UTC
[R] Repeated Measures ANOVA and Missing Values in the data set
This happens because your model should be : aov.out = aov(values ~ time + Error(subject), data=mydata2) This will not generate any error. However, you should be aware that aov is not suitable for unbalanced data, for which it will give inconsistent results. In such case, you can use the lme function : require(nlme) aov2 <- lme(fixed= values~time, random=~1|subject, na.action=na.omit, data=mydata2) summary(aov2) anova(aov2) Le 19 juin 2015 ? 02:42, gianni lavaredo <gianni.lavaredo at gmail.com> a ?crit :> I am doing Repeated Measures ANOVA with missing values. When i run my model > i get this error message. > > > > > *aov.out = aov(values ~ time + Error(subject/time), data=mydata2)Warning > message:In aov(values ~ time + Error(subject/time), data = mydata2) : > Error() model is singular* > > The missing Values are not a error of my instrument. They mean the element > of my analysis is absent and i want to consider this. > > thanks in advance > > these are my data: > > subject <- c(1,2,3,4,5,6,7,8,9,10) > time1 <- c(5040,3637,6384,5309,5420,3549,NA,5140,3890,3910) > time2 <- c(5067, 3668, NA, 6489, NA, 3922, 3408, 6613, 4063, 3937) > time3 <- c( 3278, 3814, 8745, 4760, 4911, 5716, 5547, 5844, 4914, 4390) > time4 <- c( 0, 2971, 0, 2776, 2128, 1208, 2935, 2739, 3054, 3363) > time5 <- c(4161, 3483, 6728, 5008, 5562, 4380, 4006, 7536, 3805, 3923) > time6 <- c( 3604, 3411, 2523, 3264, 3578, 2941, 2939, NA, 3612, 3604) > mydata <- data.frame(time1, time2, time3, time4, time5, time6) > mydata2 = stack(mydata) > subject = factor(rep(subject,6)) > mydata2[3] = subject > colnames(mydata2) = c("values", "time", "subject") > aov.out = aov(values ~ time + Error(subject/time), data=mydata2) > summary(aov.out) > model.tables(aov.out,"means") > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.St?phane Adamowicz Chercheur / Scientist stephane.adamowicz at paca.inra.fr Centre PACA - UR 1115 PSH Tel. : +33 1 (0)4 32 72 24 35 Fax : +33 1 (0)4 32 72 24 32 228, route de l'A?rodrome 84 914 Avignon Cedex 9 France www.inra.fr