Hi Tal, a few remarks: - The way you did it, week is essentially a nominal variable. The analysis you use completely ignores the sequence of the weeks. You have to take that one into account as well.
- The method you use tells me you're attempting some kind of repeated-measures anova in R. Actually, the code looks almost identical to http://gribblelab.org/2009/03/09/repeated-measures-anova-using-r/ , third case. One of the other options can be used as well, provided you're not interested in taking autocorrelation into account. I wouldn't bother too much about it in this dataset anyway. That brings us to the following possibility : # restructure the data NewFrame <- data.frame(val=unlist(dat[,-1])) NewFrame$week <- rep(6:17,each=39) NewFrame$subject <- rep(1:39,times=12) NewFrame$DC <- rep(dat[,1],times=12) # build the model require(nlme) options(contrasts=c("contr.sum","contr.poly")) # I always use those mod.ok <- lme(val ~ DC*week, random = ~1|subject/week , data=NewFrame) anova(mod.ok) Post-hoc testing can be done as explained in the link above. Mind you, I'm not saying this is a perfect or even a correct solution. You have to be VERY careful when interpreting the results. But at least it gives you some indication about the research questions you have. In any case, the amount of information in your data is pretty low due to the high amount of identical values. Actually, you can in no possible way consider your dependent a continuous variable, so a repeated measures ANOVA is not the correct method. forget about GAM modelling, they have far too much degrees of freedom to do anything that makes sense with your data. Actually, as I see it you should have some kind of ordinal logistic model, but again, your data is far too sparse and has too much aliasing to expect anything decent coming out of such an analysis. Sorry to break it to you, but this is a classic case of "analysis died due to a lack of useable data". Cheers Joris On Thu, May 6, 2010 at 1:42 PM, Tal Galili <tal.gal...@gmail.com> wrote: > Hi Joris, > Thank you for taking the time to answer. > > This data is of a test done for 39 subjects (from 2 groups) over 12 weeks. > And the questions I would like to answer are: > 1) Did the test results changed over time? > 2) Did the group effected the test results? > 3) Did the effect of time differ for each group? > > I understand that the general limitation of using repeated measures anova > here is (obviously) that even if one get's a significant "effect" of time, > the analysis doesn't give any clue as to how time influences the test (the > same goes for the interaction term). > But a more appropriate tool would probably be some sort of GAM lm, which is > based on models I don't have much understanding of (yet). > > I am using this test since the researcher for whom I am doing the analysis > asked me to use it (since this is what was done in the previous work on > similar data, done by someone else). > > Due to the current stage of my ignorance, and the researchers tendency > towards this analysis - I am not sure how to proceed. > > > > Thanks, > Tal > > > > > ----------------Contact > Details:------------------------------------------------------- > Contact me: tal.gal...@gmail.com | 972-52-7275845 > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | > www.r-statistics.com (English) > > ---------------------------------------------------------------------------------------------- > > > > > On Thu, May 6, 2010 at 2:25 PM, Joris Meys <jorism...@gmail.com> wrote: > >> Hi Tal, >> >> The problem is not the analysis, but the data. You have 2 weeks that only >> have a value 4, and 31 out of 39 cases that only have a value 4. Your >> residual matrix is thus malformed, and has a lower rank than the amount of >> weeks minus 1. This makes it impossible to do the calculations in the Anova >> procedure. Even when dropping the weeks where the value is 4 for every case, >> the analysis can't be performed. >> >> Cheers >> Joris >> >> What is it you want to know exactly? >> On Thu, May 6, 2010 at 11:57 AM, Tal Galili <tal.gal...@gmail.com> wrote: >> >>> Hello all, >>> >>> I am getting the following error: >>> >>> Error in linear.hypothesis.mlm(mod, hyp.matrix.1, SSPE = SSPE, V = V, : >>> The error SSP matrix is apparently of deficient rank = 7 < 11 >>> >>> After running: >>> mod.ok <- lm(as.matrix(dat[,-1]) ~ DC, data=dat) >>> (av.ok <- Anova(mod.ok, idata=idata, idesign=~week)) >>> >>> Although if I jitter the data in "dat", the function seems to work. >>> >>> What should I do ? >>> >>> (here is a self sufficient example code of my situation) >>> >>> >>> >>> >>> >>> #------------- R code -------------------- >>> >>> # creating data >>> idata <- structure(list(week = structure(1:12, .Label = c("week6", >>> "week7", >>> "week8", "week9", "week10", "week11", "week12", "week13", "week14", >>> "week15", "week16", "week17"), class = "factor")), .Names = "week", >>> row.names = c(NA, >>> -12L), class = "data.frame") >>> >>> dat <- structure(list(DC = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, >>> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, >>> 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = >>> c("control", >>> "head (20g)"), class = "factor"), week6 = c(4, 4, 4, 4, 4, 4, >>> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, >>> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), week7 = c(4, 4, 4, 4, 4, >>> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, >>> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), week8 = c(4, 4, 4, 4, >>> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, >>> 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 4), week9 = c(4, 4, 3, >>> 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, >>> 3, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 3), week10 = c(4, 4, >>> 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, >>> 4, 3, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 3), week11 = c(4, >>> 4, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, >>> 4, 4, 3, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 3), week12 = c(4, >>> 4, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, >>> 4, 4, 3, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 3), week13 = c(4, >>> 4, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, >>> 4, 4, 3, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 3), week14 = c(4, >>> 4, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, >>> 4, 4, 2, 4, 3, 4, 4, 4, 4, 3, 4, 2, 4, 4, 4, 4, 3), week15 = c(4, >>> 4, 2, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, >>> 4, 4, 1, 4, 3, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 3), week16 = c(4, >>> 4, 2, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, >>> 4, 4, 0, 4, 3, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 3), week17 = c(4, >>> 4, 1, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, >>> 4, 4, 0, 4, 2, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 3)), .Names = c("DC", >>> "week6", "week7", "week8", "week9", "week10", "week11", "week12", >>> "week13", "week14", "week15", "week16", "week17"), class = c("cast_df", >>> "data.frame"), row.names = c(NA, 39L)) >>> # This fails >>> mod.ok <- lm(as.matrix(dat[,-1]) ~ DC, data=dat) >>> (av.ok <- Anova(mod.ok, idata=idata, idesign=~week)) >>> >>> # But this works >>> dat[,-1] <- apply(dat[,-1],2, jitter ) >>> mod.ok <- lm(as.matrix(dat[,-1]) ~ DC, data=dat) >>> (av.ok <- Anova(mod.ok, idata=idata, idesign=~week)) >>> >>> #------------- R code -------------------- >>> >>> >>> Thanks in advance, >>> Tal >>> >>> ----------------Contact >>> Details:------------------------------------------------------- >>> Contact me: tal.gal...@gmail.com | 972-52-7275845 >>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | >>> www.r-statistics.com (English) >>> >>> ---------------------------------------------------------------------------------------------- >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list >>> 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. >>> >> >> >> >> -- >> Joris Meys >> Statistical Consultant >> >> Ghent University >> Faculty of Bioscience Engineering >> Department of Applied mathematics, biometrics and process control >> >> Coupure Links 653 >> B-9000 Gent >> >> tel : +32 9 264 59 87 >> joris.m...@ugent.be >> ------------------------------- >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php >> > > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list 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.