Description Usage Arguments Details Value Author(s) References Examples
This function generates a single-level dataset with given parameters.
1 | sim.data.ts.single(n, Z, A, B, C, Sigma, W, Delta = NULL, p = NULL, nburn = 100)
|
n |
an integer indicating the length of the time series. |
Z |
a vector of treatment/exposure assignment at each time point. |
A |
a numeric value of model coefficient. |
B |
a numeric value of model coefficient. |
C |
a numeric value of model coefficient. |
Sigma |
a 2 by 2 matrix, is the covariance matrix of the two Gaussian white noise processes. |
W |
a 2p by 2 matrix, is the transition matrix. |
Delta |
a 2 by 2 matrix, is the covariance matrix of the initial condition. Default is |
p |
a numeric value indicating the order of the vector autoregressive (VAR) model. Default is |
nburn |
a integer indicating the number of burning sample. Default is 100. |
The single level GMA model is
M_{t}=Z_{t}A+E_{1t},
R_{t}=Z_{t}C+M_{t}B+E_{2t},
and for stochastic processes (E_{1t},E_{2t}),
E_{1t}=∑_{j=1}^{p}ω_{11_{j}}E_{1,t-j}+∑_{j=1}^{p}ω_{21_{j}}E_{2,t-j}+ε_{1t},
E_{2t}=∑_{j=1}^{p}ω_{12_{j}}E_{1,t-j}+∑_{j=1}^{p}ω_{22_{j}}E_{2,t-j}+ε_{2t}.
Sigma
is the covariance matrix of the Gaussian white noise (ε_{1t},ε_{2t}), and Delta
is the covariance matrix of (ε_{10},ε_{20}). W
is the transition matrix with element ω's.
The function returns a list with two data frames. One is the data with variables Z
, M
and R
; one is the data frame of (E_{1t},E_{2t}).
Yi Zhao, Brown University, zhaoyi1026@gmail.com; Xi Luo, Brown University, xi.rossi.luo@gmail.com
Zhao, Y., & Luo, X. (2017). Granger Mediation Analysis of Multiple Time Series with an Application to fMRI. arXiv preprint arXiv:1709.05328.
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 | ###################################################
# Generate a single-level dataset
# covariance matrix of errors
delta<-0.5
Sigma<-matrix(c(1,2*delta,2*delta,4),2,2)
# model coefficients
A0<-0.5
B0<--1
C0<-0.5
# number of time points
n<-500
# generate a treatment assignment vector
set.seed(1000)
Z<-matrix(rbinom(n,size=1,prob=0.5),n,1)
# VAR(1) model
p<-1
# Delta and W matrices
Delta<-matrix(c(2,delta*sqrt(2*8),delta*sqrt(2*8),8),2,2)
W<-matrix(c(-0.809,0.154,-0.618,-0.5),2,2)
# number of burning samples
nburn<-1000
set.seed(1000)
data.single<-sim.data.ts.single(n,Z,A0,B0,C0,Sigma,W,Delta,p=p,nburn=nburn)
###################################################
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.