On Mon, Aug 23, 2010 at 11:01 AM, Veronesi, Fabio <f.veron...@cranfield.ac.uk> wrote: > Hi, > I have a problem fitting the following Weibull Model to a set of data. > The model is this one: a-b*exp(-c*x^d) > If I fitted the model with CurveExpert I can find a very nice set of > coefficients which create a curve very close to my data, but when I use the > nls.lm function in R I can't obtain the same result. > My data are these: > X Y > 15 13 > 50 13 > 75 9 > 90 4 > > With the commercial software I obtain the following coefficients: > Weibull Model: y=a-b*exp(-c*x^d) > Coefficient Data: > a = 1.31636909714E+001 > b = 7.61325570579E+002 > c = 2.82150000991E+002 > d = -9.23838785044E-001 > > For fitting the Levenberg-Marquardt in R I'm using the following lines: > pS<-list(a=1,b=1,c=1,d=1) > model<-function(pS,xx){pS$a-pS$b*exp(-pS$c*xx^-pS$d)} > resid<-function(observed,pS,xx){observed-model(pS,xx)} > lin<-nls.lm(pS,resid,observed=Y,xx=X) > > Why I can't obtain the same results? > Many thanks in advance, > Fabio
Note that you have 4 parameters and only 4 data points! You are not likely to get anything useful with that. At any rate try this noting that with alg = "plinear" you don't have to provide starting values for the linear parameters: > DF <- data.frame(X = c(15, 50, 75, 90), Y = c(13, 13, 9, 4)) > > nls(Y ~ cbind(1, exp(-c*X^d)), DF, start = list(c = 1, d = 1), alg = > "plinear") Nonlinear regression model model: Y ~ cbind(1, exp(-c * X^d)) data: DF c d .lin1 .lin2 1.000e+00 1.000e+00 8.667e+00 1.417e+07 residual sum-of-squares: 40.67 Number of iterations to convergence: 0 Achieved convergence tolerance: 0 ______________________________________________ R-help@r-project.org mailing list 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.