gradient_var_init: Gradient of VAR reduced-form log-likelihood

Description Usage Examples

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

Description

Gradient of VAR reduced-form log-likelihood

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
set.seed(8191)

N <- 1E4
K <- 1
p <- 1

A  <- matrix(0.1, K, K * p); diag(A) <- 0.4
Y0 <- matrix(0, K, p)
U <- matrix(rnorm(N * K), K, N)

Y <- create_varp_data(A = A, Y0 = Y0, U = U)

gradient <- gradient_var_init(Y, p)

args <- c(mu = rep(0, K), a = vec(A), s = vech(diag(K)))
gradient(args)

ols_fit <- ols_mv(Y, p, const = TRUE)

ols_args <- c(mu = ols_fit$BETA.hat[, 1],
          a = ols_fit$BETA.hat[, -1],
          s = c(vech(ols_fit$SIGMA.hat)) * (N - 1 - K * p) / N)
gradient(ols_args)

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