Hi.
I'm trying to produce lm fitted values and standard errors for cases with missing y values. I know how to compute these myself with matrix algebra, but I'm wondering if there is an appropriate na.action in the lm function to do this.
Here is some simple code where I use na.action=NULL with a dataset with 2 missing y values, but the model won't estimate. It also won't run with na.action=TRUE or FALSE. Any suggestions would be appreciated.
Thanks much,
Brent Mast
x <- rnorm(15)
y <- x + rnorm(15)
lm <- lm(y ~ x)
fit <- fitted(lm)
fit
# 2 new x cases
newx <- c(x,-3, 3)
# set y to NA for new cases
newy <- matrix(,17,1)
newy[1:15,1] <- y
newdata <- data.frame(newy,newx)
newdata
lmnew <- lm(newy ~ newx,newdata,na.action=NULL)
fitnew <- fitted(lmnew)
fitnew
[[alternative HTML version deleted]]