2021年5月7日星期五

lme() function return error "complete.cases(object) : not all arguments have the same length"

I have a problem when using lme() function in R to do a Penalized-Spline Regression Analysis into my data.
My response variable is an 17x1 numeric vector and my predictor variable is an 17x5 numeric matrix

My code is like this :

y <- as.vector(data[,1])  X <- as.matrix(cbind(1,data[,2:5]))  knot <- c(1078.33,1585.85,2151.14,2688.52)  z.spline <- outer(as.matrix(data[,6]),knot,"-")  idnum <- 1:17  id <- factor(idnum)  group <- 1:17  ZBlock <- pdBlocked(list(pdIdent(~z.spline-1), pdIdent(~id-1)))  dataFr <- groupedData(y ~ X|group, data=data.frame(y,X,z.spline,idnum))  fit <- lme(fixed = y ~ -1+X, data = dataFr, random = ZBlock)  

When I run the last code, it returns an error "complete.cases(object) : not all arguments have the same length". I assume it is somewhere inside the lme() function but i can't find the cause. You can get my data here, so that you can run the code too.

Thank you!

https://stackoverflow.com/questions/67443708/lme-function-return-error-complete-casesobject-not-all-arguments-have-the May 08, 2021 at 11:07AM

没有评论:

发表评论