predict.lme / nlmmPQL: "non-conformable arguments"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

predict.lme / nlmmPQL: "non-conformable arguments"

David Reitter
I'm trying to use "predict" with a linear mixed-effects logistic  
regression model fitted with nlmmPQL from the MASS library.
Unfortunately, I'm getting an error "non-conformable arguments" in  
predict.lme, and I would like to understand why.

I have used the same call to "predict" with "glm" models without  
problems. I assume I'm doing something wrong, but I have no idea what  
it is. If someone could help me (even by telling me how to trace this  
properly - is there an interactive tracer/debugger I can use?),  
that'd be fantastic.

Here's what I'm doing:

 > summary(model)
...
Random effects:
Formula: ~log(distance) | target.utt
...
Fixed effects: primed ~ log(distance) * role * source - log
(distance):source
...

 >  x=10:500*0.1
 >  new <- data.frame(distance=x, role="r", source="m"  )

 > yp = predict(model,  newdata=new, type="response",  level=0)
Error in X %*% fixef(object) : non-conformable arguments


 > traceback()
4: predict.lme(object, newdata, level = level, na.action = na.action)
3: predict(object, newdata, level = level, na.action = na.action)
2: predict.glmmPQL(model, newdata = new, type = "response", level = 0)
1: predict(model, newdata = new, type = "response", level = 0)

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: predict.lme / glmmPQL: "non-conformable arguments"

David Reitter
  On 30 Jan 2006, at 22:01, David Reitter wrote:

> I'm trying to use "predict" with a linear mixed-effects logistic  
> regression model fitted with nlmmPQL from the MASS library.
> Unfortunately, I'm getting an error "non-conformable arguments" in  
> predict.lme, and I would like to understand why.

I'd like to add a bit of information. (Correction: I am talking about  
glmmPQL from the MASS library.)

Again, the error I'm getting is:

> > yp = predict(model,  newdata=new, type="response",  level=0)
> Error in X %*% fixef(object) : non-conformable arguments

I have ensured that I input a data frame in newdata with the fixed  
factors/predictors filled in (as factors with the correct level sets  
where appropriate).

Debugging this, I had a look at lme.R from the nlme library.
Specifically, line 1909:

if (maxQ == 0) {
     ## only population predictions
     val <- c(X %*% fixef(object))
     attr(val, "label") <- "Predicted values"
     return(val)
   }

the 'fixef' structure in my model looks like this (7 elements)

fixef(model)
                       (Intercept)                     log(distance)
                       -2.14560407                       -0.13207341
                             roler                     sourcemaptask
                       -0.58692474                       -0.93108113
               log(distance):roler log(distance):rolei:sourcemaptask
                        0.16449238                        0.06877369
log(distance):roler:sourcemaptask
                       -0.12278367


But the predict.lme function produces the following 6x5 matrix

   (Intercept) log(distance) roler sourcemaptask log
(distance):roler    log(distance):roler:sourcemaptask
           1     0.0000000     1             0           0.0000000  0
          1     0.6931472     1             0           0.6931472  0
(...)

We're missing the coefficient for the 3-way interaction "log
(distance):rolei:sourcemaptask", which is why we can't come up with  
the inner product of X and the fixed effects coefficients.

Is this an issue with predict.lme, and/or can I do something about it?

Thanks
D

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: predict.lme / glmmPQL: "non-conformable arguments"

David Reitter
 > I'm trying to use "predict" with a linear mixed-effects logistic
 > regression model fitted with nlmmPQL from the MASS library.
 > Unfortunately, I'm getting an error "non-conformable arguments" in
 > predict.lme, and I would like to understand why.

I'd like to briefly describe how I ended up working around this problem.

The issue is that predict.lme (nlme package) is unhappy when not all  
factor levels actually occur in the data given to it via "newdata".

Therefore I had to add a few dummy data points to the data frame  
given to "predict", containing examples of all factor levels. The  
predictions for these dummies can, of course, later be removed from  
the result. Specifying the possible levels with factor(X, levels=c
(...)) does NOT do the job.

Thanks to Jonathan Williams, who set me on the right track.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html