I'm running into problems trying to use the nls function to fit the some data. I'm invoking nls using nls(s~k/(a+r)^b, start=list(k=1, a=13, b=0.59)) but I get errors indicating that the step has been reduced below the minimum step size or an inifinity is generated in numericDeriv. I've tried to use a variety of starting values for a, b, k but get similar errors. Is there anything I can do to get the a fit or is there an alternative to the nls function? -- Suchandra Thapa <s-thapa-11 at alumni.uchicago.edu>
An article in the American Statistician perhaps 5 years ago on the accuracy of statistical software recommended using nlminb first to find the least squares solution and then pass those numbers to nls to get confidence intervals. More recently, optim has replaced nlminb for such purposes, as far as I know. In addition, optim will optionally output the Hessian from which approximate confidence intervals can be obtained. I have not used this recently, but I would expect that "profile" on the nls fit would give better confidence intervals. hth. spencer graves Suchandra Thapa wrote:> I'm running into problems trying to use the nls function to fit the some > data. I'm invoking nls using > > nls(s~k/(a+r)^b, start=list(k=1, a=13, b=0.59)) > > but I get errors indicating that the step has been reduced below the > minimum step size or an inifinity is generated in numericDeriv. I've > tried to use a variety of starting values for a, b, k but get similar > errors. > > Is there anything I can do to get the a fit or is there an alternative > to the nls function? >
Suchandra Thapa <s-thapa-11 at alumni.uchicago.edu> writes:> I'm running into problems trying to use the nls function to fit the some > data. I'm invoking nls using > > nls(s~k/(a+r)^b, start=list(k=1, a=13, b=0.59)) > > but I get errors indicating that the step has been reduced below the > minimum step size or an inifinity is generated in numericDeriv. I've > tried to use a variety of starting values for a, b, k but get similar > errors. > > Is there anything I can do to get the a fit or is there an alternative > to the nls function?Well, first you plot the data and see if the relationship between r and s is sufficiently well defined to estimate three parameters in a nonlinear model. It is common to try to estimate more parameters than can reasonably be determined from the data. Secondly, the parameter k is conditionally linear so you can try fitting the model as nls(s ~ 1/(a+r)^b, start = list(a = 13, b = 0.59), alg = 'plinear', trace = TRUE) I recommend using trace = TRUE on difficult problems so you can see exactly where the iterations are going. If that shows unstable behavior then try to determine how the model is collapsing. In particular, what is happening to the value of a? -- Douglas Bates bates at stat.wisc.edu Statistics Department 608/262-2598 University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/