sim.data.ts.two: Generate two-level simulation data

Description Usage Arguments Details Value Author(s) References Examples

Description

This function generates a two-level dataset with given parameters.

Usage

1
2
sim.data.ts.two(Z.list, N, theta, Sigma, W, Delta = NULL, p = NULL, 
  Lambda = diag(rep(1, 3)), nburn = 100)

Arguments

Z.list

a list of data. Each list is a vector containing the treatment/exposure assignment at each time point for the subject.

N

an integer, indicates the number of subjects.

theta

a vector of length 3, contains the population level causal effect coefficients.

Sigma

a 2 by 2 matrix, is the covariance matrix of the two Gaussian white noise processes in the single level model.

W

a 2p by 2 matrix, is the transition matrix in the single level model.

Delta

a 2 by 2 matrix, is the covariance matrix of the initial condition in the single level model. Default is NULL, will be the same as Sigma.

p

an integer, indicates the order of the vector autoregressive (VAR) model in the single level model. Default is NULL, will be calculated based on W.

Lambda

the covariance matrix of the model errors in the linear model of the model coefficients. Default is a 3 by 3 identity matrix.

nburn

a integer indicating the number of burning sample in the single level model. Default is 100.

Details

For the time series of length n_{i} of subject i, the single level GMA model is

M_{i_{t}}=Z_{i_{t}}A_{i}+E_{i_{1t}},

R_{i_{t}}=Z_{i_{t}}C_{i}+M_{i_{t}}B_{i}+E_{i_{2t}},

and

E_{i_{1t}}=∑_{j=1}^{p}ω_{i_{11_{j}}}E_{i_{1,t-j}}+∑_{j=1}^{p}ω_{i_{21_{j}}}E_{i_{2,t-j}}+ε_{i_{1t}},

E_{i_{2t}}=∑_{j=1}^{p}ω_{i_{12_{j}}}E_{i_{1,t-j}}+∑_{j=1}^{p}ω_{i_{22_{j}}}E_{i_{2,t-j}}+ε_{i_{2t}},

where Sigma is the covariance matrix of (ε_{i_{1t}},ε_{i_{2t}}) (for simplicity, Sigma is the same across subjects). For coefficients A_{i}, B_{i} and C_{i}, we assume a multivariate regression model. The model errors are from a trivariate normal distribution with mean zero and covariance Lambda.

Value

data

a list of data. Each list is a data frame of (Z_{t},M_{t},R_{t}).

error

a list of data. Each list is a data frame of (E_{1t},E_{2t}).

A

a vector of length N, the value of As.

B

a vector of length N, the value of Bs.

C

a vector of length N, the value of Cs.

type

a character indicates the type of the dataset.

Author(s)

Yi Zhao, Brown University, zhaoyi1026@gmail.com; Xi Luo, Brown University, xi.rossi.luo@gmail.com

References

Zhao, Y., & Luo, X. (2017). Granger Mediation Analysis of Multiple Time Series with an Application to fMRI. arXiv preprint arXiv:1709.05328.

Examples

 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
33
34
35
36
37
38
39
40
41
42
43
###################################################
# Generate a two-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

theta<-c(A0,B0,C0)

# number of time points
N<-50
set.seed(2000)
n<-matrix(rpois(N,100),N,1)

# treatment assignment list
set.seed(1000)
Z.list<-list()
for(i in 1:N)
{
  Z.list[[i]]<-matrix(rbinom(n[i,1],size=1,prob=0.5),n[i,1],1)
}

# Lambda
Lambda<-diag(0.5,3)

# 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(2000)
# data2<-sim.data.ts.two(Z.list,N,theta=theta,Sigma,W,Delta,p,Lambda,nburn)
###################################################

gma documentation built on May 2, 2019, 6:08 a.m.