[R] Question about lmer

From: Julia Proudnikova <prudnikova_at_itcwin.com>
Date: Mon, 18 Jun 2007 14:02:13 +0400


Hello,

We have a problem with function lmer. This is our code:

Get_values<-function(ff_count, fixed_factors, rf_count, random_factors, y_values) {
  SA<-matrix(as.array(c(fixed_factors, random_factors)), ncol=3)   data<-as.data.frame(SA)
  y<-as.array(y_values)

  dd<-data.frame(SA)
  for(i in 1:(ff_count+rf_count)){
    dd[,i]<-as.factor(data[,i])
  }   

  fit_full=lmer(y~dd[,1]+dd[,2]+(1|dd[,3]),method="ML")   fit_full
}

A<-c(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1)
B<-c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1)
C<-c(0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1)
Y<-c(5,3,4,1,1,2,6,1,5,3,7,1,2,3,1,1,5,3,4,1,1,2,6,1,5,3,7,1,2,3,1,1)
r<-Get_values(2, c(A,B),1,c(C),Y)

r

R output:
Error in inherits(x, "factor") : object "dd" not found

Can this function work with random array? Because this code is working:

D<-as.factor(data[,3])
fit_full=lmer(y~dd[,1]+dd[,2]+(1|D),method="ML")  

-- 
Truly yours,
Julia                 mailto:prudnikova_at_itcwin.com

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 18 Jun 2007 - 10:14:57 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Jun 2007 - 12:32:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.