다중 레벨 모델에서 데이터 프레임의 각 열 (한 번에 하나씩)을 사용하는 간단한 방법이 있습니까? 내가 this 게시물을 찾았지만, 다른 열을 IV로 사용하여 DV를 제공합니다. 나는 상보을하려고하고있는 알 수없는 DV 및 열을 테스트하기 위해 알려진 IV (1) 의미 :DV로 모든 열을 개별적으로 사용하는 모델
library(nlme)
exampledf<- data.frame(matrix(ceiling(runif(16,0,50)), ncol=4))
colnames(exampledf)<-c("a","b","id_num","d")
my.control<-list(opt='optim',method='ML')
lme(.~1,random=~1|id_num,na.action=na.fail,data=exampledf,control=my.control) #fails
내 목표 출력 (이들의 값을 특정 열 이름을 지정하지 않고) :
lme(a~1,random=~1|id_num,na.action=na.fail,data=exampledf,control=my.control)
lme(b~1,random=~1|id_num,na.action=na.fail,data=exampledf,control=my.control)
lme(d~1,random=~1|id_num,na.action=na.fail,data=exampledf,control=my.control)
A-드문 일이 아니다 움직임은 당신의 목록을 끝낼 수 있도록 수식 문자열로를 paste'하고, 실제 공식에 그것을 강요','이름 (exampledf)'에서 lapply''에있다 모델. 모두 함께, lapply (이름 (exampledf) [- 3], 함수 (x) {lme (붙여 넣기 (x, '~ 1')), 임의 = ~ 1 | id_num, na.action = na. data = exampledf, control = my.control)})' – alistaire