[R] Sigmoidal fitting

Bernardo Rangel Tura tura at centroin.com.br
Sun Mar 4 14:55:09 CET 2007


On Sat, 2007-03-03 at 16:30 -0500, Cressoni, Massimo (NIH/NHLBI) [F]
wrote:
> I am trying to write a function that fits a sigmoid given a X and Y vector guessing the start parameters.
> I use nls. What I did (enclosed) seems to work well with many data points but if I want to fit small
> vectors like :
> 
> pressure <- c(5,15,9,35,45)
> gas <- c(1000,2000,3000,4000,5000)
> 
> it do not work. The help page says that it do no not work on zero residual data.
> 
> Massimo Cressoni

Hi Massimo

I think which this script solve your question
------------------------
pressure <- c(5,9,15,35,45)
gas <- c(1000,2000,3000,4000,5000)
plot(gas,pressure)
model.1 <- nls(pressure ~ SSlogis(gas, ASym, xmid, scal)))
coef.sig<-coef(summary(model.1))[,1]
est.p<-coef.sig[1]/(1+exp((coef.sig[2]-gas)/coef.sig[3]))
points(gas,est.p,col=2)
------------------------

If you need more help just need a mail


-- 
Bernardo Rangel Tura,M.D.,Ph.D
National Institute of Cardiology
Rio de Janeiro - Brazil



More information about the R-help mailing list