icp_ppm {ppmSuite} | R Documentation |
Function that fits the multivariate independent product partition change point model
Description
icp_ppm
is a function that fits a Bayesian product partition change
point model. Each series is treated independently.
Usage
icp_ppm(ydata,
a0, b0,
mltypes,
thetas,
nburn, nskip, nsave,
verbose = FALSE)
Arguments
ydata |
An |
a0 |
Vector of dimension |
b0 |
Vector of dimension |
mltypes |
Type of marginal likelihood. Currently only available is:
|
thetas |
An
|
nburn |
The number of initial MCMC iterates to be discarded as burn-in. |
nskip |
The amount to thinning that should be applied to the MCMC chain. |
nsave |
Then number of MCMC iterates to be stored. |
verbose |
Logical indicating whether to print to screen the MCMC
progression. The default value is |
Details
As described in Barry and Hartigan (1992) and Loschi and Cruz (2002), for each
time series
:
Here, is a partition of
the set
into
contiguous blocks, and
. Also,
is a marginal
likelihood function which depends on the nature of
,
indexed by a hyperparameter
. Notice that
is the probability of observing a change point in series
,
at each time
.
Value
The function returns a list containing arrays filled with MCMC iterates
corresponding to model parameters. In order to provide more detail, in what
follows let be the number of MCMC iterates collected. The output list
contains the following:
C. An
matrix containing MCMC iterates associated with each series indicators of a change point. The
th row in
C
is divided intoblocks; the first
change point indicators for time series 1, the next
change point indicators for time series 2, and so on.
P. An
matrix containing MCMC iterates associated with each series probability of a change point. The
th row in
P
is divided intoblocks; the first
change point probabilities for time series 1, the next
change point probabilities for time series 2, and so on.
Examples
# Generate data that has two series, each with 100 observations
y1 <- replicate(25, rnorm(4, c(-1, 0, 1, 2), c(0.1, 0.25, 0.5, 0.75)))
y2 <- replicate(25, rnorm(4, c(2, 1, 0, -2), c(0.1, 0.25, 0.5, 0.75)))
y <- rbind(c(t(y1)), c(t(y2)))
n <- ncol(y)
# Marginal likelihood parameters
thetas <- matrix(1, nrow = 2, ncol = 4)
thetas[1,] <- c(0, 1, 2, 1)
thetas[2,] <- c(0, 1, 2, 1)
# Fit the Bayesian ppm change point model
fit <- icp_ppm(ydata = y,
a0 = c(1, 1),
b0 = c(1, 1),
mltypes = c(1, 1),
thetas = thetas,
nburn = 1000, nskip = 1, nsave = 1000)
cpprobsL <- matrix(apply(fit$C,2,mean), nrow=n-1, byrow=FALSE)