# [R] help for segmented package

From: <pw2233_at_columbia.edu>
Date: Sat, 08 Dec 2007 05:18:59 -0500

Hi,

I am trying to find m breakpoints of a linear regression model. I used the segmented package. It works fine for small number of predicators and breakpoints.(3 r.v. 3 points). However, my model has 14 variables it even would not work even for just one breakpoints!. The error message is always estimated breakpoints are out of range.

Since my problem is time related problem. So I hink the breakpoints should be all at the same time for all variables. Can I achieve this requiement with this package? How? Thanks
Best Regards
Peter

Here is the code I used and the data is also attached.

attach(reduceddata)
library(segmented)
dat=data.frame(y=V2,x1=V3,x2=V4,x3=V5,

```     x4=V6,x5=V7,x6=V8,x7=V9,x8=V10,x9=V11,
x10=V12,x11=V13,x12=V14,x13=V15,x14=V16,x15=V16)
```
m=2
psi <- array(0, c(15,m))
for (i in 1:m)
{
```psi[1,i]=range(V3)+(i)/(m+1)*(range(V3)-range(V3))
psi[2,i]=range(V4)+(i)/(m+1)*(range(V4)-range(V4))
psi[3,i]=range(V5)+(i)/(m+1)*(range(V5)-range(V5))
psi[4,i]=range(V6)+(i)/(m+1)*(range(V6)-range(V6))
psi[5,i]=range(V7)+(i)/(m+1)*(range(V7)-range(V7))
psi[6,i]=range(V8)+(i)/(m+1)*(range(V8)-range(V8))
psi[7,i]=range(V9)+(i)/(m+1)*(range(V9)-range(V9))
psi[8,i]=range(V10)+(i)/(m+1)*(range(V10)-range(V10))
psi[9,i]=range(V11)+(i)/(m+1)*(range(V11)-range(V11))
psi[10,i]=range(V12)+(i)/(m+1)*(range(V12)-range(V12))
psi[11,i]=range(V13)+(i)/(m+1)*(range(V13)-range(V13))
psi[12,i]=range(V14)+(i)/(m+1)*(range(V14)-range(V14))
psi[13,i]=range(V15)+(i)/(m+1)*(range(V15)-range(V15))
psi[14,i]=range(V16)+(i)/(m+1)*(range(V16)-range(V16))
psi[15,i]=range(V17)+(i)/(m+1)*(range(V17)-range(V17))
```
}
out.lm=glm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14

,data=dat)
o=segmented(out.lm,seg.Z=~x1+x2+x3+x4+x5+x6+ x7+x9+x8+x9+

```	x10+x11+x12+x13+x14,
psi=list(x1=0,x2=psi[2,],x3=psi[3,],
x4=psi,x7=psi,x9=psi,
x5=psi, x6=psi,x8=psi,
x10=psi,x11=psi,x12=psi[12,],
x13=psi,x14=psi[14,]),control=seg.control(display=TRUE))

______________________________________________
```
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.
Received on Sat 08 Dec 2007 - 17:14:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 08 Dec 2007 - 17:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.