Hi: See below.
On Mon, Aug 30, 2010 at 2:21 PM, Bruce Johnson <bruce.ejohn...@verizon.net>wrote: > I am trying to do post-hoc tests associated with a repeated measures > analysis with on factor nested within respondents. > > The factor (SOI) has 17 levels. The overall testing is working fine, but I > can't seem to get the multiple comparisons to work. > > The first step is to "stack" the data. > > Then I used "lme" to specify and test the overall model. > > Finally I'm trying to use "glht" to do multiple comparisons. > > Here's my code and the resulting output. > > > ImpSoi<-ImpData[,c("iobs", soi)] > > > ImpSoi[1:5,] > > iobs soi1 soi2 soi3 soi4 soi5 soi6 soi7 soi8 soi9 soi10 soi11 soi12 soi13 > soi14 soi15 soi16 > > 1 32 7.00 7.00 7.00 7.00 7.00 6.00 7.0 7.00 5.00 7.00 7.00 7.00 7.00 > 5.00 7.00 6.00 > > 2 70 5.95 4.95 7.00 4.95 5.20 5.40 4.2 3.95 4.15 4.95 4.85 4.95 6.75 > 5.95 5.20 5.10 > > 3 78 3.00 1.00 4.75 2.75 3.00 4.50 4.0 4.00 1.50 4.00 4.00 4.50 2.50 > 3.00 3.75 4.00 > > 4 104 3.75 3.50 6.25 5.25 4.25 3.75 4.0 5.25 4.75 4.75 5.00 5.75 6.00 > 4.00 4.75 3.75 > > 5 117 5.00 5.00 4.00 5.00 2.00 4.62 5.0 4.00 4.00 4.00 5.00 4.00 4.70 > 4.70 5.00 2.00 > > soi17 > > 1 7.00 > > 2 5.15 > > 3 4.00 > > 4 5.50 > > 5 4.00 > > > stack <- > reshape(ImpSoi,varying=soi,timevar="solution",idvar="iobs",sep="", > dir="long") > > > solution <- factor(solution,levels(1:17),) > > > stack[1:5,] > > iobs solution soi > > 32.1 32 1 7.00 > > 70.1 70 1 5.95 > > 78.1 78 1 3.00 > > 104.1 104 1 3.75 > > 117.1 117 1 5.00 > Try str(stack) at this point. Is solution a factor? (Hint: You defined solution *outside* of the stack data frame. Now look at ls(), which tells you the variables in your global workspace.) > > Lmes.mod <- lme(soi ~ solution + iobs, random = ~1 | iobs/solution, data > = > stack) > > > anova(Lmes.mod) > > numDF denDF F-value p-value > > (Intercept) 1 2383 2894.8342 <.0001 > > solution 1 2383 0.0003 0.9870 > > iobs 1 147 0.0126 0.9109 > > > summary(glht(Lmes.mod, linfct=mcp(solution="Tukey"))) > > Error in mcp2matrix(model, linfct = linfct) : > > Variable(s) 'solution' of class 'numeric' is/are not contained as a factor > in 'model'. > This is telling you solution is a numeric variable in stack at this point, correctly so. > > > > I don't understand the error since "solution" is clearly a factor in the > model. > Here's what I don't understand. Why do you believe a procedure that will produce 17 * 16 / 2 = 136 pairwise comparisons will be scientifically meaningful? Please tell me you're not using a time variable as an unordered factor with 17 levels... If you don't understand why that's a problem, you need to consult with a local statistical expert. Seriously. HTH, Dennis > > Any suggestions would be welcome. > > Bruce > > > > > > > [[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. > [[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.