[R] Parameter estimation in nls
p.dalgaard at biostat.ku.dk
Tue Nov 25 10:59:47 CET 2003
Dr Andrew Wilson <eia018 at comp.lancs.ac.uk> writes:
> 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,
> 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?
You don't seem to have an x anywhere. Are you making the (apparently
not uncommon) mistake of trying to use a program for fitting nonlinear
relations by least squares to fit a probability density? If so, look
for fitdistr() instead.
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