Skip to content

Commit

Permalink
fix bug in extraction of Sigma draws for stability calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Clark committed Oct 1, 2024
1 parent a51df94 commit 0251634
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/stability.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ stability.mvgam = function(object, ...){
}

# Take posterior draws of the interaction matrix
B_post <- as.matrix(object, variable = 'A', regex = TRUE)
B_post <- mcmc_chains(object$model_output, 'A')

# Take posterior draws of Sigma
Sigma_post <- as.matrix(object, variable = 'Sigma', regex = TRUE)
Sigma_post <- mcmc_chains(object$model_output, 'Sigma')

# Number of series in the VAR process
n_series <- object$n_lv
Expand All @@ -204,13 +204,15 @@ stability.mvgam = function(object, ...){

B <- matrix(B_post[i,],
nrow = n_series,
ncol = n_series)
ncol = n_series,
byrow = TRUE)
p <- dim(B)[1]

# If we want to get the variance of the stationary distribution (Sigma_inf)
Sigma <- matrix(Sigma_post[i,],
nrow = n_series,
ncol = n_series)
ncol = n_series,
byrow = TRUE)
vecS_inf <- solve(diag(p * p) - kronecker(B, B)) %*% as.vector(Sigma)
Sigma_inf <- matrix(vecS_inf, nrow = p)

Expand Down
Binary file modified src/RcppExports.o
Binary file not shown.
Binary file modified src/mvgam.dll
Binary file not shown.
Binary file modified src/trend_funs.o
Binary file not shown.

0 comments on commit 0251634

Please sign in to comment.