# Example of a change in regression at 100 in simulated normal data
set.seed(1)
x=1:250
y=c(0.01*x[1:100],1.5-0.02*(x[101:250]-101))
ynoise=y+rnorm(250,0,0.2)
data=cbind(ynoise,1,x) # including an intercept
single.reg.norm.calc(data,extrainf=FALSE) # finds change at 100
single.reg.norm.calc(data) # finds change at 100 and gives null likelihood as 1119.3264 and alternative likelihood as 554.1691
# Example of no change in regression in simulated normal data
set.seed(1)
x=1:250
y=0.01*x
ynoise=y+rnorm(250,0,0.2)
data=cbind(ynoise,x) # no intercept included
single.reg.norm.calc(data,extrainf=FALSE) # finds change at 96, this is the most probable point of change but if a changepoint test is performed then no change will be found.
single.reg.norm.calc(data)# change at 96, null liklihood is 555.6434 and alternative is 552.6056
Run the code above in your browser using DataLab