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=list(z=.5))
plot(z,y)
points(z,broken.line(o.seg,linkinv=TRUE),col=2,pch=20)
Run the code above in your browser using DataLab