1dSVAR: an R program for structural vector autoregression


Modeling strategy: structural vector auto-regressive (SVAR) analysis 

Connectivity analysis in FMRI data explores the interactions of brain regions under various perceptual, cognitive, and affective conditions. With a seed-based approach, we seek to identify regions that have causal relations with the seed. In an ROI-based connectivity analysis, causal effects of one region on another are inferred from a model of inter-regional interactions among a predetermined set of regions. In addition, some alternative models can be explored, cautiously, through model comparison and model search. Vector autoregression (VAR) and structural equation modeling (SEM) are two popular brain-network modeling tools. VAR (aka Granger causality analysis in the FMRI community), which is a data-driven approach, assumes that connected regions exert time-lagged influences on one another. In contrast, the hypothesis-driven SEM is used to validate an existing connectivity model where connected regions have contemporaneous interactions among them. We here propose a unified approach that models both lagged and contemporaneous effects under one framework. The unifying model, structural vector autoregression (SVAR), promises improved statistical and explanatory power, and avoids some prevalent pitfalls that can occur when VAR and SEM are utilized separately.

For more discussion, see Chen et al., Vector autoregression, structural equation modeling, and their synthesis in neuroimaging data analysis, Comput. Biol. Med. (2011), Volume 41, Issue 12, 1142-1155.


Program 1dSVAR

1dSVAR, a primary version written in R, currently adopts a data-driven approach for the lagged effects and model validation for the instantaneous effects. More specifically, the lagged effects are estimated in a similar way as vector autoregression (VAR) in 1dGC; with the instantaneous effects the user has to specify the connections and 1dSVAR will estimate the path strengths and confirm whether the data support the model. More modeling capabilities such as model comparison/search may be added in the future if desired. 

1dSVAR can be run on all major platforms such as unix-based systems and Windows, and requires R installation: 

Choose a mirror site geographically close to you, and download the appropriate binary for your platform (or the source code and then compile yourself). Set your path appropriately. For example, my R executable is under /Applications/R.app/Contents/MacOS on my Mac OS X, so I add /Applications/R.app/Contents/MacOS as one of the search paths in my C shell startup configuration file .cshrc

If the installation is successful, start the R interface with the following command on the prompt


You can also work with the GUI version of R on Mac OS and Windows.

1dSVAR.R should be already in the most recent version of AFNI package (say, under ~/abin/). 

If you know the directory (e.g., ~/abin/) 1dSVAR.R is in, launch it inside R by typing/copying, for example, 


If you are not sure about the location of 1dGC.R, copy the following into R (assuming 1dGC.R is under the same directory as the AFNI graphic viewer):

source(paste(strsplit(system('which afni', intern=TRUE), "afni")[[1]], "1dSVAR.R", sep=""))

or (assuming 1dGC.R is on one of the search paths)

source(Find(file.exists, file.path(strsplit(system("echo $PATH", intern=TRUE), "\\:")[[1]], "1dSVAR.R")))


1dSVAR.R works in a procedural or streamlined fashion with a string of inputs about parameters and options, and can run analysis at both individual subject and group levels. Hopefully anything else should be self-evident from there.

In case the program chokes because of failure on installing packages such as vars, network, tcltk, etc. for some reason, run the following commands in R:


To quit R, type


(or hit letter "d" while holding down CTRL key on UNIX-based systems).


Input data

Some suggestions about input files below might be too specific for FMRI data. Make proper adjustment if the program is used under other circumstances.

(1) All input data are assumed having a suffix of .1D in the AFNI convention, and they are typically time series at regions of interest (ROIs) and from covariates such as conditions/tasks of no interest, head motion and physiological noises). They should be structured in a pure text format of either multiple one-column files or one multi-column file.

(2) Header is NOT allowed in a one-column input file, but is optional for a multi-column input file: If provided in the first row, it has to be the labels of those ROIs/nodes, as the format of data frame in R. ROI time series as input are required, but covariates are optional. All ROI time series can be stored in one data frame, or multiple one-column files, but not a mixture. 

(3) The minimum pre-processing steps for the ROI time series include slice timing correction and volume registration. Spatial smoothing is typically recommended for noise reduction, but not mandatory. It is the change relative to the baseline that is comparable across blocks/runs, regions, and subjects, therefore signal normalization through scaling in terms of the loose concept of percent signal change is very important, and it can be done during the pre-processing, or you can leave it for 1dGC.R to handle.

(4) Any confounding effects are better entered as covariates in the causality model unless they are orthogonal to the autocorrelation present in the network, which is rarely true.

(5) Since the low frequencies (drifting effect including baseline) in the signal can be modeled with polynomials embedded in the causality model, it's NOT recommended to remove the trend (including baseline) during the pre-processing because of argument (4) above. You don't have to include the polynomial time series from the design matrix as covariates for input, but if you do decide to include them, disable the embedded option in the program by specifying an order of -1 for polynomials in the program.

(6) Covariates should be in separate file(s) from ROI time series files, and can be stripped from the design matrix of the individual subject regression analysis. All the ROI time series can be multiple one-column files or one multi-column file, but not a mixture of both formats. The same is true for covariates, but they don't have to be of the same format as the ROI files. All time series from ROI and covariates must have the same length and match up in temporal sequence. They can be data from multiple blocks and/or runs stitched together.

(7) If you want to censor out a few time points in the time series, create one covariate for each censored time point with the same length of the time series and with all 0's except putting a 1 at the censored time point.

(8) Input files for group analysis with mixed-effects meta-analysis are supposed to be path coefficients (plus corresponding t-statistics if available) saved from analysis at individual subject level.


I thank Patrick Brandt and Chris Sims for theoretical consultation, and Bernhard Pfaff for programming support.