[R] lmList Error in !unlist(lapply(coefs, is.null))

Lorenzo Lucchi lorenzolucchi at student.eur.nl
Wed May 13 11:03:07 CEST 2015


I have a dataframe with the following structure:

 'data.frame':  13095 obs. of  1433 variables:

 $ my   : Factor w/ 624 levels "19631","19632",..: 1 1 1 1 1 1 1 1 1 1 ...

 $ s1   : num  NA NA NA NA NA NA NA NA NA NA ...



Where my is a factor with the number of the month, s1,..,,s1426 vectors that contain my dependent variable, f1,..,f6 vectors that contain my indepent variables.

S1 is a vector with many NA observations.

I want to regress s1 on f1,...,f6. To make the regression, I used the following code:


 try1 <- lmList(s1 ~ f1+f2+f3+f4+f5+f6 |my , data=d1)

 try1

And I received the following output:
Call: lmList(formula = s1 ~ f1 + f2 + f3 + f4 + f5 + f6 | my, data = d1)
Coefficients:
Error in !unlist(lapply(coefs, is.null)) : invalid argument type

I tried to change na.action to na.omit but I have the same output.

I tried to create a new dataframe with:
d2<-data.frame(d1$my,d1$s1,d1$f1,d1$f2,d1$f3,d1$f4,d1$f5,d1$f6)
colnames(d2)<-c("my", "s1", "f1", "f2", "f3", "f4", "f5", "f6")
d2 has the following structure:

'data.frame':  13095 obs. of  8 variables:

 $ my: Factor w/ 624 levels "19631","19632",..: 1 1 1 1 1 1 1 1 1 1 ...

 $ s1: num  NA NA NA NA NA NA NA NA NA NA ...

 $ f1: num  -0.54 1.66 0.68 0.06 0.9 -0.16 0.19 0.25 0.57 -0.1 ...

 $ f2: num  0.94 0.98 0.63 0.32 -0.03 0.11 0.2 -0.03 0.07 0.01 ...

 $ f3: num  0.31 -0.25 0.02 0.29 0.22 0.07 -0.09 -0.17 0.21 0.28 ...

 $ f4: num  1.5 1.7 1.14 -0.02 0.36 0.49 -0.13 0.18 0.14 0.47 ...

 $ f5: num  -0.5 -1.96 -0.66 -0.17 -0.43 0.24 -0.12 -0.01 -0.58 0.52 ...

 $ f6: num  0.38 0.3 0.35 0.3 0.08 0.13 -0.18 -0.05 -0.08 0.03 ...

When I run the regression:

try2<-lmList(s1~f1+f2+f3+f4+f5+f6|my,data=d2)

try2,



It works without any problem.

How can I solve the problem? I need to run a regression for every s, so I can't just create a new dataframe every time. I read the documentation of lmList and also this site but I didn't find anything related at the size of the dataframe, so I don't think that the problem depends from the size of d1, but for all the other things the two dataframe are equivalent.
I also tried to create an example but when I build a new dataframe, also with many NA like my file, I don't have these problems (i.e. lmList works fine).





	[[alternative HTML version deleted]]



More information about the R-help mailing list