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 L×nL \times n data matrix, where LL is the number of time series and nn, the number of time points.

a0

Vector of dimension LL with shape 1 Beta parameters (see Details).

b0

Vector of dimension LL with shape 2 Beta parameters (see Details).

mltypes

Type of marginal likelihood. Currently only available is:

  • mltypes = 1. Observations within a block are conditionally independent Normal(μ,σ2)Normal(\mu, \sigma^2) variates with mean μ\mu and variance σ2\sigma^2. The desired marginal likelihood is obtained after integrating (μ,σ2)(\mu, \sigma^2) with respect to a NormalInverseGamma(μ0,κ0,α0,β0)Normal-Inverse-Gamma(\mu_0, \kappa_0, \alpha_0, \beta_0) prior.

thetas

An L×qL \times q matrix containing hyperparameters associated with the marginal likelihood. The number of rows (L)(L) corresponds to the number of series. The number of columns (q)(q) depend on the marginal likelihood:

  • If mltypes = 1, then q=4q = 4 and thetas equals the hyperparameter (μ0,κ0,α0,β0)(\mu_{0}, \kappa_{0}, \alpha_{0}, \beta_{0}) of the Normal-Inverse-Gamma prior.

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 verbose = FALSE.

Details

As described in Barry and Hartigan (1992) and Loschi and Cruz (2002), for each time series yi=(yi,1,,yi,n)\boldsymbol{y}_{i} = (y_{i,1}, \ldots , y_{i,n})':

yiρij=1biF(yi,jθi)\boldsymbol{y}_{i} \mid \rho_{i} \sim \prod_{j = 1}^{b_{i}}\mathcal{F}(\boldsymbol{y}_{i,j} \mid \boldsymbol{\theta}_{i})

ρipipibi1(1pi)nbi\rho_{i} \mid p_{i} \sim p_{i}^{b_{i} - 1}(1 - p_{i})^{n - b_{i}}

piBeta(ai,0,bi,0).p_{i} \sim Beta(a_{i,0}, b_{i,0}).

Here, ρi={Si,1,,Si,bi}\rho_{i} = \{S_{i,1}, \ldots , S_{i,b_{i}}\} is a partition of the set {1,,n}\{1, \ldots , n\} into bib_{i} contiguous blocks, and yi,j=(yi,t:tSi,j)\boldsymbol{y}_{i,j} = (y_{i,t} : t \in S_{i,j})'. Also, F(θi)\mathcal{F}( \cdot \mid \boldsymbol{\theta}_{i}) is a marginal likelihood function which depends on the nature of yi\boldsymbol{y}_{i}, indexed by a hyperparameter θi\boldsymbol{\theta}_{i}. Notice that pip_{i} is the probability of observing a change point in series ii, at each time t{2,,n}t \in \{2, \ldots , n\}.

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 MM be the number of MCMC iterates collected. The output list contains the following:

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)




[Package ppmSuite version 0.3.4 Index]