search for: xminusx0

Displaying 1 result from an estimated 1 matches for "xminusx0".

Did you mean: xminus
2006 Aug 02
0
Trying to use segmented in a function
...write functions that use segmented, and it's driving me mad. Here's a simple example: simdata<-function (Ns=200,Xmean=20,Xsd=5,SdYerr=0.5,Yint=0,threshold=20,slopebelow=0.5,slo peabove=1) { Xs<-rnorm(Ns,Xmean,Xsd) Yerr<-rnorm(Ns,0,SdYerr) D<-ifelse(Xs<=threshold,0,1) XminusX0<-Xs-threshold Ys<-Yint+slopebelow*Xs+slopeabove*XminusX0*D+Yerr plot(Xs,Ys) linmod<-lm(Ys~Xs) segment<-segmented(linmod,Z=Xs,psi=threshold) segment } This code should simply simulate some "breakpoint" data, with the change in slope at "threshold" and th...