[R] lmList and missing values

Henrik Parn henrik.parn at bio.ntnu.no
Fri Aug 18 16:27:25 CEST 2006


Dear all,

I have a question on handling of missing values in lmList. My data set 
have continuous predictor and response, x and y, and a grouping variable 
group.id. All these variables have NAs and the data set also has several 
other variables that also contains NAs.

To create the lmList-object seems to work fine:
y.list <- lmList(y ~ x | group.id, data=mydata, na.action=na.omit)

However, when I try to apply functions on the object such as coef or 
intervals it fails:

 > coef(y.list)
Error in !unlist(lapply(coefs, is.null)) :
        invalid argument type


If I beforehand select only the variables (still including missing 
values) used as arguments in lmList...
 
mydata2 <- mydata[ , c("x", "y", "group")]

...and use mydata2 in lmList as above, coef and intervals works fine.

In order to provide a reproducible example, I made a small test data 
set. This data set contained the same pattern of NAs as in my real data 
set, i.e. NAs in both used and unused variables. The example turned out 
to be not very illustrative though, because strange enough 
'na.action=na.omit' works just fine on the small test data set so I 
don't bother to include it here...

I have not encountered any problems to apply other functions, such as lm 
or lme, to my data set.

Any idea what causes the error?

A related problem seems to have occured before, although it is not clear 
if different na.action options was tried in this case:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/14293.html


Thanks in advance for any help!

Best regards,

Henrik

-- 
************************
Henrik Pärn
Department of Biology
NTNU
7491 Trondheim
Norway

+47 735 96282 (office)
+47 909 89 255 (mobile)
+47 735 96100 (fax)



More information about the R-help mailing list