[R] ask for help about lme function
Juan Liu
21707095 @end|ng |rom zju@edu@cn
Tue Jul 20 16:32:23 CEST 2021
Dear R project,
I am a doctoral student in Zhejiang university in China, I am using lme function in nlme package and learning the function by Package 'nlme' document. I am writing this email for some help to build a lme model.
My goal was to include two non-nested random effects in the lme model. the document described how to write the random effects while I found it difficult for me to understand. My problem are as below:
In these model, site and year were considered as non nested effects. I want to set the structure in lme model the same as lmer model(the 1st model below), and I used the structure "random=list(site=~1,year=~1)"(the 2nd model below) . According to the result, the lme model was obviously wrong, for the R2 and AIC were different from that of lmer model. I want to know to get the same result as lmer model, how should I set the random argument?
Below is the model and results in R,
################################################################1. lmer function
lmer<-lmer(data, y~x1+x2+x3+(1|site)+(1|year))
r2(lmer)##58.8%;29.7%
r.squaredGLMM(lmer)##58.8%; 29.72%;AIC=462.4
###################################################################2. lme1
lme1<-lme(data, y~x1+x2+x3,random = list(site=~1,year=~1))
r2(lme1)## NA(can't get the result)
r.squaredGLMM(lme1)##92.4%; 30.89%;AIC=533
I will be appreciated for your help.
Yours sincerely,
Juan Liu
Juan Liu
PhD candidate
College of Life Sciences, Zhejiang University
866 Yuhangtang Road, Hangzhou
Zhejiang 310058, P.R.China
21707095 using zju.edu.cn; liujuan_1994 using outlook.com
[[alternative HTML version deleted]]
More information about the R-help
mailing list