[R] Constrain slope in segmented package

Peter Ehlers ehlers at ucalgary.ca
Tue Mar 12 19:14:04 CET 2013


On 2013-03-12 03:55, Pierre Hainaut wrote:
> Hello,
>
> I'm currently using the segmented package of M.R. Muggeo to fit a
> two-slope segmented regression. I would like to constrain a
> null-left-slope, but I cannot make it. I followed the explanations of
> the package (http://dssm.unipa.it/vmuggeo/segmentedRnews.pdf) to write
> the following code :
>
>     fit.glm <- glm(y~x)
>     fit.seg <- segmented(fit.glm, seg.Z=~x,psi=0.3)
>     fit.glm <-update(fit.glm,.~.-x)
>     fit.seg1 <-update(fit.seg)
>
> If I got well, the two last lines are supposed to constrain the slope,
> but it did not change anything. Could you help me with this ?
> By the way, I don't understand the ".-.-x" code in the update function.
>
> Thanks a lot by anticipation !
>
> Pierre
>

I can't help you with the segmented constraints, but the 'dot'-notation
is very well and concisely documented: use ?update which will take you
to a link for ?update.formula where you can read all about it.

Peter Ehlers



More information about the R-help mailing list