Re: [Rd] Bug?: summary() fails after use of na.action="na.exclude" in lm()

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Wed 19 Jul 2006 - 15:30:04 GMT

On Wed, 19 Jul 2006, Gregor Gorjanc wrote:
> I have encountered a weird problem and I am wondering if this is a bug.
> Here is the example:
>
> n <- 50
> x <- runif(n=n)
> y1 <- 2 * x + rnorm(n=n)
> y2 <- 5 * x + rnorm(n=n)
> y2[sample(1:n, size=5)] <- NA
>
> y <- cbind(y1, y2)
>
> fit <- lm(y1 ~ 1, na.action="na.exclude")
> summary(fit)
>
> ## Goes ok here
> fit <- lm(y2 ~ 1, na.action="na.exclude")
> summary(fit)
>
> ## But fails if we use matrix of response variables
> fit <- lm(y ~ 1, na.action="na.exclude")
> summary(fit)
>
> ## Response y1 :
> ##
> ## Call:
> ## lm(formula = y1 ~ 1, na.action = "na.exclude")
> ##
> ## Residuals:
> ## Error in quantile.default(resid) : missing values and NaN's not
> allowed if 'na.rm' is FALSE
>

Yes, I think it's a bug.

  summary.mlm() produces an object that is a list of objects of class "summary.lm", but these objects get their $resid component from the residuals() function and so NAs in their $resid component where a "summary.lm" produced by summary.lm() would not.

         -thomas



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Jul 20 02:51:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 20 Jul 2006 - 14:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.