Use nlsr::nlxb() to get analytic derivatives. Though your problem is pretty
rubbishy --
look at the singular values. (You'll need to learn some details of nlxb()
results to
interpret.)
Note to change the x to t in the formula.
JN
> f1 <- y ~ a+b*sin(2*pi*t)+c*cos(2*pi*t)
> res1 <- nls(f1, data=data.frame(t,y), start=list(a=1,b=0, c=1))
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
> library(nlsr)
> res1n <- nlxb(f1, data=data.frame(t,y), start=list(a=1,b=0, c=1))
> res1n
nlsr object: x
residual sumsquares = 28.644 on 12 observations
after 3 Jacobian and 4 function evaluations
name coeff SE tstat pval gradient
JSingval
a 11.2235 NA NA NA -2.473e-12
4.899
b -1.55541e-09 NA NA NA 1.595e-14
8.399e-15
c 11.2235 NA NA NA -2.473e-12
5.053e-16
>
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.