View source: R/VAR-2-estimation.R
Gradient of VAR reduced-form log-likelihood
1 | gradient_var_init(Y, p)
|
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.