# NOT RUN {
set.seed(1234)
z<-runif(100)
y<-rpois(100,exp(2+1.8*pmax(z-.6,0)))
o<-glm(y~z,family=poisson)
o.seg<-segmented(o,seg.Z=~z,psi=.5)
# }
# NOT RUN {
plot(z,y)
# }
# NOT RUN {
points(z,broken.line(o.seg,link=FALSE)$fit,col=2)
# }
# NOT RUN {
#ok, but use plot.segmented()!
# }
Run the code above in your browser using DataLab