Hi Dennis,
Thank you for your suggestion.
Firstly, the below minimum step size is only a warning because I told it to
be (warnOnly=T), otherwise it's thrown as an error. I'm not sure if this
is
completely arbitrary.
About segmented regression, I have tried to use it, but it doesn't seem to
work right with weights, but I may have done something wrong, have you tried
it with weights before?
Karen
On Mon, Apr 19, 2010 at 3:59 PM, Dennis Murphy <djmuser@gmail.com> wrote:
> Hi:
>
> On Mon, Apr 19, 2010 at 8:38 AM, Karen Chang Liu <karencl@uw.edu>
wrote:
>
>> Hi,
>>
>> I have a small dataset that I'm fitting a segmented regression
using nls
>> on.
>> I get a step below minimum factor error, which I presume is because
>> residual
>> sum of square is still "not small enough" when steps in the
parameter
>> space
>> is already below specified/default value. However, when I look at the
>> trace,
>> the convergence seems to have been reached. I initially thought I might
>> have
>> reached the parameter space boundary, but these converging parameter
>> values
>> are by no means near boundary, they are quite in the middle. Could
someone
>> help me understand or throw out some possibilities?
>>
>
> It's not an error; it's a warning. In this case, it's simply
telling you
> that the
> step size it took was smaller than the minimum specified by your function
> call.
> If an error had been thrown, the function would have stopped and the object
>
> nlmod would not have been kept in your workspace. If the results 'look
> right',
> the warning is probably harmless; it's there to get your attention and
warn
> you
> to look carefully at the results. (Good programming style, I'd say...)
>
> BTW, are you aware that there is a package named segmented on CRAN that
> is reputedly designed for this type of problem? I mention this because the
> nls
> fit is not particularly good (the changepoint is too early and the slope is
> too sharp...)
> and perhaps this package can do a better job (hopefully). FYI...
>
> HTH,
> Dennis
>
>>
>> ##Here's a sample dataset and code.
>> y2<-c(2.404529, 1.625661, 1.013981, 3.810921, 10.023745, 10.990817,
>> 10.740636, 11.246827,17.022761, 21.430386)
>> x2<-c(25.0, 29.3, 33.8, 38.3, 42.8, 47.2, 51.6, 55.8, 60.4, 64.9)
>> dat <- data.frame(x2,y2)
>> nlmod <- nls(y2 ~ ifelse(x2 < xint+(yint/slp), yint, yint +
>> (x2-(xint+(yint/slp)))*slp),
>> data=dat,
control=list(minFactor=1e-5,maxiter=500,warnOnly=T),
>> start=list(xint=40.49782, yint=1.013981, slp=0.8547828),
>> na.action=na.omit, trace=T)
>>
>> ##plotting the function
>> plot(dat$x2,dat$y2)
>> segments(x0=0, x1=coef(nlmod)[1]+coef(nlmod)[2]*coef(nlmod)[3],
>> y0=coef(nlmod)[2], y1=coef(nlmod)[2])
>> segments(x0=coef(nlmod)[1]+coef(nlmod)[2]*coef(nlmod)[3],x1=80,
>> y0=coef(nlmod)[2], y1=80*coef(nlmod)[3]+coef(nlmod)[2])
>>
>> Karen
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
>
--
Karen Liu
Graduate Student
Department of Biostatistics, University of Washington
Seattle, WA 98105
karencl@uw.edu
[[alternative HTML version deleted]]