Title: | Bayesian Package for Network Changepoint Analysis |
---|---|
Description: | Network changepoint analysis for undirected network data. The package implements a hidden Markov network change point model (Park and Sohn (2020)). Functions for break number detection using the approximate marginal likelihood and WAIC are also provided. |
Authors: | Jong Hee Park [aut,cre], Yunkyu Sohn [aut] |
Maintainer: | Jong Hee Park <[email protected]> |
License: | GPL-3 |
Version: | 0.8 |
Built: | 2024-10-29 05:04:55 UTC |
Source: | https://github.com/jongheepark/networkchange |
Detect a break number using different metrics
BreakDiagnostic( Y, R = 2, mcmc = 100, burnin = 100, verbose = 100, thin = 1, UL.Normal = "Orthonormal", v0 = NULL, v1 = NULL, break.upper = 3, a = 1, b = 1 )
BreakDiagnostic( Y, R = 2, mcmc = 100, burnin = 100, verbose = 100, thin = 1, UL.Normal = "Orthonormal", v0 = NULL, v1 = NULL, break.upper = 3, a = 1, b = 1 )
Y |
Reponse tensor |
R |
Dimension of latent space. The default is 2. |
mcmc |
The number of MCMC iterations after burnin. |
burnin |
The number of burn-in iterations for the sampler. |
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. |
UL.Normal |
Transformation of sampled U. Users can choose "NULL", "Normal" or "Orthonormal." "NULL" is no normalization. "Normal" is the standard normalization. "Orthonormal" is the Gram-Schmidt orthgonalization. Default is "NULL." |
v0 |
|
v1 |
|
break.upper |
Upper threshold for break number detection.
The default is |
a |
|
b |
|
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
## Not run: set.seed(19333) ## Generate an array (15 by 15 by 20) with a block merging transition Y <- MakeBlockNetworkChange(n=5, T=20, type ="merge") ## Fit 3 models (no break, one break, and two break) for break number detection detect <- BreakDiagnostic(Y, R=2, break.upper = 2) ## Look at the graph detect[[1]]; print(detect[[2]]) ## End(Not run)
## Not run: set.seed(19333) ## Generate an array (15 by 15 by 20) with a block merging transition Y <- MakeBlockNetworkChange(n=5, T=20, type ="merge") ## Fit 3 models (no break, one break, and two break) for break number detection detect <- BreakDiagnostic(Y, R=2, break.upper = 2) ## Look at the graph detect[[1]]; print(detect[[2]]) ## End(Not run)
Compute the Average Loss of Hidden State Changes from Expected Break Points
BreakPointLoss(model.list, waic = FALSE, display = TRUE)
BreakPointLoss(model.list, waic = FALSE, display = TRUE)
model.list |
MCMC output objects. These have to be of class
|
waic |
If |
display |
If
|
BreakPointLoss
returns five objects. They are: ave.loss
the expected loss for each model
computed by the mean sqaured distance of hidden state changes from the expected break points.
logmarglike
the natural log of the marginal likelihood for each model; State
sampled state vectors;
Tau
expected break points for each model; and Tau.samp
sampled break points from hidden state draws.
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
## Not run: set.seed(1973) ## Generate an array (30 by 30 by 40) with block transitions from 2 blocks to 3 blocks Y <- MakeBlockNetworkChange(n=10, T=40, type ="split") G <- 100 ## Small mcmc scans to save time ## Fit multiple models for break number detection using Bayesian model comparison out0 <- NetworkStatic(Y, R=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out1 <- NetworkChange(Y, R=2, m=1, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out2 <- NetworkChange(Y, R=2, m=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out3 <- NetworkChange(Y, R=2, m=3, mcmc=G, burnin=G, verbose=G, Waic=TRUE) ## The most probable model given break number 0 to 3 and data is out1 according to WAIC out <- BreakPointLoss(out0, out1, out2, out3, waic=TRUE) print(out[["ave.loss"]]) ## End(Not run)
## Not run: set.seed(1973) ## Generate an array (30 by 30 by 40) with block transitions from 2 blocks to 3 blocks Y <- MakeBlockNetworkChange(n=10, T=40, type ="split") G <- 100 ## Small mcmc scans to save time ## Fit multiple models for break number detection using Bayesian model comparison out0 <- NetworkStatic(Y, R=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out1 <- NetworkChange(Y, R=2, m=1, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out2 <- NetworkChange(Y, R=2, m=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out3 <- NetworkChange(Y, R=2, m=3, mcmc=G, burnin=G, verbose=G, Waic=TRUE) ## The most probable model given break number 0 to 3 and data is out1 according to WAIC out <- BreakPointLoss(out0, out1, out2, out3, waic=TRUE) print(out[["ave.loss"]]) ## End(Not run)
Plot latent node cluster
drawPostAnalysis( mcmcout, Y, point.cex = 3, text.cex = 3, segment.size = 0.1, n.cluster = NULL, start = 1, frequency = 1 )
drawPostAnalysis( mcmcout, Y, point.cex = 3, text.cex = 3, segment.size = 0.1, n.cluster = NULL, start = 1, frequency = 1 )
mcmcout |
NetworkChange output |
Y |
Input raw data |
point.cex |
node point size. Default is 3. |
text.cex |
node label size. Default is 3. |
segment.size |
segment size. Default is 0.1. |
n.cluster |
number of cluster. Default is 3. |
start |
start of ts object |
frequency |
frequency of ts object |
A plot object
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
## Not run: set.seed(1973) ## generate an array with two constant blocks data(MajorAlly) Y <- MajorAlly fit <- NetworkChange(newY, R=2, m=2, mcmc=G, initial.s = initial.s, burnin=G, verbose=0, v0=v0, v1=v1) drawPostAnalysis(fit, Y, n.cluster=c(4, 4, 3)) ## End(Not run)
## Not run: set.seed(1973) ## generate an array with two constant blocks data(MajorAlly) Y <- MajorAlly fit <- NetworkChange(newY, R=2, m=2, mcmc=G, initial.s = initial.s, burnin=G, verbose=0, v0=v0, v1=v1) drawPostAnalysis(fit, Y, n.cluster=c(4, 4, 3)) ## End(Not run)
Plot latent node cluster
drawRegimeRaw(mcmcout, Y)
drawRegimeRaw(mcmcout, Y)
mcmcout |
NetworkChange output |
Y |
Input raw data |
A plot object
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
## Not run: set.seed(1973) ## generate an array with two constant blocks data(MajorAlly) Y <- MajorAlly fit <- NetworkChange(newY, R=2, m=2, mcmc=G, initial.s = initial.s, burnin=G, verbose=0, v0=v0, v1=v1) drawRegimeRaw(fit, newY) ## End(Not run)
## Not run: set.seed(1973) ## generate an array with two constant blocks data(MajorAlly) Y <- MajorAlly fit <- NetworkChange(newY, R=2, m=2, mcmc=G, initial.s = initial.s, burnin=G, verbose=0, v0=v0, v1=v1) drawRegimeRaw(fit, newY) ## End(Not run)
K-mean clustering of latent node positions
kmeansU(out, R = 2, n.cluster = 3, layer = 1, main = "")
kmeansU(out, R = 2, n.cluster = 3, layer = 1, main = "")
out |
Output of networkchange objects. |
R |
Number of latent space dimensions |
n.cluster |
Number of latent cluster |
layer |
Layer id for the cluster analysis |
main |
Title |
A plot object
## Not run: set.seed(1973) ## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=10, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") ## latent node positions kmeansU(out0) ## End(Not run)
## Not run: set.seed(1973) ## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=10, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") ## latent node positions kmeansU(out0) ## End(Not run)
This dataframe contains major power alliance network data from 1816 to 2012 (2 year interval).
The dataframe has contains data for major power alliance network data from 1816 to 2012. Major power definition is the COW data set, which incldues USA, UK, France, Germany (West Germany during 1954-1989), Austria, Italy, Russia, China, and Japan. In this data set, a defense pact (Type I), which is the highest level of military commitment, is coded as 1, and 0 otherwise.
Correlates of War Project. 2017. "State System Membership List, v2016." Online, https://correlatesofwar.org/. Gibler, Douglas M. 2009. International military alliances, 1648-2008. CQ Press.
MakeBlockNetworkChange generates a block-structured temporal data with breaks.
MakeBlockNetworkChange( n = 10, break.point = 0.5, base.prob = 0.05, block.prob = 0.5, shape = 1, T = 40, break.point1 = 0.25, break.point2 = 0.75, type = "merge" )
MakeBlockNetworkChange( n = 10, break.point = 0.5, base.prob = 0.05, block.prob = 0.5, shape = 1, T = 40, break.point1 = 0.25, break.point2 = 0.75, type = "merge" )
n |
The number of nodes within a block. The total number of nodes is n*block.number. |
break.point |
The point of break. 0 indicates the beginning, 0.5 indicates the middle, and 1 indicates the end. |
base.prob |
The probability of link among non-block members. |
block.prob |
The probability of link among within-block members. |
shape |
The speed of breaks. The larger shape is, the faster the transition is. shape > 0 and shape < 8. |
T |
The length of time. |
break.point1 |
The point of the first break in "merge-split" or "split-merge". Any number between 0 and 0.5 can be chosen. For example, 0 indicates #' the beginning, 0.25 indicates the 1/4th point, and 0.5 indicates the half point. |
break.point2 |
The point of the second breakin "merge-split" or "split-merge". Any number between 0.5 and 1 can be chosen. For example, 0.5 indicates the beginning, 0.75 indicates the 3/4th point, and 1 indicates the end point. |
type |
The type of network changes. Options are "constant", "merge", "split", "merge-split", "split-merge." If "constant" is chosen, the number of breaks is zero. If "merge" or "split" is chosen, the number of breaks is one. If either "merge-split" or "split-merge" is chosen, the number of breaks is two. |
output An output of MakeBlockNetworkChange
contains a symmetric block-structured temporal network data set with breaks.
Compare Log Marginal Likelihood
MarginalCompare(outlist)
MarginalCompare(outlist)
outlist |
List of NetworkChange objects |
A matrix of log marginal likelihoods.
Siddhartha Chib. 1995. “Marginal Likelihood from the Gibbs Output.” Journal of the American Statistical Association. 90: 1313-1321.
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
Sumio Watanabe. 2010. "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory." Journal of Machine Learning Research. 11: 3571-3594.
Print multiple ggplots in one file. Slightly modified for packaging from the original version in the web.
multiplot(..., plotlist = NULL, cols = 1, layout = NULL)
multiplot(..., plotlist = NULL, cols = 1, layout = NULL)
... |
A list of ggplot objects separated by commas. |
plotlist |
A list of ggplot objects |
cols |
The number of columns. |
layout |
A matrix specifying the layout. If present, 'cols' is ignored. |
A plot object
http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
NetworkChange implements Bayesian multiple changepoint models to network time series data using a degree-corrected multilinear tensor decomposition method
NetworkChange( Y, R = 2, m = 1, initial.s = NULL, mcmc = 100, burnin = 100, verbose = 0, thin = 1, reduce.mcmc = NULL, degree.normal = "eigen", UL.Normal = "Orthonormal", DIC = FALSE, Waic = FALSE, marginal = FALSE, plotUU = FALSE, plotZ = FALSE, constant = FALSE, b0 = 0, B0 = 1, c0 = NULL, d0 = NULL, u0 = NULL, u1 = NULL, v0 = NULL, v1 = NULL, a = NULL, b = NULL )
NetworkChange( Y, R = 2, m = 1, initial.s = NULL, mcmc = 100, burnin = 100, verbose = 0, thin = 1, reduce.mcmc = NULL, degree.normal = "eigen", UL.Normal = "Orthonormal", DIC = FALSE, Waic = FALSE, marginal = FALSE, plotUU = FALSE, plotZ = FALSE, constant = FALSE, b0 = 0, B0 = 1, c0 = NULL, d0 = NULL, u0 = NULL, u1 = NULL, v0 = NULL, v1 = NULL, a = NULL, b = NULL )
Y |
Reponse tensor |
R |
Dimension of latent space. The default is 2. |
m |
Number of change point.
If |
initial.s |
The starting value of latent state vector. The default is sampling from equal probabilities for all states. |
mcmc |
The number of MCMC iterations after burnin. |
burnin |
The number of burn-in iterations for the sampler. |
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. |
reduce.mcmc |
The number of reduced MCMC iterations for marginal likelihood computations.
If |
degree.normal |
A null model for degree correction. Users can choose "NULL", "eigen" or "Lsym." "NULL" is no degree correction. "eigen" is a principal eigen-matrix consisting of the first eigenvalue and the corresponding eigenvector. " Lsym" is a modularity matrix. Default is "eigen." |
UL.Normal |
Transformation of sampled U. Users can choose "NULL", "Normal" or "Orthonormal." "NULL" is no normalization. "Normal" is the standard normalization. "Orthonormal" is the Gram-Schmidt orthgonalization. Default is "NULL." |
DIC |
If |
Waic |
If |
marginal |
If |
plotUU |
If |
plotZ |
If |
constant |
If |
b0 |
The prior mean of |
B0 |
The prior variance of |
c0 |
= 0.1 |
d0 |
= 0.1 |
u0 |
|
u1 |
|
v0 |
|
v1 |
|
a |
|
b |
|
An mcmc object that contains the posterior sample. This object can
be summarized by functions provided by the coda package. The object
contains an attribute Waic.out
that contains results of WAIC and the log-marginal
likelihood of the model (logmarglike
). The object
also contains an attribute prob.state
storage matrix that contains the
probability of for each period
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
Peter D. Hoff 2011. "Hierarchical Multilinear Models for Multiway Data." Computational Statistics \& Data Analysis. 55: 530-543.
Siddhartha Chib. 1998. "Estimation and comparison of multiple change-point models." Journal of Econometrics. 86: 221-241.
## Not run: set.seed(1973) \## Generate an array (30 by 30 by 40) with block transitions from 2 blocks to 3 blocks Y <- MakeBlockNetworkChange(n=10, T=40, type ="split") G <- 100 ## Small mcmc scans to save time \## Fit multiple models for break number detection using Bayesian model comparison out0 <- NetworkStatic(Y, R=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out1 <- NetworkChange(Y, R=2, m=1, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out2 <- NetworkChange(Y, R=2, m=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out3 <- NetworkChange(Y, R=2, m=3, mcmc=G, burnin=G, verbose=G, Waic=TRUE) outlist <- list(out0, out1, out2, out3) \## The most probable model given break number 0 to 3 and data is out1 according to WAIC WaicCompare(outlist) plotU(out1) plotV(out1) ## End(Not run)
## Not run: set.seed(1973) \## Generate an array (30 by 30 by 40) with block transitions from 2 blocks to 3 blocks Y <- MakeBlockNetworkChange(n=10, T=40, type ="split") G <- 100 ## Small mcmc scans to save time \## Fit multiple models for break number detection using Bayesian model comparison out0 <- NetworkStatic(Y, R=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out1 <- NetworkChange(Y, R=2, m=1, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out2 <- NetworkChange(Y, R=2, m=2, mcmc=G, burnin=G, verbose=G, Waic=TRUE) out3 <- NetworkChange(Y, R=2, m=3, mcmc=G, burnin=G, verbose=G, Waic=TRUE) outlist <- list(out0, out1, out2, out3) \## The most probable model given break number 0 to 3 and data is out1 according to WAIC WaicCompare(outlist) plotU(out1) plotV(out1) ## End(Not run)
NetworkChangeRobust implements Bayesian multiple changepoint models to network time series data using a degree-corrected multilinear tensor decomposition method with t-distributed error
NetworkChangeRobust( Y, R = 2, m = 1, initial.s = NULL, mcmc = 100, burnin = 100, verbose = 0, thin = 1, degree.normal = "eigen", UL.Normal = "Orthonormal", plotUU = FALSE, plotZ = FALSE, b0 = 0, B0 = 1, c0 = NULL, d0 = NULL, n0 = 2, m0 = 2, u0 = NULL, u1 = NULL, v0 = NULL, v1 = NULL, a = NULL, b = NULL )
NetworkChangeRobust( Y, R = 2, m = 1, initial.s = NULL, mcmc = 100, burnin = 100, verbose = 0, thin = 1, degree.normal = "eigen", UL.Normal = "Orthonormal", plotUU = FALSE, plotZ = FALSE, b0 = 0, B0 = 1, c0 = NULL, d0 = NULL, n0 = 2, m0 = 2, u0 = NULL, u1 = NULL, v0 = NULL, v1 = NULL, a = NULL, b = NULL )
Y |
Reponse tensor |
R |
Dimension of latent space. The default is 2. |
m |
Number of change point.
If |
initial.s |
The starting value of latent state vector. The default is sampling from equal probabilities for all states. |
mcmc |
The number of MCMC iterations after burnin. |
burnin |
The number of burn-in iterations for the sampler. |
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. |
degree.normal |
A null model for degree correction. Users can choose "NULL", "eigen" or "Lsym." "NULL" is no degree correction. "eigen" is a principal eigen-matrix consisting of the first eigenvalue and the corresponding eigenvector. " Lsym" is a modularity matrix. Default is "eigen." |
UL.Normal |
Transformation of sampled U. Users can choose "NULL", "Normal" or "Orthonormal." "NULL" is no normalization. "Normal" is the standard normalization. "Orthonormal" is the Gram-Schmidt orthgonalization. Default is "NULL." |
plotUU |
If |
plotZ |
If |
b0 |
The prior mean of |
B0 |
The prior variance of |
c0 |
= 0.1 The shape parameter of inverse gamma prior for |
d0 |
= 0.1 The rate parameter of inverse gamma prior for |
n0 |
= 0.1 The shape parameter of inverse gamma prior for |
m0 |
= 0.1 The rate parameter of inverse gamma prior for |
u0 |
|
u1 |
|
v0 |
|
v1 |
|
a |
|
b |
|
An mcmc object that contains the posterior sample. This object can
be summarized by functions provided by the coda package. The object
contains an attribute Waic.out
that contains results of WAIC and the log-marginal
likelihood of the model (logmarglike
). The object
also contains an attribute prob.state
storage matrix that contains the
probability of for each period
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
Peter D. Hoff 2011. "Hierarchical Multilinear Models for Multiway Data." Computational Statistics \& Data Analysis. 55: 530-543.
Siddhartha Chib. 1998. "Estimation and comparison of multiple change-point models." Journal of Econometrics. 86: 221-241.
Sumio Watanabe. 2010. "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory." Journal of Machine Learning Research. 11: 3571-3594. Siddhartha Chib. 1995. “Marginal Likelihood from the Gibbs Output.” Journal of the American Statistical Association. 90: 1313-1321.
## Not run: set.seed(1973) ## Generate an array (30 by 30 by 40) with block transitions from 2 blocks to 3 blocks Y <- MakeBlockNetworkChange(n=10, T=40, type ="split") G <- 100 ## only 100 mcmc scans to save time ## Fit models out1 <- NetworkChangeRobust(Y, R=2, m=1, mcmc=G, burnin=G, verbose=G) ## plot latent node positions plotU(out1) ## plot layer-specific network generation rules plotV(out1) ## End(Not run)
## Not run: set.seed(1973) ## Generate an array (30 by 30 by 40) with block transitions from 2 blocks to 3 blocks Y <- MakeBlockNetworkChange(n=10, T=40, type ="split") G <- 100 ## only 100 mcmc scans to save time ## Fit models out1 <- NetworkChangeRobust(Y, R=2, m=1, mcmc=G, burnin=G, verbose=G) ## plot latent node positions plotU(out1) ## plot layer-specific network generation rules plotV(out1) ## End(Not run)
NetworkStatic implements a degree-corrected Bayesian multilinear tensor decomposition method
NetworkStatic( Y, R = 2, mcmc = 100, burnin = 100, verbose = 0, thin = 1, reduce.mcmc = NULL, degree.normal = "eigen", UL.Normal = "Orthonormal", plotUU = FALSE, plotZ = FALSE, constant = FALSE, b0 = 0, B0 = 1, c0 = NULL, d0 = NULL, u0 = NULL, u1 = NULL, v0 = NULL, v1 = NULL, marginal = FALSE, DIC = FALSE, Waic = FALSE )
NetworkStatic( Y, R = 2, mcmc = 100, burnin = 100, verbose = 0, thin = 1, reduce.mcmc = NULL, degree.normal = "eigen", UL.Normal = "Orthonormal", plotUU = FALSE, plotZ = FALSE, constant = FALSE, b0 = 0, B0 = 1, c0 = NULL, d0 = NULL, u0 = NULL, u1 = NULL, v0 = NULL, v1 = NULL, marginal = FALSE, DIC = FALSE, Waic = FALSE )
Y |
Reponse tensor |
R |
Dimension of latent space. The default is 2. |
mcmc |
The number of MCMC iterations after burnin. |
burnin |
The number of burn-in iterations for the sampler. |
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. |
reduce.mcmc |
The number of reduced MCMC iterations for marginal likelihood computations.
If |
degree.normal |
A null model for degree correction. Users can choose "NULL", "eigen" or "Lsym." "NULL" is no degree correction. "eigen" is a principal eigen-matrix consisting of the first eigenvalue and the corresponding eigenvector. " Lsym" is a modularity matrix. Default is "eigen." |
UL.Normal |
Transformation of sampled U. Users can choose "NULL", "Normal" or "Orthonormal." "NULL" is no normalization. "Normal" is the standard normalization. "Orthonormal" is the Gram-Schmidt orthgonalization. Default is "NULL." |
plotUU |
If |
plotZ |
If |
constant |
If |
b0 |
The prior mean of |
B0 |
The prior variance of |
c0 |
= 0.1 |
d0 |
= 0.1 |
u0 |
|
u1 |
|
v0 |
|
v1 |
|
marginal |
If |
DIC |
If |
Waic |
If |
An mcmc object that contains the posterior sample. This object can
be summarized by functions provided by the coda package. The object
contains an attribute Waic.out
that contains results of WAIC and the log-marginal
likelihood of the model (logmarglike
).
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
Peter D. Hoff 2011. "Hierarchical Multilinear Models for Multiway Data." Computational Statistics \& Data Analysis. 55: 530-543.
Sumio Watanabe. 2010. "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory." Journal of Machine Learning Research. 11: 3571-3594. Siddhartha Chib. 1995. “Marginal Likelihood from the Gibbs Output.” Journal of the American Statistical Association. 90: 1313-1321.
## Not run: set.seed(1973) \## generate an array with three constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=10, type ="constant") G <- 100 ## Small mcmc scans to save time out0 <- NetworkStatic(Y, R=2, mcmc=G, burnin=G, verbose=G) \## recovered latent blocks Kmeans(out0, n.cluster=3, main="Recovered Blocks") \## contour plot of latent node positions plotContour(out0) \## plot latent node positions plotU(out0) \## plot layer-specific network connection rules plotV(out0) ## End(Not run)
## Not run: set.seed(1973) \## generate an array with three constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=10, type ="constant") G <- 100 ## Small mcmc scans to save time out0 <- NetworkStatic(Y, R=2, mcmc=G, burnin=G, verbose=G) \## recovered latent blocks Kmeans(out0, n.cluster=3, main="Recovered Blocks") \## contour plot of latent node positions plotContour(out0) \## plot latent node positions plotU(out0) \## plot layer-specific network connection rules plotV(out0) ## End(Not run)
Draw a contour plot of latent node positions
plotContour(OUT, main = "", k = 8, my.cols = brewer.pal(k, "Spectral"))
plotContour(OUT, main = "", k = 8, my.cols = brewer.pal(k, "Spectral"))
OUT |
Output of networkchange objects. |
main |
The title of plot |
k |
The number of levels (nlevels in contour ()). |
my.cols |
Color scale. Use brewer.pal() from RColorBrewer. |
A plot object
## Not run: set.seed(1973) \## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=40, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") \## contour plot of latent node positions plotContour(out0) ## End(Not run)
## Not run: set.seed(1973) \## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=40, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") \## contour plot of latent node positions plotContour(out0) ## End(Not run)
Plot network array data
plotnetarray( Y, n.graph = 4, node.size = 2, node.color = "brown", edge.alpha = 0.5, edge.size = 0.2, edge.color = "grey" )
plotnetarray( Y, n.graph = 4, node.size = 2, node.color = "brown", edge.alpha = 0.5, edge.size = 0.2, edge.color = "grey" )
Y |
network array data |
n.graph |
number of subgraphs. Default is 4. |
node.size |
node size. Default is 2. |
node.color |
node color. Default is "brown." |
edge.alpha |
transparency of edge. Default is 0.5. |
edge.size |
edge size. Default is 0.2. |
edge.color |
edge color. Default is "grey." |
A plot object
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.
## Not run: set.seed(1973) ## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=1, T=20, type ="split") plotnetarray(Y) ## End(Not run)
## Not run: set.seed(1973) ## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=1, T=20, type ="split") plotnetarray(Y) ## End(Not run)
Plot latent node positions
plotU(OUT, Time = NULL, names = NULL, main = NULL, label.prob = 0.9)
plotU(OUT, Time = NULL, names = NULL, main = NULL, label.prob = 0.9)
OUT |
Output of networkchange objects. |
Time |
Starting of the time period. If NULL, 1. |
names |
Node names. If NULL, use natural numbers. |
main |
The title of plot |
label.prob |
Label print threshold. 0.9 is the default. |
A plot object
## Not run: set.seed(1973) \## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=40, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") \## latent node positions plotU(out0) ## End(Not run)
## Not run: set.seed(1973) \## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=40, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") \## latent node positions plotU(out0) ## End(Not run)
Plot layer-specific network generation rules.
plotV(OUT, main = "", cex = 2)
plotV(OUT, main = "", cex = 2)
OUT |
Output of networkchange objects. |
main |
The title of plot |
cex |
point size |
A plot object
## Not run: set.seed(1973) \## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=40, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") \## latent node positions plotV(out0) ## End(Not run)
## Not run: set.seed(1973) \## generate an array with two constant blocks Y <- MakeBlockNetworkChange(n=10, shape=10, T=40, type ="constant") out0 <- NetworkStatic(Y, R=2, mcmc=10, burnin=10, verbose=10, UL.Normal = "Orthonormal") \## latent node positions plotV(out0) ## End(Not run)
This dataframe contains postwar alliance network data from 1946 to 2012 (2 year interval).
The dataframe has contains data for postwar alliance network data from 1946 to 2012 with 2 year interval. After removing disconnected components, 104 countries are included. In this data set, a defense pact (Type I), which is the highest level of military commitment, is coded as 1, and 0 otherwise.
Correlates of War Project. 2017. "State System Membership List, v2016." Online, https://correlatesofwar.org/. Gibler, Douglas M. 2009. International military alliances, 1648-2008. CQ Press.
Sample a starting value of hidden states
startS(Z, Time, m, initial.U, V, s2, R)
startS(Z, Time, m, initial.U, V, s2, R)
Z |
Degree-corrected network array data |
Time |
The length of time. |
m |
The number of breaks |
initial.U |
Initialized U matrix. |
V |
Initialized V matrix. |
s2 |
Initialized error variance |
R |
The dimensionality of latent space |
A state vector
Initialize starting values of U and V
startUV(Z, R, K)
startUV(Z, R, K)
Z |
Degree-corrected network array data. |
R |
The dimensionality of latent space. |
K |
The dimensionality of Z. |
A list of U and V
Sample hidden states from hidden Markov multilinear model
ULUstateSample(m, s, ZMUt, s2, P, SOS.random)
ULUstateSample(m, s, ZMUt, s2, P, SOS.random)
m |
The number of break |
s |
Latent state vector |
ZMUt |
Z - MU |
s2 |
error variance |
P |
Transition matrix |
SOS.random |
single observation state random perturbation |
A list of a state vector, state probabilities, and SOS.random.
Sample hidden states from hidden Markov multilinear model with precision using Rmpfr package
ULUstateSample.mpfr(m, s, ZMUt, s2, P, SOS.random)
ULUstateSample.mpfr(m, s, ZMUt, s2, P, SOS.random)
m |
The number of break |
s |
Latent state vector |
ZMUt |
Z - MU |
s2 |
error variance |
P |
Transition matrix |
SOS.random |
single observation state random perturbation |
A list of a state vector, state probabilities, and SOS.random.
Update time-constant regression parameters
updateb(Z, MU, s2, XtX, b0, B0)
updateb(Z, MU, s2, XtX, b0, B0)
Z |
Degree corrected response tensor |
MU |
Mean array |
s2 |
Error variance |
XtX |
X'X |
b0 |
Prior mean of beta |
B0 |
Prior variance of beta |
A vector of regression parameters
Update regime-changing beta
updatebm(ns, K, s, s2, B0, p, ZU)
updatebm(ns, K, s, s2, B0, p, ZU)
ns |
The number of hidden states |
K |
The dimensionality of Z |
s |
Latent state vector |
s2 |
The variance of error |
B0 |
The prior variance of beta |
p |
The rank of X |
ZU |
Z - ULU |
A vector of regime-changing regression parameters
Update transition matrix
updateP(s, ns, P, A0)
updateP(s, ns, P, A0)
s |
Latent state vector |
ns |
The number of hidden states |
P |
Transition matrix |
A0 |
Prior of transition matrix |
A transtion matrix
Update latent states
updateS( iter, s, V, m, Zb, Zt, Time, MU.state, P, s2, N.upper.tri, random.perturb )
updateS( iter, s, V, m, Zb, Zt, Time, MU.state, P, s2, N.upper.tri, random.perturb )
iter |
iteration number |
s |
the most recent latent states |
V |
Network generation rules |
m |
The number of breaks |
Zb |
Z - b |
Zt |
Z stacked by time |
Time |
The length of time |
MU.state |
UVU for each state |
P |
Transition matrix |
s2 |
error variance |
N.upper.tri |
The number of upper triangular elements |
random.perturb |
If |
A list of vectors containing latent states and their probabilities
Update regime-specific variance parameter
updates2m(ns, Zm, MU, c0, d0, Km)
updates2m(ns, Zm, MU, c0, d0, Km)
ns |
The number of hidden states |
Zm |
The regime-specific holder of Z - beta |
MU |
The mean array. |
c0 |
Scalar shape parameter |
d0 |
Scalar scale parameter |
Km |
Regime-specific dimensions |
A scalar for a regime-specific variance
Update time-constant latent node positions
updateU(K, U, V, R, Zb, s2, eU, iVU)
updateU(K, U, V, R, Zb, s2, eU, iVU)
K |
The dimensionality of Z |
U |
The most recent draw of latent node positions |
V |
Layer-specific network generation rule |
R |
The dimensionality of latent space |
Zb |
Z - beta |
s2 |
error variance |
eU |
The mean of U |
iVU |
The variance of U |
A matrix of time-constant latent node positions
Update regime-specific latent node positions.
updateUm(ns, U, V, R, Zm, Km, ej, s2, eU, iVU, UL.Normal)
updateUm(ns, U, V, R, Zm, Km, ej, s2, eU, iVU, UL.Normal)
ns |
The number of latent states |
U |
THe latent node positions |
V |
Layer-specific network generation rule. |
R |
The dimensionality of latent space |
Zm |
Regim-specific Z - beta |
Km |
The dimension of regime-specific Z. |
ej |
Regime indicator. |
s2 |
The variance of error. |
eU |
The regim-specific mean of U. |
iVU |
The regim-specific variance of U. |
UL.Normal |
Normalization method for U. "Normal" or "Orthonormal" are supported. |
A matrix of regime-specific latent node positions
Update layer specific network generation rules
updateV(Zb, U, R, K, s2, eV, iVV, UTA)
updateV(Zb, U, R, K, s2, eV, iVV, UTA)
Zb |
Z - beta. |
U |
The latent node positions. |
R |
The dimension of latent space. |
K |
The dimension of Z. |
s2 |
The variance of error. |
eV |
The mean of V. |
iVV |
The variance of V. |
UTA |
Indicator of upper triangular array |
A matrix of layer specific network generation rules
Update layer specific network generation rules from a change-point network process
updateVm(ns, U, V, Zm, Km, R, s2, eV, iVV, UTA)
updateVm(ns, U, V, Zm, Km, R, s2, eV, iVV, UTA)
ns |
The number of hidden regimes. |
U |
The latent node positions. |
V |
The layer-specific network generation rule. |
Zm |
The holder of Z - beta. |
Km |
The dimension of regime-specific Z. |
R |
The dimension of latent space. |
s2 |
The variance of error. |
eV |
The mean of V |
iVV |
The variance of V |
UTA |
Indicator of upper triangular array |
A matrix of regime-specific layer specific network generation rules
Compare Widely Applicable Information Criterion
WaicCompare(outlist)
WaicCompare(outlist)
outlist |
List of NetworkChange objects |
Results of WAIC computation
A matrix of log marginal likelihoods.
Sumio Watanabe. 2010. "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory." Journal of Machine Learning Research. 11: 3571-3594.
Andrew Gelman, Jessica Hwang, and Aki Vehtari. 2014. "Understanding predictive information criteria for Bayesian models." Statistics and Computing. 24(6):997-1016.
Jong Hee Park and Yunkyun Sohn. 2020. "Detecting Structural Change in Longitudinal Network Data." Bayesian Analysis. Vol.15, No.1, pp.133-157.