# Example of a change in mean at 100 in simulated data
set.seed(1)
x=c(rnorm(100,0,1),rnorm(100,10,1))
single.mean.cusum.calc(x,extrainf=FALSE) # finds change at 101
single.mean.cusum.calc(x) # finds change at 101 and gives the test statistic as 2.463326
# Example of no change in mean in simulated data
set.seed(1)
x=rnorm(100,0,1)
single.mean.cusum.calc(x,extrainf=FALSE) # finds change at 97, this is the most probable point of
#change but if a changepoint test is performed then no change will be found.
single.mean.cusum.calc(x)# change at 97, test statistic is 0.0398342
Run the code above in your browser using DataLab