Re: [R] predict.lm with NAs

2010-04-15 Thread Walmes Zeviani
You can use predict() by specifying a complete data.frame() for prediction to the argument newdata=. Look: da <- expand.grid(x1=LETTERS[1:4], x2=1:9) da$y <- rnorm(da$x1) da$y[sample(length(da$y), 5)] <- NA m0 <- lm(y~x1+x2, data=da) predict(m0) # NA not predicted predict(m0, newdata=da) # NA pr

Re: [R] predict.lm with NAs

2010-04-14 Thread Wincent
see ?na.exclude you can set na.action='na.exclude' when fit the model. On 15 April 2010 09:06, Martin Batholdy wrote: > Hi, > > I wanted to use the predict.lm() function to compare the empirical data with > the predicted values. > The problem is that I have NAs in my data. > > I wanted to cbin

[R] predict.lm with NAs

2010-04-14 Thread Martin Batholdy
Hi, I wanted to use the predict.lm() function to compare the empirical data with the predicted values. The problem is that I have NAs in my data. I wanted to cbind my data.frame with the empirical values with the vector I get from predict.lm. But they don't have the same length because predict.