'Error: cannot subset columns that don't exist: predictY in hlme

I met a strange problem when I tried to get the predicted mean to draw a trajectory plot. I used the results from the following 3-class model:

WK$TIME_25<-(WK$TIME_QRT_R-25)/10  #TIME_QRT_R is the orginal time variable
m3a <- hlme(GFR_QRT_MEAN~ poly(TIME_25, degree = 3, raw = 
TRUE)+GENDER+AGE_BL+HOSP+PROTEINURIA_bl,random = ~ 1,  mixture=~poly(TIME_25, degree = 3, raw 
 = TRUE),subject = "ID",data = WK,  ng = 3,B=m1)

After I got the results, I tried to create new dataset to draw trajectory mean plot. My codes are as below:

datnew<-data.frame(TIME_QRT_R=seq(0,27,length=100)
datnew$TIME_25<-(datnew$TIME_QRT_R-25)/10
datnew$GENDER<-1
datnew$AGE_BL<-64
datnew$HOSP<-1   # 1 stands for hospitalization
datnew$PROTEINURIA_bl<-1  # 1 stands for the presence of renal damage
mon_p<-predictY(m3a, datnew, var.time='TIME_QRT_R', draws=T)

To my surprise, I got the following error message after running the 'predictY' statement above: "Error: cannot subset columns that don't exist. x column 'TIME_25' doesn't exist" I created 'TIME_25' in the 'datnew' data, and the hlme model also includes this variable. Why did I get this error? Could you let me know how to fix it? Thank you!

Sincerely, Liang Feng

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source