set.seed(1)
######### pvar ########
x = rbridge(1, 1000)
### simple run:
pv = pvar(x, 2)
print(pv)
summary(pv)
plot(pv)
### partition points are those that maximises Sum_p function
Sum_p(x[pv$Partition], 2)
### lets take only the partition points:
pv2 = pvar(x[pv$Partition], TimeLabel=pv$TimeLabel[pv$Partition], 2)
op <- par(mfrow = c(2, 1))
plot(pv, main="pvar with original data")
plot(pv2, main="the same pvar without meaningless points")
par(op)
######### PvarBreakTest ########
x = c(rnorm(250,0),rnorm(250,0.3), rnorm(250,0), rnorm(250,0.3))
# run test
PVBT = PvarBreakTest(x); PVBT
PVBTSummary = summary(PVBT); PVBTSummary
# the plot of the test
plot(PVBT)
# the suggestion of break points. True points are 250, 500 and 750
BreakPoints(PVBT)
##################################
# the statistic maigth by find with pvar
Y = BridgeT(x)
pv = pvar(Y, p = 4)
pv
# critical value
PvarQuantile(n=length(x), prob = c(0.95))
# apricimal p-value
PvarPvalue(n=length(x), stat=pv$value)
PVBT
Run the code above in your browser using DataLab