testCP: Test RACVM change point

View source: R/testCP.R

testCPR Documentation

Test RACVM change point

Description

Identifies appropriate models on either side of a change point

Usage

testCP(
  Z,
  T,
  cp,
  start,
  end,
  modelset = "all",
  spline = FALSE,
  criterion = "BIC",
  ...
)

Arguments

Z

location

T

time of data

cp

change point

start

beginning time of segment to analyze

end

end time of segment to analyze

modelset

set of models to compare (combination of UCVM, ACVM, RCVM, RACVM, or all, which includes all of them)

spline

whether or not to use the spline approximation for the final estimate.

criterion

selection criterion - either BIC or AIC (can be upper- or lowercased)

...

further params to getFit internal function

Examples

require(smoove)
# Simulate a single change point

set.seed(101)
ucvm1 <- simulateUCVM(T=cumsum(rexp(100)), nu=2, tau=1, method="exact")
ucvm2 <- simulateUCVM(T=cumsum(rexp(100)), nu=5, tau=10, v0 = ucvm1$V[100], method="exact")
T <- c(ucvm1$T, ucvm1$T[100] + ucvm2$T)
Z <- c(ucvm1$Z, ucvm1$Z[100] + ucvm2$Z)
plot_track(Z)

# testing the true changepoint
testCP(Z, T, 100, 1, 200)
# both AIC and BIC are very much lower for the changepoint model

# testing a changepoint in the middle of the first 100 points 
testCP(Z, T, 50, 1, 100)


EliGurarie/smoove documentation built on Aug. 2, 2022, 10:26 p.m.