Skip to content

predict/residual

2 messages · Michaell Taylor, Brian Ripley

#
I am having trouble understanding the way naresid is used when using
predict/residual in a new data frame.
original frame, but are dropped when applied to a new frame.

ultimately I need to cbind the residuals and predictions to a dataframe.
Any help would be appreciated. Thanks in advance.
# CREATE A MISSING VALUE
1          2          3          4          5         
6          7 
 0.9152478  1.5665630  1.1444221  0.4781361         NA  0.1659269 
0.6856764 
         8          9         10 
 1.5615913 -0.1687372  0.4164926 

# MAKE A COPY OF A, THEN CHANGE A COUPLE OF VALUES
2           3           4           6           7           8 
  1.5665630 -44.9938287   0.4781361   0.1659269   0.6856764   1.5615913 
          9          10 
 -0.1687372   0.4164926
#  THE PROBLEM IS OF COURSE THAT I NO LONGER HAVE APPROPRIATE MISSING
VALUES IN THE VECTOR - obs 1 and 5 are no-shows.


Michaell
#
On 26 Apr 2003, michaell taylor wrote:

            
[From the example, for an lm fit, and for predict: you cannot use 
`residual in a new data frame'.]

It isn't: what makes you think otherwise?  naresid is *never* used for 
prediction, and napredict is only used for predictions on the fitted data 
set.

I think you want to set na.action=na.pass whilst making your predictions,
which you will have to do via options() as predict.lm uses the default, 
na.omit.  (I would call that a design error in predict.lm: some other 
predict methods handle this better.)

BTW `_' is stringly deprecated, and defunct in R-devel.