R-beta: sum of squares and NAs

Bill Simpson wsimpson at uwinnipeg.ca
Fri Jul 3 22:48:43 CEST 1998


This surprised me.  Is it the way it is supposed to be?
> x<-c(1,2,3,4,5)
> y<-c(1.2,1.3,1.4,1.5,NA)
> x-y
[1] -0.2  0.7  1.6  2.5   NA
> (x-y)^2
[1] 0.04 0.49 2.56 6.25  NaN
>>>so NA^2 = NaN? Why not still NA?

> sum((x-y)^2)
[1] NaN
>>>yes that is reasonable

So if you ever have a data set with missing observations (NAs), you can't
do any nlm() least squares fitting? That doesn't seem right.

Thanks for any help.

Bill Simpson

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list