[R] Fitting a linear model with a break point
Vito Muggeo (UniPa)
vito.muggeo at unipa.it
Tue Sep 8 17:03:35 CEST 2009
dear Dan,
As far as I know, the strucchange package can be helpful for you..
On the other hand, if your regression function is continuous at the
unknown break points to be estimated, you could try the segmented package.
Hope this helps you,
vito
Daniel Brewer ha scritto:
> Hello,
>
> I would like to test some data to see whether it has the shape of a step
> function (i.e. y1 up until x_th and then y2 where x_th is the
> threshold). The threshold x_th is unknown and the x values can only
> take discrete values (0,1,2,3,4).
>
> An example would be:
> data<- data.frame(x=1:20,y=c(rnorm(10),rnorm(10,10)))
>
>
> I was thinking along the lines of fitting some sort of piiecewise linear
> model which has the gradient constrained to zero trying out all possible
> different threshold and taking the one with the least residuals. I am
> not sure how to implement this in R. Anyone got any ideas?
>
> Also is there a way of including the threshold in the actual model, so
> that could be estimated too?
>
> Thanks
>
> Dan
>
--
====================================
Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 6626240
fax: 091 485726/485612
http://dssm.unipa.it/vmuggeo
More information about the R-help
mailing list