Title: | Sparse Time Series Chain Graphical Models |
---|---|
Description: | Computes sparse vector autoregressive coefficients and precision matrices for time series chain graphical models. Fentaw Abegaz and Ernst Wit (2013) <doi:10.1093/biostatistics/kxt005>. |
Authors: | Fentaw Abegaz [aut, cre], Ernst Wit [aut] |
Maintainer: | Fentaw Abegaz <[email protected]> |
License: | GPL (>= 3) |
Version: | 4.0 |
Built: | 2024-12-07 06:48:09 UTC |
Source: | CRAN |
Computes sparse autoregressive coefficient and precision matrices for time series chain graphical models(TSCGM). These models provide an effeicient way of simultaneously dealing with Gaussian graphical models (undirected graphs for instantaneous interactions) and Bayesian networks (directed graphs for dynamic interactions) for reconstructing instantaneous and dynamic networks from repeated multivariate time series data.
Package: | SparseTSCGM |
Type: | Package |
Version: | 4.0 |
Date: | 2021-01-12 |
License: | GPL (>=3) |
LazyLoad: | yes |
Fentaw Abegaz and Ernst Wit
Maintainer: Fentaw Abegaz <[email protected]>
Fentaw Abegaz and Ernst Wit (2013). Sparse time series chain graphical models for reconstructing genetic networks. Biostatistics. 14, 3: 586-599.
Rothman, A.J., Levina, E., and Zhu, J. (2010). Sparse multivariate regression with covariance estimation. Journal of Computational and Graphical Statistics. 19: 947–962.
seed = 321 datas <- sim.data(model="ar1", time=10,n.obs=10, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 prec_true <- datas$theta autoR_true <- datas$gamma res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar1", penalty="scad", optimality="bic_mod", control=list(maxit.out = 10, maxit.in = 100)) #Estimated sparse precision and autoregression matrices prec <- res.tscgm$theta autoR <- res.tscgm$gamma #Graphical visualization oldpar <- par(mfrow=c(2,2)) plot.tscgm(datas, mat="precision",main="True precision matrix") plot.tscgm(res.tscgm, mat="precision",main="Estimated precision matrix") plot.tscgm(datas, mat="autoregression",main="True autoregression coef. matrix") plot.tscgm(res.tscgm, mat="autoregression", main="Estimated autoregression coef. matrix") par(oldpar)
seed = 321 datas <- sim.data(model="ar1", time=10,n.obs=10, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 prec_true <- datas$theta autoR_true <- datas$gamma res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar1", penalty="scad", optimality="bic_mod", control=list(maxit.out = 10, maxit.in = 100)) #Estimated sparse precision and autoregression matrices prec <- res.tscgm$theta autoR <- res.tscgm$gamma #Graphical visualization oldpar <- par(mfrow=c(2,2)) plot.tscgm(datas, mat="precision",main="True precision matrix") plot.tscgm(res.tscgm, mat="precision",main="Estimated precision matrix") plot.tscgm(datas, mat="autoregression",main="True autoregression coef. matrix") plot.tscgm(res.tscgm, mat="autoregression", main="Estimated autoregression coef. matrix") par(oldpar)
The data contains 30 genes identified using cluster analysis from 12488 probe sets representing approximately 8600 genes. The data are measured over 54 arrays of 3 replicates each on 18 time points of the developmental stages of mammary gland in mice. See Stein et al. (2004) for more details.
data(mammary)
data(mammary)
Data is in longitudinal format with 30 columns, 54 rows and a number of extra attributes (see R package longitudinal).
This data is described in Stein et al. (2004) and can be freely obtained from the R package smida.
Stein T, Morris J, Davies C, Weber Hall S, Duffy M, Heath V, Bell A, Ferrier R, Sandilands G, Gusterson B, et al. (2004). Involution of the mouse mammary gland is associated with an immune cascade and an acute phase response, involving LBP, CD14 and STAT3. Breast Cancer Res, 6(2), R 75 - 91.
Wit E. and McClure J. (2004). Statistics for Microarrays: Design, Analysis and Inference. Wiley.
# load "longitudinal" library library(longitudinal) # load data sets data(mammary)
# load "longitudinal" library library(longitudinal) # load data sets data(mammary)
plot.tscgm
is a generic plot function that is adapted
for objects of class sparse.tscgm
.
## S3 method for class 'tscgm' plot(x, mat=c("precision","autoregression"),...)
## S3 method for class 'tscgm' plot(x, mat=c("precision","autoregression"),...)
x |
an object of class |
mat |
Name of matrix to be plotted,i.e., either the precision matrix or vector autoregression matrix. |
... |
Arguments to be passed to graphical parameters (see |
Undirected or directed networks.
Fentaw Abegaz and Ernst Wit
seed = 321 datas <- sim.data(model="ar1", time=10,n.obs=10, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar1", penalty="scad",optimality="bic_mod",control=list(maxit.out = 10, maxit.in = 100)) #Network visualization oldpar <- par(mfrow=c(2,1)) plot.tscgm(res.tscgm, mat="precision", main="Undirected network", pad = 0.01, label.pad = 0.3, label.col = 6, vertex.col = 5,vertex.cex = 1.5, edge.col = 4, mode = "fruchtermanreingold", interactive=FALSE) plot.tscgm(res.tscgm, mat="autoregression", main="Directed network", pad = 0.01, label.pad = 0.3, label.col = 6, vertex.col = 5,vertex.cex = 1.5, edge.col = 4, mode = "fruchtermanreingold", interactive=FALSE) par(oldpar)
seed = 321 datas <- sim.data(model="ar1", time=10,n.obs=10, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar1", penalty="scad",optimality="bic_mod",control=list(maxit.out = 10, maxit.in = 100)) #Network visualization oldpar <- par(mfrow=c(2,1)) plot.tscgm(res.tscgm, mat="precision", main="Undirected network", pad = 0.01, label.pad = 0.3, label.col = 6, vertex.col = 5,vertex.cex = 1.5, edge.col = 4, mode = "fruchtermanreingold", interactive=FALSE) plot.tscgm(res.tscgm, mat="autoregression", main="Directed network", pad = 0.01, label.pad = 0.3, label.col = 6, vertex.col = 5,vertex.cex = 1.5, edge.col = 4, mode = "fruchtermanreingold", interactive=FALSE) par(oldpar)
plot.tscgm.ar2
is a generic plot function that is adapted
for objects of class sparse.tscgm
.
## S3 method for class 'tscgm.ar2' plot(x, mat=c("precision","autoregression1", "autoregression2"),...)
## S3 method for class 'tscgm.ar2' plot(x, mat=c("precision","autoregression1", "autoregression2"),...)
x |
an object of class |
mat |
Name of matrix to be plotted,i.e., either the precision matrix or vector autoregression matrices of lag 1 or 2. |
... |
Arguments to be passed to graphical parameters (see |
Undirected or directed networks.
Fentaw Abegaz and Ernst Wit
## Data generation from time series chain graphical model with vector ## autoregressive model of order 2 seed = 321 datas <- sim.data(model="ar2", time=10,n.obs=20, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 ## Model fitting with vector autoregressive order 2 res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar2", penalty="scad",optimality="bic_mod",control=list(maxit.out = 10, maxit.in = 100)) #Network visualization oldpar<-par(mfrow=c(3,2)) plot.tscgm.ar2(datas, mat="precision",main="True precision matrix") plot.tscgm.ar2(res.tscgm, mat="precision",main="Estimated precision matrix") plot.tscgm.ar2(datas, mat="autoregression1", main="True autoregression coef. matrix of lag 1" ) plot.tscgm.ar2(res.tscgm, mat="autoregression1", main="Estimated autoregression coef. matrix of lag 1") plot.tscgm.ar2(datas, mat="autoregression2", main="True autoregression coef. matrix of lag 2") plot.tscgm.ar2(res.tscgm, mat="autoregression2", main="Estimated autoregression coef. matrix of lag 2") par(oldpar)
## Data generation from time series chain graphical model with vector ## autoregressive model of order 2 seed = 321 datas <- sim.data(model="ar2", time=10,n.obs=20, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 ## Model fitting with vector autoregressive order 2 res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar2", penalty="scad",optimality="bic_mod",control=list(maxit.out = 10, maxit.in = 100)) #Network visualization oldpar<-par(mfrow=c(3,2)) plot.tscgm.ar2(datas, mat="precision",main="True precision matrix") plot.tscgm.ar2(res.tscgm, mat="precision",main="Estimated precision matrix") plot.tscgm.ar2(datas, mat="autoregression1", main="True autoregression coef. matrix of lag 1" ) plot.tscgm.ar2(res.tscgm, mat="autoregression1", main="Estimated autoregression coef. matrix of lag 1") plot.tscgm.ar2(datas, mat="autoregression2", main="True autoregression coef. matrix of lag 2") plot.tscgm.ar2(res.tscgm, mat="autoregression2", main="Estimated autoregression coef. matrix of lag 2") par(oldpar)
print
is a generic function that prints output summaries of fitted
models in the SparseTSCGM package.
## S3 method for class 'tscgm' print(x, ...)
## S3 method for class 'tscgm' print(x, ...)
x |
an object of class |
... |
other arguments passed to print. |
The print.tscgm
function summarizes and prints results of
the fitted model.
Prints summary of results:
Fentaw Abegaz and Ernst Wit
Generates sparse vector autoregressive coefficients matrices and precision matrix from various network structures and using these matrices generates repeated multivariate time series dataset.
sim.data(model=c("ar1","ar2"),time=time,n.obs=n.obs, n.var=n.var,seed=NULL, prob0=NULL, network=c("random","scale-free","hub","user_defined"), prec=NULL,gamma1=NULL,gamma2=NULL)
sim.data(model=c("ar1","ar2"),time=time,n.obs=n.obs, n.var=n.var,seed=NULL, prob0=NULL, network=c("random","scale-free","hub","user_defined"), prec=NULL,gamma1=NULL,gamma2=NULL)
model |
Specifies the order of vector autoregressive models. Vector autoregressive
model of order 1 is applied if |
time |
Number of time points. |
n.obs |
Number of observations or replicates. |
n.var |
Number of variables. |
seed |
Random number seed. |
prob0 |
Initial sparsity level. |
network |
Specifies the type of network structure. This could be random, scale-free, hub
or user defined structures. Details on simultions from the various network
structures can be found in the R package |
prec |
Precision matrix. |
gamma1 |
Autoregressive coefficients matrix at time lag 1. |
gamma2 |
Autoregressive coefficients matrix at time lag 2. |
A list containing:
theta |
Sparse precision matrix. |
gamma |
Sparse autoregressive coefficients matrix. |
sigma |
Covariance matrix. |
data1 |
Repeated multivariate time series data in longitudinal format. |
Fentaw Abegaz and Ernst Wit
seed = 321 datas <- sim.data(model="ar1", time=4,n.obs=3, n.var=5,seed=seed,prob0=0.35, network="random") data.ts <- datas$data1 prec_true <- datas$theta autoR_true <- datas$gamma
seed = 321 datas <- sim.data(model="ar1", time=4,n.obs=3, n.var=5,seed=seed,prob0=0.35, network="random") data.ts <- datas$data1 prec_true <- datas$theta autoR_true <- datas$gamma
Computes sparse vector autoregressive coefficients matrices of order 1 and
order 2 and precision matrix estimates for time series chain graphical
models using SCAD penalty. In time series chain graphs directed
edges are identified by nonzero entries of the autoregressive
coefficients matrix and undirected
edges are identified by
nonzero entries of the precision matrix.
sparse.tscgm(data = data, lam1 = NULL, lam2 = NULL, nlambda = NULL, model = c("ar1", "ar2"), penalty=c("scad","lasso"), optimality = c("NULL", "bic", "bic_ext", "bic_mod", "aic", "gic"), control = list())
sparse.tscgm(data = data, lam1 = NULL, lam2 = NULL, nlambda = NULL, model = c("ar1", "ar2"), penalty=c("scad","lasso"), optimality = c("NULL", "bic", "bic_ext", "bic_mod", "aic", "gic"), control = list())
data |
Longitudinal data format. |
lam1 |
Either a scalar or a vector of tuning parameter values for the
SCAD penalty on the precision matrix. The default is |
lam2 |
Either a scalar or a vector of tuning parameter values for the
SCAD penalty on the precision matrix. The default is |
nlambda |
The number of values used in |
model |
This specifies the order of vector autoregressive models. Vector autoregressive
model of order 1 is applied if |
penalty |
This specifies the type of penalty function uto be used. SCAD penalty function
is applied if |
optimality |
This specifies the type of information based model selection criteria. When
optimality is "NULL" it computes the time series chain graphical model
solutions for specified scalar values of the tuning parameters |
control |
The argument control = list(maxit.out = 5, maxit.in = 50, tol.out = 1e-04, silent = TRUE)
|
For description of the objective functions and computational details see Abegaz and Wit (2013).
A list containing:
theta |
Precision matrix estimate. The nonzero estimates of
the precision matrix are used for constructing |
gamma |
Autoregressive coefficients matrix estimate. The nonzero estimates
of the autoregression matrix are used for constructing |
lam1.opt |
The optimal tuning parameter for SCAD penalty on the precision matrix selected with minimum information criterion. |
lam2.opt |
The optimal tuning parameter for SCAD penalty on the autoregressive coefficients matrix selected with minimum BIC criterion. |
min.ic |
Minimum value of the optimality criterion. |
tun.ic |
A matrix containing the list of tuning parameter values and the corresponding model selection or optimality values. |
lam1.seq |
The sequence of tuning parameter values related to precision matrix. |
lam2.seq |
The sequence of tuning parameter values related to autoregression matrix. |
s.theta |
Sparsity level of the precision matrix. |
s.gamma |
Sparsity level of the autoregression coefficients matrix. |
Fentaw Abegaz and Ernst Wit
Fentaw Abegaz and Ernst Wit (2013). Sparse time series chain graphical models for reconstructing genetic networks. Biostatistics. 14, 3: 586-599.
Rothman, A.J., Levina, E., and Zhu, J. (2010). Sparse multivariate regression with covariance estimation. Journal of Computational and Graphical Statistics. 19: 947–962.
seed = 321 datas <- sim.data(model="ar1", time=10,n.obs=10, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 prec_true <- datas$theta autoR_true <- datas$gamma res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar1", penalty="scad",optimality="bic_mod",control=list(maxit.out = 10, maxit.in = 100)) #Estimated sparse precision and autoregression matrices prec <- res.tscgm$theta autoR <- res.tscgm$gamma #Optimal tuning parameter values lambda1.opt <- res.tscgm$lam1.opt lambda2.opt <- res.tscgm$lam2.opt #Sparsity levels sparsity_theta <- res.tscgm$s.theta sparsity_gamma <- res.tscgm$s.gamma #Graphical visualization oldpar <- par(mfrow=c(2,2)) plot.tscgm(datas, mat="precision",main="True precision matrix") plot.tscgm(res.tscgm, mat="precision",main="Estimated precision matrix") plot.tscgm(datas, mat="autoregression",main="True autoregression coef. matrix") plot.tscgm(res.tscgm, mat="autoregression", main="Estimated autoregression coef. matrix") par(oldpar)
seed = 321 datas <- sim.data(model="ar1", time=10,n.obs=10, n.var=5,seed=seed,prob0=0.35, network="random") data.fit <- datas$data1 prec_true <- datas$theta autoR_true <- datas$gamma res.tscgm <- sparse.tscgm(data=data.fit, lam1=NULL, lam2=NULL, nlambda=NULL, model="ar1", penalty="scad",optimality="bic_mod",control=list(maxit.out = 10, maxit.in = 100)) #Estimated sparse precision and autoregression matrices prec <- res.tscgm$theta autoR <- res.tscgm$gamma #Optimal tuning parameter values lambda1.opt <- res.tscgm$lam1.opt lambda2.opt <- res.tscgm$lam2.opt #Sparsity levels sparsity_theta <- res.tscgm$s.theta sparsity_gamma <- res.tscgm$s.gamma #Graphical visualization oldpar <- par(mfrow=c(2,2)) plot.tscgm(datas, mat="precision",main="True precision matrix") plot.tscgm(res.tscgm, mat="precision",main="Estimated precision matrix") plot.tscgm(datas, mat="autoregression",main="True autoregression coef. matrix") plot.tscgm(res.tscgm, mat="autoregression", main="Estimated autoregression coef. matrix") par(oldpar)
summary
is a generic function that produces output summaries of fitted
models in the SparseTSCGM package. In particular, the function invokes
methods for objects of class sparse.tscgm.
## S3 method for class 'tscgm' summary(object, ...)
## S3 method for class 'tscgm' summary(object, ...)
object |
An object of class |
... |
Other arguments passed to summary. |
The summary.stscgm
function provides summary results of the fitted model.
A list containing:
theta |
Precision matrix estimate |
gamma |
Autoregressive coefficients matrix estimate |
lam1.opt |
The optimal tuning parameter on the precision matrix with model selection. |
lam2.opt |
The optimal tuning parameter on the autoregressive coefficients matrix with model selection. |
min.ic |
Minimum value of the optimality criterion. |
tun.ic |
A matrix containing the list values from model selection. |
lam1.seq |
The sequence of tuning parameter values on precision matrix. |
lam2.seq |
The sequence of tuning parameter values on autoregression matrix. |
s.theta |
Sparsity level of the precision matrix. |
s.gamma |
Sparsity level of the autoregression coefficients matrix. |
Fentaw Abegaz and Ernst Wit