Dear Mixed Model users,

I want to fit the same mixed model to each of 21 variables (columns)  
in my dataset. If coded individually for each variable it would look  
like this:

lmer(colour ~ feed + (-1 + feed | taster), data = data2)

Then I just change 'colour' and run through the variables on at a  
time. Or I can use apply or for statements like this to cycle through  
each variable like this:

auto <- function(x) lmer(x ~ data2$feed + (-1 + data2$feed | data2 
$taster))
apply(data2[3:22], 2, auto)

or

for(i in 3:22) print(c(names(data2[i]), summary(lmer(data2[,i] ~ 1 +  
data2$feed + (-1 + data2$feed | data2$taster)))))

Either works fine. However, when I try the same with lme it does not  
work:

 > for(i in 3:22) lme(data2[,i] ~ data2[25], random = ~1 | data2[2]/ 
data2[25], method = "ML")

Error in model.frame(formula, rownames, variables, varnames, extras,  
extranames,  :
	invalid type (list) for variable 'data2'

(column 25 is has the name taster, and 2 feed)

Any ideas why it works for one but not the other? I suppose I could  
stack the 21 response variable and then use dummy variables to code  
the multivariate response, but that would be a bit cumbersome.

Thanks,
AJ

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr Albertus J Smit
(Marine Biologist)
School of Biological & Conservation Sciences
G. Campbell Building
University of KwaZulu-Natal
Howard College Campus
Durban 4041, South Africa

E-mail: smitaj@ukzn.ac.za
Tel. +27 031 260 7410;
Fax +27 031 260 2029

Marine Biology web page: http://marinesci.ukzn.ac.za/biology
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"The ocean weeds out, from all the races of mankind that come upon it  
to make a living, a certain type of person. This type of person stays  
with the ocean, and the rest are cast back ashore to deal with the  
land people." ~~ Wilbert Chapman


	[[alternative HTML version deleted]]


