I have a dataset (data1
) as below:
T,D,P,R
1,0,1,1
2,1,1,3
3,0,1,7
1,0,2,2
2,1,2,3
3,1,2,7
1,0,3,1
2,1,3,4
3,1,3,7
1,1,4,1
2,1,4,3
3,0,4,7
To start with, all variables except the response (which is R
) are specified as factors (so D
, T
and P
are factors). I then fit the model:
model1 <- lme(R~D+T,random=~1|P, method="REML",data=data1)
Then I want to use lsmeans
to average across factor levels of D
and P
.
To do this I type:
lsm_model <- lsmeans(model1,~T)
Doing this, I get two error messages:
"Error in
[.data.frame
(tbl, , vars, drop = FALSE) : undefined columns selected
And
Error in ref.grid(object = list(modelStruct = list(reStruct = list(Plot = -11.7209195395097)), : Perhaps a 'data' or 'params' argument is needed"
Why can't I fit lsmeans
to this model? I have used lsmeans
many times without any problems.