1

I get this error when I try to predict the nlme. And I don't know how to solve it my code is the following:

mod1.lme <- lme(pRNFL~ status +  Time:status, random= ~1|DBID/Eye_ID, data = long, na.action = na.omit)
summary(mod1.lme)


plot(fitted(mod1.lme), resid(mod1.lme), col = long$status) 
dim(long)
length(fitted(long))
length(fitted(mod1.lme))

long2 <- long[!is.na(long$pRNFL),]  
dim(long2)
plot(long2$pRNFL, fitted(mod1.lme))
plot(long2$pRNFL, fitted(mod1.lme), pch = 16, cex = 0.8, xlab = "Measured pRNFL", ylab = "Model fitted pRNFL")
abline(a = 0, b = 1, col = "red", lty = 2)

A_AQP4 <- subset(long, status=='A-AQP4')
F_AQP4 <- subset(long, status=='F-AQP4')
N_AQP4 <- subset(long, status=='N-AQP4')
A_MOG <- subset(long, status=='A-MOG')
F_MOG <- subset(long, status=='F-MOG')
N_MOG <- subset(long, status=='N-MOG')


x <- c(0:800)/100
A_AQP4data <- data.frame(Time = x, status = "A-AQP4")
F_AQP4data <- data.frame(Time = x, status = "F-AQP4")
N_AQP4data <- data.frame(Time = x, status = "N-AQP4")
A_MOGdata <- data.frame(Time = x, status = "A-MOG")
F_MOGdata <- data.frame(Time = x, status = "F-MOG")
N_MOGdata <- data.frame(Time = x, status = "N-MOG")

yA_AQP4 <- predict(mod1.lme, newdata = A_AQP4data, level = 0)
yF_AQP4 <- predict(mod1.lme, newdata = F_AQP4data, level = 0)
yN_AQP4 <- predict(mod1.lme, newdata = N_AQP4data, level = 0)
yA_MOG <- predict(mod1.lme, newdata = A_MOGdata, level = 0)
yF_MOG <- predict(mod1.lme, newdata = F_MOGdata, level = 0)
yN_MOG <- predict(mod1.lme, newdata = N_MOGdata, level = 0)

Any idea of how can I solve it please? The error is the following:

> yA_AQP4 <- predict(mod1.lme, newdata = A_AQP4data, level = 0)
Error in X %*% fixef(object) : non-conformable arguments

This is a summary of mod1.lme (called here mod2) in case this is useful enter image description here [enter image description here][2 ]

The levels of my variables are different enter image description here

What am I doing wrong?

Thank you!!

Lili
  • 547
  • 6
  • 19
  • 1
    This can often be a sign that the dataset you are trying to `predict` with doesn't have all of the columns required by the model (or if there are factor columns, that they don't share the same set of levels) – JDL Apr 15 '20 at 11:31
  • Thank you very much for helping! I am really struggling with this. pRNFL(numeric), status(factor with 6 levels), Time(numeric), DBID(factor 63 levels) and Eye_ID (factor 114 levels) are columns in the dataset. What do you mean by "same set of levels"? How can I check that? Thank you so much I am on a tight deadline!! – Lili Apr 15 '20 at 11:39
  • I mean that `levels(long$status)` is the same as `levels(A_AQP4data$status)` (and similarly for the other datasets). If there are extra levels in one and not the other, then it could cause this error. – JDL Apr 15 '20 at 11:42
  • I have checked and they are different (edited the post). How should I modify the code now? I am completely lost... – Lili Apr 15 '20 at 11:49
  • I presume the mistake could be other though. Cause I have another model (in a different data frame) where: > levels(df$status) [1] "H" "NON" "ON" > levels(ONdata$status) [1] "ON" And it works perfectly and the function predict does its job. > – Lili Apr 15 '20 at 11:57
  • I think the problem can be under fixDF tab? – Lili Apr 15 '20 at 12:06

0 Answers0