From tlumley at u.washington.edu  Wed Jul 19 17:30:04 2006
From: tlumley at u.washington.edu (Thomas Lumley)
Date: Wed, 19 Jul 2006 08:30:04 -0700 (PDT)
Subject: [Rd] Bug?: summary() fails after use of na.action="na.exclude"
 in lm()
In-Reply-To: <44BDFA61.20500@bfro.uni-lj.si>
References: <44BDFA61.20500@bfro.uni-lj.si>
Message-ID: <Pine.LNX.4.64.0607190823230.6767@homer23.u.washington.edu>

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



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