Dear R-helpers:
May I ask a question related to storing a number of lmer model fit into a
list.

Basically, I have a for-loop (see towards the bottom of this email)
in the loop, I am very sure that the i-th model fit (i.e.,fit_i) is
successfully generated and the character string (i.e., tmp_i) is created
correctly.
The problem stems from the following line in the for-loop
#trouble making line below
fit.list[[tmp_i]] <- fit_i


I tried the following example which stores glm() model fit without a
problem.
#the following code can store glm() model fit into a list
---------------------------------------------------
x1<-runif(200)
x2<-rnorm(200)
y<-x1+x2
testdf<-data.frame(y=y, x1=x1, x2=x2)
indepvec<-c("x1","x2")
fit.list<-NULL
fit_1<-glm(y~x1,data=testdf)
fit_2<-glm(y~x2,data=testdf)
fit.list[[paste('fit_',indepvec[1],sep='')]]<-fit_1
fit.list[[paste('fit_',indepvec[12],sep='')]]<-fit_2
----------------------------------------------------
so why cannot I store lmer() model fit in a list?
Would someone kindly explain to me what the R error message(last line of
this email) really means?
Your kind help will be highly appreciated!

-Sean

#the following for-loop intends to store lmer() random poisson model output
into list (fit.list), it does not work
---------------------------------------------------------------------------
fit.list<-NULL
for (i in seq_along(depvar_vec))
    {
      #I found that s_sex, ses1 and race are not useful
      fit_i <- lmer(as.formula(gen.ranpoisson.fml.jh(depvar_vec[i],
offsetvar ,factorindepvars,  nonfactorindepvars ,ranintvar )),
family=quasipoisson(link="log"),verbose=F, data=indf)
      tmp_i<-paste('ranpoi_', depvar_vec[i], sep='')
      fit.list[[tmp_i]] <- fit_i
      #assign also does not work
      #assign(fit.list$parse(text = tmp_i), fit_i)
     }
---------------------------------------------------------------


#R gives the following error message.

Error in fit.list[[tmp_i]] <- fit_i : invalid type/length (S4/0) in vector
allocation

	[[alternative HTML version deleted]]


