[R] Robust nonlinear regression - sin(x)/x?
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Feb 2 20:57:16 CET 2004
cstrato <cstrato at aon.at> writes:
> Dear all
>
> Since I did not receive any answer to my general question (?),
> let me ask a concrete question:
>
> How can I fit the simple function y = a*sin(x)/b*x?
>
> This is the code that I tried, but nls gives an error:
>
> x <- seq(1,10,0.1)
> y <- sin(x)/x
> plot(x,y)
> z <- jitter(y,amount=0.1)
> plot(x,z)
> df <- as.data.frame(cbind(x,z))
> nf <- nls(z ~ a*sin(x)/b*x, data=df,
> start=list(a=0.8,b=0.9), trace = TRUE)
>
> I have followed the Puromycin sample which works fine:
> Pur.wt <- nls(rate ~ (Vm * conc)/(K + conc), data = Treated,
> start = list(Vm = 200, K = 0.1), trace = TRUE)
>
> Do I make some mistake or is it not possible to fit sin(x)/x?
The expression only depends on a/b so you cannot estimate both.
Besides, you need to check up on operator precedence and
associativity: What you wrote is equivalent to a*sin(x)*x/b.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list