[R] Parameter estimation in nls
apjaworski@mmm.com
apjaworski at mmm.com
Tue Nov 25 17:39:21 CET 2003
Your starting values for the parameters are no even in the general
ballpark. Here is what I got for the final fit:
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 3.806e+07 1.732e+06 21.971 <2e-16 ***
k -3.391e-02 6.903e-02 -0.491 0.628
b 9.000e-01 1.240e-02 72.612 <2e-16 ***
As you can see only b has the same order of magnitude as your starting b
and a is different by 7 orders!
In general, an nls procedure needs starting values that are "close". The
same is true for any general nonlinear optimization algorithm. Only in
special circumstances a nonlinear algorithm will converge from any starting
point - one I know of is the convexity of the objective function.
I do not think there is any nls program that will find starting values
automatically for an arbitrary nonlinear model. It is possible for
specific models, but is very much model dependent. Your model, for
example, can be easily linearized by taking logs of both sides, i.e.
mm <- lm(log(y) ~ x + I(log(x)))
Then doing
aa <- exp(coef(mm)[1])
bb <- exp(coef(mm)[2])
kk <- coef(mm)[3]
mm1 <- nls(y ~ a * x^k * b^x, start=list(a=aa,k=kk,b=bb))
results in convergence with no problems in 7 iterations.
Hope this helps,
Andy
__________________________________
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-----
E-mail: apjaworski at mmm.com
Tel: (651) 733-6092
Fax: (651) 736-3122
|---------+-------------------------------->
| | Dr Andrew Wilson |
| | <eia018 at comp.lancs.ac|
| | .uk> |
| | Sent by: |
| | r-help-bounces at stat.m|
| | ath.ethz.ch |
| | |
| | |
| | 11/25/2003 03:09 |
| | |
|---------+-------------------------------->
>-----------------------------------------------------------------------------------------------------------------------------|
| |
| To: r-help at stat.math.ethz.ch |
| cc: |
| Subject: [R] Parameter estimation in nls |
>-----------------------------------------------------------------------------------------------------------------------------|
I am trying to fit a rank-frequency distribution with 3 unknowns (a, b
and k) to a set of data.
This is my data set:
y <- c(37047647,27083970,23944887,22536157,20133224,
20088720,18774883,18415648,17103717,13580739,12350767,
8682289,7496355,7248810,7022120,6396495,6262477,6005496,
5065887,4594147,2853307,2745322,454572,448397,275136,268771)
and this is the fit I'm trying to do:
nlsfit <- nls(y ~ a * x^k * b^x, start=list(a=5,k=1,b=3))
(It's a Yule distribution.)
However, I keep getting:
"Error in nls(y ~ a * x^k * b^x, start = list(a = 5, k = 1, b = 3)) :
singular gradient"
I guess this has something to do with the parameter start values.
I was wondering, is there a fully automated way of estimating parameters
which doesn't need start values close to the final estimates? I know
other programs do it, so is it possible in R?
Thanks,
Andrew Wilson
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list