Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/cran/graphicalVAR
15 March 2024, 11:27:55 UTC
  • Code
  • Branches (14)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.1.1
    • refs/tags/0.1.2
    • refs/tags/0.1.3
    • refs/tags/0.1.4
    • refs/tags/0.2
    • refs/tags/0.2.1
    • refs/tags/0.2.2
    • refs/tags/0.2.3
    • refs/tags/0.2.4
    • refs/tags/0.3
    • refs/tags/0.3.1
    • refs/tags/0.3.3
    • refs/tags/0.3.4
    No releases to show
  • 37363ec
  • /
  • man
  • /
  • graphicalVAR.Rd
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:f49730e4286fa1369b20089c1c06633d29733487
origin badgedirectory badge Iframe embedding
swh:1:dir:c2aa17b473f02ae2aad31dce7edfcddda2245b64
origin badgerevision badge
swh:1:rev:5ec0fee4721f06734fa9952c26bdf6f2128cac0d
origin badgesnapshot badge
swh:1:snp:9d71d524f3f98b6820bf7864b20870c1d9d25774
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 5ec0fee4721f06734fa9952c26bdf6f2128cac0d authored by Sacha Epskamp on 21 February 2024, 04:10:03 UTC
version 0.3.4
Tip revision: 5ec0fee
graphicalVAR.Rd
\name{graphicalVAR}
\alias{graphicalVAR}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Estimate the graphical VAR model.
}
\description{
Estimates the graphical VAR (Wild et al., 2010) model through LASSO estimation coupled with extended Bayesian information criterion for choosing the optimal tuning parameters. The estimation procedure is outlined by Rothman, Levina and Zhu (2010) and is further described by Abegaz and Wit (2013). The procedure here is based on the work done in the R package SparseTSCGM (Abegaz and Wit, 2014).
}
\usage{
graphicalVAR(data, nLambda = 50, verbose = TRUE, gamma = 0.5, scale
                   = TRUE, lambda_beta, lambda_kappa,
                   regularize_mat_beta, regularize_mat_kappa, maxit.in =
                   100, maxit.out = 100, deleteMissings = TRUE,
                   penalize.diagonal = TRUE, lambda_min_kappa = 0.05,
                   lambda_min_beta = lambda_min_kappa, mimic =
                   c("current", "0.3.2", "0.1.2", "0.1.4", "0.1.5",
                   "0.2"), vars, beepvar, dayvar, idvar, lags = 1,
                   centerWithin = TRUE, likelihood = c("unpenalized",
                   "penalized"), ebic_tol = 1e-04)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{data}{
A matrix or data frame containing repeated measures (rows) on a set of variables (columns).
}
  \item{nLambda}{
The number of both lambda parameters to test. Defaults to 50, which results in 2500 models to evaluate.
}
  \item{verbose}{
Logical, should a progress bar be printed to the console?
}
  \item{gamma}{
The EBIC hyper-parameter. Set to 0 to use regular BIC.
}
\item{scale}{
Logical, should responses be standardized before estimation?
}
  \item{lambda_beta}{
An optional vector of lambda_beta values to test. Set \code{lambda_beta = 0} argument and \code{lambda_kappa = 0} for unregularized estimation.
}
  \item{lambda_kappa}{
An optional vector of lambda_kappa values to test. Set \code{lambda_beta = 0} argument and \code{lambda_kappa = 0} for unregularized estimation.
}
\item{regularize_mat_beta}{
A logical matrix indicating which elements of the beta matrix should be regularized (experimental).
}
\item{regularize_mat_kappa}{
A logical matrix indicating which elements of the kappa matrix should be regularized (experimental).
}
  \item{maxit.in}{
Maximum number of iterations in the inner loop (computing beta)
}
  \item{maxit.out}{
  Maximum number of iterations in the outer loop
  }
  \item{deleteMissings}{
    Logical, should missing responses be deleted?
  }
  \item{penalize.diagonal}{
  Logical, should the diagonal of beta be penalized (i.e., penalize auto-regressions)?
  }
  \item{lambda_min_kappa}{
      Multiplier of maximal tuning parameter for kappa
  }
    \item{lambda_min_beta}{
      Multiplier of maximal tuning parameter for beta
  }
  \item{mimic}{
      Allows one to mimic earlier versions of graphicalVAR
  }
\item{vars}{
Vectors of variables to include in the analysis
}
\item{beepvar}{
String indicating assessment beep per day (if missing, is added). Adding this argument will cause non-consecutive beeps to be treated as missing!
}
  \item{dayvar}{
String indicating assessment day. Adding this argument makes sure that the first measurement of a day is not regressed on the last measurement of the previous day. IMPORTANT: only add this if the data has multiple observations per day.
}
  \item{idvar}{
String indicating the subject ID
}
\item{lags}{
Vector of lags to include
}
\item{centerWithin}{
Logical, should subject data be within-person centered before estimating fixed effects?
}
\item{likelihood}{
Should likelihood be computed based on penalized contemporaneous matrix or unpenalized contemporaneous matrix. Set to \code{"penalized"} to mimic version 2.5 and later of \code{sparseTSCGM}.
}
\item{ebic_tol}{
Tolerance used to judge if two EBIC values are the same. If two values are deemed the same the model with the lowest tuning parameter (kappa preferred) will be selected.
}
}
\details{
Let y_t denote the vector of centered responses of a subject on a set of items on time point t. The graphical VAR model, using only one lag, is defined as follows:

y[t] = Beta y[y-1] + epsilon[t]

In which epsilon_t is a vector of error and is independent between time points but not within time points. Within time points, the error is normally distributed with mean vector 0 and precision matrix (inverse covariance matrix) Kappa. The Beta matrix encodes the between time point interactions and the Kappa matrix encodes the within time point interactions. We aim to find a sparse solution for both Beta and Kappa, and do so by applying the LASSO algorithm as detailed by Rothman, Levina and Zhu (2010). The LASSO algorithm uses two tuning parameters, lambda_beta controlling the sparsity in Beta and lambda_kappa controlling the sparsity in Kappa. We estimate the model under a (by default) 50 by 50 grid of tuning parameters and choose the tuning parameters that optimize the extended Bayesian Information Criterion (EBIC; Chen and Chen,2008).

After estimation, the Beta and Kappa matrices can be standardized as described by Wild et al. (2010). The Kappa matrix can be standardized to partial contemporaneous correlations (PCC) as follows:

PCC(y[i,t], y[j,t]) = - kappa[ij] / sqrt(kappa[ii] kappa[jj])

Similarly, the beta matrix can be standardized to partial directed correlations (PDC):

PDC(y[i,t-1], y[j,t]) = beta[ji] / sqrt( sigma[jj] kappa[ii] + beta[ji]^2 )

In which sigma is the inverse of kappa. Note that this process transposes the beta matrix. This is done because in representing a directed network it is typical to let rows indicate the node of origin and columns the node of destination.

Set \code{lambda_beta = 0} argument and \code{lambda_kappa = 0} for unregularized estimation.

Missing data are removed listwise after augmenting the dataset. This means that if there is a missing response at time t, the row corresponding to time t-1 and time t and the row corresponding to time t and time t+1 are removed.
}
\value{
A \code{graphicalVAR} object, which is a list containing:

\item{PCC}{The partial contemporaneous correlation network}
\item{PDC}{The  partial directed correlation network}
\item{beta}{The estimated beta matrix}
\item{kappa}{The estimated kappa matrix}
\item{EBIC}{The optimal EBIC}
\item{path}{Results of all tested tuning parameters}
\item{labels}{A vector containing the node labels}
}
\references{
Chen, J., & Chen, Z. (2008). Extended Bayesian information criteria for model selection with large model spaces. Biometrika, 95(3), 759-771.

Fentaw Abegaz and Ernst Wit (2013). Sparse time series chain graphical
models for reconstructing genetic networks. Biostatistics. 14, 3:
586-599.

Fentaw Abegaz and Ernst Wit (2014). SparseTSCGM: Sparse time series chain graphical
models. R package version 2.1.1. http://CRAN.R-project.org/package=SparseTSCGM

Rothman, A.J., Levina, E., and Zhu, J. (2010). Sparse multivariate
regression with covariance estimation. Journal of Computational and
Graphical Statistics. 19: 947-962.

Wild, B., Eichler, M., Friederich, H. C., Hartmann, M., Zipfel, S., &
Herzog, W. (2010). A graphical vector autoregressive modelling
approach to the analysis of electronic diary data. BMC medical
research methodology, 10(1), 28.
}
\author{
Sacha Epskamp <mail@sachaepskamp.com>
}

\examples{
# Simulate model:
Mod <- randomGVARmodel(4,probKappaEdge = 0.8,probBetaEdge = 0.8)

# Simulate data:
Data <- graphicalVARsim(100,Mod$beta,Mod$kappa)

# Estimate model:
Res <- graphicalVAR(Data, gamma = 0, nLambda = 5)


\dontrun{
# For more precision, run:
Res <- graphicalVAR(Data, gamma = 0)

# Plot results:
layout(t(1:2))
plot(Mod, "PCC", layout = "circle")
plot(Res, "PCC", layout = "circle")

plot(Mod, "PDC", layout = "circle")
plot(Res, "PDC", layout = "circle")
}
}

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top