[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.

reduceddata <- read.table("reduceddata.txt")   detach()
  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)[1]+(i)/(m+1)*(range(V3)[2]-range(V3)[1])
psi[2,i]=range(V4)[1]+(i)/(m+1)*(range(V4)[2]-range(V4)[1])
psi[3,i]=range(V5)[1]+(i)/(m+1)*(range(V5)[2]-range(V5)[1])
psi[4,i]=range(V6)[1]+(i)/(m+1)*(range(V6)[2]-range(V6)[1])
psi[5,i]=range(V7)[1]+(i)/(m+1)*(range(V7)[2]-range(V7)[1])
psi[6,i]=range(V8)[1]+(i)/(m+1)*(range(V8)[2]-range(V8)[1])
psi[7,i]=range(V9)[1]+(i)/(m+1)*(range(V9)[2]-range(V9)[1])
psi[8,i]=range(V10)[1]+(i)/(m+1)*(range(V10)[2]-range(V10)[1])
psi[9,i]=range(V11)[1]+(i)/(m+1)*(range(V11)[2]-range(V11)[1])
psi[10,i]=range(V12)[1]+(i)/(m+1)*(range(V12)[2]-range(V12)[1])
psi[11,i]=range(V13)[1]+(i)/(m+1)*(range(V13)[2]-range(V13)[1])
psi[12,i]=range(V14)[1]+(i)/(m+1)*(range(V14)[2]-range(V14)[1])
psi[13,i]=range(V15)[1]+(i)/(m+1)*(range(V15)[2]-range(V15)[1])
psi[14,i]=range(V16)[1]+(i)/(m+1)*(range(V16)[2]-range(V16)[1])
psi[15,i]=range(V17)[1]+(i)/(m+1)*(range(V17)[2]-range(V17)[1])
}
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[4],x7=psi[7],x9=psi[9],
	x5=psi[5], x6=psi[6],x8=psi[8],
	x10=psi[10],x11=psi[11],x12=psi[12,],
	x13=psi[13],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.