Skip to content

NAs spoil lowess smoothing

3 messages · Stuart Luppescu, Thomas Lumley, Brian Ripley

#
Can anyone explain to me what this error message means, why I'm getting it, and
how to fix it?

 lines(lowess(xdat, ydat, f=.5), col=3)
Error: NAs in foreign function call (arg 1)
______________________________________________________________________
Stuart Luppescu         -=-=-  University of Chicago
ºÍʸ ¤ÈÃÒÆàÈþ¤ÎÉã(EUC)  -=-=-  s-luppescu at uchicago.edu
http://www.consortium-chicago.org/people/sl/sl.html
ICQ #21172047  AIM: psycho7070
The program isn't debugged until the last user is dead.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 28 Jan 1999, Stuart Luppescu wrote:

            
It means that in a call to .C or .Fortran there are missing values in the 
first argument. The call to .C is inside lowess(), and its first argument
is the x data. So you're getting it because there are NAs in xdat.

You can fix it by removing the NAs, eg
	good<-!(is.na(xdat) | is.na(ydat))
	lines(lowess(xdat[good],ydat[good],f=.5),col=3)

Refusing to handle NAs is the usual default behaviour of functions. Some
functions have na.action= arguments to control this, but lowess doesn't.


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 28 Jan 1999, Thomas Lumley wrote:

            
Actually, that message is confusing. There could be Infs or NaNs in xdat
rather than NAs. Thomas is probably right, but this is worth bearing in
mind (says he having searched for ages for NAs in a locfit example).
I would take a look at xdat to see what is unexpected (by you).