David Reitter
2006-Jan-30 22:01 UTC
[R] predict.lme / nlmmPQL: "non-conformable arguments"
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)
David Reitter
2006-Jan-31 20:39 UTC
[R] predict.lme / glmmPQL: "non-conformable arguments"
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 argumentsI 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