[R] lines(predict(nls()) with NA's

Fred Jean Frederic.Jean at univ-brest.fr
Tue Jul 9 17:14:54 CEST 2002


Dear List,

my exploration of R goes on... And I REALLY enjoy it ! (thanks to all guRus).

Yesterday a colleague ask me for fitting some data presented as a data.frame,
something like :

>a
        x X158.7  X150.0  ...
1   -0.25    506   183.1
2   -0.75    633   210.7
3   -1.25    674   220.3
4   -1.50     NA   244.6
5   -1.75    742   261.2
6   -2.25    787   269.1
7   -2.50     NA   283.5
8   -2.75    794   287.6
9   -3.25    816   296.4
10  -3.50     NA   307.9
...

I used the nls package :

>nls(nls(X158.7 ~ Cd + ((158.7-Cd)*exp(b*x)),
start=list(b=0.5,Cd=500),na.action=na.omit,trace=T)->mod1

then, to look at the result
> plot(x,X158.7, pch='+', col='blue')

but (not surprisingly)
> lines(predict(mod1),lty=2,col='red')

doesn't line anything as long as there are NA's in the dependant vector.
How can I make this work and get my nice plots ?

Thanks 
Sincerely yours

Fred

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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