[R] predicting from segmented regression

claudia tebaldi claudia.tebaldi at gmail.com
Fri Sep 4 03:06:50 CEST 2009


Hello

I'm having trouble figuring out how to use the output of "segmented()"
with a new set of predictor values.
Using the example of the help file:

set.seed(12)
     xx<-1:100
     zz<-runif(100)
     yy<-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2)
     dati<-data.frame(x=xx,y=yy,z=zz)
     out.lm<-lm(y~x,data=dati)
     o<-## S3 method for class 'lm':
     segmented(out.lm,seg.Z=~x,psi=list(x=c(30,60)),
         control=seg.control(display=FALSE))

Now I would like to create a new set of values between 0 and 100 and
predict the value of the piecewise linear function at those. Would you
please help me figuring out how I would do that?

Thank you so much in advance

claudia




-- 
Claudia Tebaldi
Research Scientist, Climate Central
http://www.climatecentral.org
& Adjunct Professor
Department of Statistics - UBC Vancouver
office 604 822 3595 (Canadian area code)
cell 303 775 5365 (US area code)




More information about the R-help mailing list