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

> 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'.

> 

I don't understand the error since "solution" is clearly a factor in the
model.

Any suggestions would be welcome.

Bruce

 

 


	[[alternative HTML version deleted]]

