[R] breakpoints and nonlinear regression

Vito Muggeo (UniPa) vito.muggeo at unipa.it
Thu Jan 19 15:38:51 CET 2012


dear Julian,


Il 18/01/2012 14.36, crimsonengineer87 ha scritto:
> Thanks for the comments. Yes, I also had segmented and then I went away from
> that. I can't remember. I've tried using it but I get some sort of strange
> error. Here's some code ...

it is difficult for me to help you without knowing "which error" you 
obtain.. If you refer to "maximum number of iterations", it is a warning 
(not error). See the discussion in the paper on Rnews (that Achim 
suggested). The following code is expected to work

pavlu.glm<- lm(Na ~ yield, data=pavludata)
pavlu.seg<- segmented(pavlu.glm, seg.Z=~yield, psi=1000)
with(pavludata, plot(yield, Na))
plot(pavlu.seg, add=TRUE)

See in ?segmented and ?plot.segmented for additional examples and 
contact me off list if you have additional questions

best,
vito



>
>
> pavlu.glm<- glm(Na ~ yield, data=pavludata, family=gaussian)
> pavlu.seg<- segmented(pavlu.glm, seg.Z=~yield, psi=1000,
> control=seg.control(display=FALSE))
>
> plot.series<- function()
> {
> plot(pavlu.seg)
> plot(pavlu.seg, add=TRUE, linkinv=TRUE, lwd=2, col=2:3, lty=c(1,3))
> lines(pavlu.seg, col=2, pch=19, bottom=FALSE, lwd=2)
> }
>
> jpeg("pavlu-cuttingsystem-segmented.jpg", width = 1000, height = 700, units
> = "px")
> plot.series()
>
> ## Turn off device driver (to flush output to JPG)
> dev.off()
>
> 1. I don't think I'm doing my plotting right. I'm just not sure how that
> works with segmented.
> 2. My error is something about an error in do.call(lines) and that the
> maximum number of iterations has been reached. Am I missing something with
> glm or lm?
>
> Thanks again.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/breakpoints-and-nonlinear-regression-tp4303629p4306657.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>

-- 
====================================
Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 23895240
fax: 091 485726
http://dssm.unipa.it/vmuggeo



More information about the R-help mailing list