Description Usage Arguments Author(s) Examples
View source: R/BridgeChangeRandomPanel.R
Sparse Change Point Model with Random Effect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
data |
Data.frame object. |
index |
String vector for unit and time index variables.
For example, |
interaction |
If interaction = 1, no interaciton. If interaction = 2, only two-way interaciton. Interaction can be up to K, which is the rank of the model matrix. |
a |
a is the shape1 beta prior for transition probabilities. By default, the expected duration is computed and corresponding a and b values are assigned. The expected duration is the sample period divided by the number of states. |
b |
b is the shape2 beta prior for transition probabilities. By default, the expected duration is computed and corresponding a and b values are assigned. The expected duration is the sample period divided by the number of states. |
n.break |
Number of breaks.
If |
alpha.MH |
If |
mcmc |
The number of MCMC iterations after burn-in. |
verbose |
A switch which determines whether or not the
progress of the sampler is printed to the screen. If
|
thin |
The thinning interval used in the simulation. The number of MCMC iterations must be divisible by this value. |
c0 |
Hyperparam |
d0 |
= 0.1 |
r0 |
= 1 |
R0 |
= 1 |
nu.shape |
=2.0 |
nu.rate |
=2.0 |
alpha |
= 1 |
fomula |
Inherited from |
burnin |
The number of burn-in iterations for the sampler. |
Jong Hee Park, and Soichiro Yamauchi syamauchi@princeton.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ####################################
## Alvarez et al. data
####################################
library("pcse")
set.seed(1999)
data("agl")
model = "within"
index = c('country', 'year')
model = 'within'
effect = 'time'
data = agl
#########################
## HMBB estimation
#########################
## Be aware that 100 runs are too short for analysis.
mcmc = 100; burn = 100; verbose = 100; thin = 1;
formula <- growth ~ lagg1 + opengdp + openex + openimp + leftc + central + inter
agl.cp0 <- BridgeRandomPanel(formula=formula, data = data, index = index,
mcmc=mcmc, , verbose=verbose, Waic = TRUE,
n.break = 0)
agl.cp1 <- BridgeRandomPanel(formula=formula, data = data, index = index,
mcmc=mcmc, , verbose=verbose, Waic = TRUE,
n.break = 1)
agl.cp2 <- BridgeRandomPanel(formula=formula, data = data, index = index,
mcmc=mcmc, , verbose=verbose, Waic = TRUE,
n.break = 2)
## model selection by WAIC
waic <- WaicCompare(list(agl.cp0, agl.cp1, agl.cp2), print = TRUE)
plotWaic(waic)
par(mfrow=c(1, 2))
MCMCpack::plotState(agl.cp1, start=1970, legend.control =c(1970, 0.85), main="One break")
MCMCpack::plotState(agl.cp2, start=1970, legend.control =c(1970, 0.85), main="Two breaks")
####################################
## dotplot over time
## time-varying movements of selected covariates
####################################
## all covariates
dotplotRegime(agl.cp1, hybrid=FALSE, start = 1970, location.bar=12, x.location="default",
text.cex=0.8, main="Time-varying Movements of All Covariates")
## label as a legend
dotplotRegime(agl.cp1, hybrid=FALSE, start = 1970, location.bar=12, x.location="legend",
text.cex=0.8, main="Time-varying Movements of All Covariates")
## leftc only
## select works like grep()
dotplotRegime(agl.cp1, hybrid=FALSE, start = 1970, location.bar=12, x.location="static",
text.cex=0.8, select="left", main=("Time-varying Movements of Left Party"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.