[Rd] na.action=na.omit doesn't omit in glm() (PR#1282)
Prof Brian D Ripley
ripley@stats.ox.ac.uk
Fri, 25 Jan 2002 07:46:38 +0000 (GMT)
On Fri, 25 Jan 2002 Ralph.MacNally@sci.monash.edu.au wrote:
> Full_Name: Ralph Mac Nally
> Version: 1.40
> OS: MacOS9x/Windows98
> Submission from: (NULL) (130.194.13.180)
>
>
> I'm using a simple glm in which the dependent variable may have missing data
> (coded 'NA') as usual. Both the default na.action (na.omit) and explicit
> 'na.action=na.omit' do not seem to ignore the missing data as I expect,
> generating an error to that effect (NA passed to routine). I encounter the same
> problem in classic Mac and Windows98 versions, but S works alright.
>
> What is the source/solution to this problem?
Could we have a reproducible example, please?
Based on example(glm)
counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12)
outcome <- gl(3, 1, 9)
treatment <- gl(3, 3)
d.AD <- data.frame(treatment, outcome, counts)
glm(counts ~ outcome + treatment, family = poisson, data=d.AD)
Degrees of Freedom: 8 Total (i.e. Null); 4 Residual
Null Deviance: 10.58
Residual Deviance: 5.129 AIC: 56.76
d.AD[1, 1] <- NA
glm(counts ~ outcome + treatment, family = poisson, data=d.AD)
Degrees of Freedom: 7 Total (i.e. Null); 3 Residual
Null Deviance: 10.46
Residual Deviance: 4.011 AIC: 50.91
d.AD[9,3] <- NA
glm(counts ~ outcome + treatment, family = poisson, data=d.AD)
Degrees of Freedom: 6 Total (i.e. Null); 2 Residual
Null Deviance: 8.934
Residual Deviance: 2.725 AIC: 45.28
appears to work exactly as advertised.
Or try not using a data frame:
counts[9] <- NA
glm(counts ~ outcome + treatment, family = poisson)
Degrees of Freedom: 7 Total (i.e. Null); 3 Residual
Null Deviance: 8.971
Residual Deviance: 3.204 AIC: 50.5
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._