MCMCresidualBreakAnalysis  R Documentation 
This function performs a break analysis for univariate time series data
using a linear Gaussian changepoint model. The code is written mainly for an
internal use in testpanelSubjectBreak
.
MCMCresidualBreakAnalysis(
resid,
m = 1,
b0 = 0,
B0 = 0.001,
c0 = 0.1,
d0 = 0.1,
a = NULL,
b = NULL,
mcmc = 1000,
burnin = 1000,
thin = 1,
verbose = 0,
seed = NA,
beta.start = NA,
P.start = NA,
random.perturb = FALSE,
WAIC = FALSE,
marginal.likelihood = c("none", "Chib95"),
...
)
resid 
Univariate time series 
m 
The number of breaks. 
b0 
The prior mean of 
B0 
The prior precision of 
c0 

d0 

a 

b 

mcmc 
The number of MCMC iterations after burnin. 
burnin 
The number of burnin iterations for the sampler. 
thin 
The thinning interval used in the simulation. The number of MCMC iterations must be divisible by this value. 
verbose 
A switch which determines whether or not the progress of the
sampler is printed to the screen. If 
seed 
The seed for the random number generator. If NA, the Mersenne
Twister generator is used with default seed 12345; if an integer is passed
it is used to seed the Mersenne twister. The user can also pass a list of
length two to use the L'Ecuyer random number generator, which is suitable
for parallel computation. The first element of the list is the L'Ecuyer
seed, which is a vector of length six or NA (if NA a default seed of

beta.start 
The starting values for the 
P.start 
The starting values for the transition matrix. A user should
provide a square matrix with dimension equal to the number of states. By
default, draws from the 
random.perturb 
If TRUE, randomly sample hidden states whenever regularly sampled hidden states have at least one single observation state. It's one method to avoid overfitting in a nonergodic hidden Markov models. See Park and Sohn (2017). 
WAIC 
Compute the Widely Applicable Information Criterion (Watanabe 2010). 
marginal.likelihood 
How should the marginal likelihood be calculated?
Options are: 
... 
further arguments to be passed 
MCMCresidualBreakAnalysis
simulates from the posterior distribution
using standard Gibbs sampling (a multivariate Normal draw for the betas, and
an inverse Gamma draw for the conditional error variance). The simulation
proper is done in compiled C++ code to maximize efficiency. Please consult
the coda documentation for a comprehensive list of functions that can be
used to analyze the posterior sample.
The model takes the following form:
y_{i} \sim \mathcal{N}(\beta_{m}, \sigma^2_{m}) \;\; m = 1, \ldots, M
We assume standard, semiconjugate priors:
\beta \sim \mathcal{N}(b_0,B_0^{1})
And:
\sigma^{2} \sim \mathcal{G}amma(c_0/2, d_0/2)
Where \beta
and \sigma^{2}
are
assumed a priori independent.
And:
p_{mm} \sim \mathcal{B}eta(a, b),\;\; m = 1, \ldots, M
Where M
is the number of states.
An mcmc object that contains the posterior sample. This object can be summarized by functions provided by the coda package.
Jong Hee Park and Yunkyu Sohn. 2017. "Detecting Structural Changes in Network Data: An Application to Changes in Military Alliance Networks, 18162012". Working Paper.
Jong Hee Park, 2012. “Unified Method for Dynamic and CrossSectional Heterogeneity: Introducing Hidden Markov Panel Models.” American Journal of Political Science.56: 10401054. <doi: 10.1111/j.15405907.2012.00590.x>
Sumio Watanabe. 2010. "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory" Journal of Machine Learning Research. 11: 35713594.
Siddhartha Chib. 1995. "Marginal Likelihood from the Gibbs Output." Journal of the American Statistical Association. 90: 13131321. <doi: 10.1016/S03044076(97)001152>
Siddhartha Chib. 1998. "Estimation and comparison of multiple changepoint models." Journal of Econometrics. 86: 221241. <doi: 10.1080/01621459.1995.10476635>
plot.mcmc
, summary.mcmc
,
lm
## Not run:
line < list(X = c(2,1,0,1,2), Y = c(1,3,3,3,5))
ols < lm(Y~X)
residual < rstandard(ols)
posterior < MCMCresidualBreakAnalysis(residual, m = 1, data=line, mcmc=1000, verbose=200)
plotState(posterior)
summary(posterior)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.