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

______________________________________________
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.

Reply via email to