ols_cholesky: Estimate Contemporaneous Structural Effects

Description Usage Arguments Details Value Examples

View source: R/SVAR-2-estimation.R

Description

Estimate structural matrices By and Be by least squares or maximum likelihood.

Usage

1
2
3
ols_cholesky(Y, p)

mle_svar(Y, p, By, Be)

Arguments

Y

A (K x N+p) matrix carrying the data for estimation. There are N observations for each of the K variables with p pre-sample values.

p

An integer scalar. The lag length of the VAR(p) system.

By

A (K x K) matrix. Determines the contemporaneous relation between the endogeneous variables y_t. See examples and details below.

Be

A (K x K) matrix. Determines the contemporaneous impact of a structural shock e_t on the endogeneous variables y_t. See examples and details below.

Details

The two matrices By and Be refer to the instantaneous effects matrices in a vector autoregressive system

By * y_t = A_s(L) y_t + Be * e_t.

Thus, By describes the contemporaneous effects between the elements of y. Be describes the contemporaneous impact a structural error vector e_t has on y_t.

Value

The results may not necessarily be unique. The column sign, for example, could be indeterminate.

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
set.seed(8191)

# number of variables, observations and lag length
K <- 3
N <- 1E6
p <- 2

# prepare input
A <- cbind(matrix(0.1, K, K), matrix(-0.05, K, K)); diag(A) <- 0.4
Be <- matrix(0.4, K, K); Be[upper.tri(Be)] <- 0
Y0 <-matrix(0, nrow = K, ncol = p)
W <- matrix(rnorm(N * K), nrow = K, ncol = N)

# draw data and estimate Be
Y <- create_svar_data(A, Be, Y0, W)
Be_hat <- ols_cholesky(Y, p)
Be_hat
set.seed(8191)

K <- 3
N <- 1E6
p <- 2

A <- cbind(matrix(0.1, K, K), matrix(-0.05, K, K)); diag(A) <- 0.4
Be <- matrix(0.4, K, K); Be[upper.tri(Be)] <- 0
Y0 <-matrix(0, nrow = K, ncol = p)
W <- matrix(rnorm(N * K), nrow = K, ncol = N)

Y <- create_svar_data(A, Be, Y0, W)

By_init <- diag(K)
Be_init <- matrix(0, K, K)
Be_init[lower.tri(Be_init, diag = TRUE)] <- NA

mle_svar(Y, p, By_init, Be_init)

nielsaka/zeitreihe documentation built on March 17, 2020, 8:38 p.m.