> D<-data.frame(x=c(NA,2,3,4,5,6),y=c(2.1,3.2,4.9,5,6,7),residual=NA)
> Z<-lm(y~x,data=D)
> D[names(Z$residuals),"residual"]<-Z$residuals
> D
x y residual
1 NA 2.1 NA
2 2 3.2 -0.28
3 3 4.9 0.55
4 4 5.0 -0.22
5 5 6.0 -0.09
6 6 7.0 0.04
http://stackoverflow.com/questions/6882709/how-do-i-deal-with-nas-in-residuals-in-a-regression-in-r
0 件のコメント:
コメントを投稿