Learn R Programming

RSDC (version 1.1-2)

rsdc_forecast: Forecast Covariance/Correlation Paths from an RSDC Model

Description

Generates per-period correlation and covariance matrices from a fitted model: "const" (constant correlation), "noX" (fixed transition matrix), or "tvtp" (time-varying transition probabilities).

Usage

rsdc_forecast(
  method = c("tvtp", "noX", "const"),
  N,
  residuals,
  X = NULL,
  final_params,
  sigma_matrix,
  value_cols,
  out_of_sample = FALSE,
  control = list()
)

Value

smoothed_probs

\(N \times T^\ast\) smoothed probabilities ("noX"/"tvtp" only).

sigma_matrix

\(T^\ast \times K\) slice aligned to the forecast horizon.

cov_matrices

List of \(K \times K\) covariance matrices \(\Sigma_t = D_t R_t D_t\).

predicted_correlations

\(T^\ast \times \binom{K}{2}\) pairwise correlations in combn(K, 2) order.

BIC

Bayesian Information Criterion \(\mathrm{BIC} = \log(n)\,k - 2\,\ell\).

y

\(T^\ast \times K\) residual matrix aligned to the forecast horizon.

Arguments

method

Character. One of "tvtp", "noX", "const".

N

Integer. Number of regimes (ignored for "const").

residuals

Numeric matrix \(T \times K\) used to compute correlations or run the filter.

X

Optional numeric matrix \(T \times p\) (required for "tvtp").

final_params

List with fitted parameters (e.g., from rsdc_estimate): must include correlations, and either transition_matrix ("noX") or beta ("tvtp"); include log_likelihood for BIC computation.

sigma_matrix

Numeric matrix \(T \times K\) of forecasted standard deviations.

value_cols

Character/integer vector of columns in sigma_matrix that define asset order.

out_of_sample

Logical. If TRUE, use a fixed 70/30 split; otherwise use the whole sample.

control

Optional list; supports threshold (in (0,1), default 0.7).

Details

  • Forecast horizon: If out_of_sample = TRUE, filter on the first threshold fraction and forecast on the remainder.

  • Correlation paths:

    • "const" — empirical correlation of residuals, repeated across time.

    • "noX"/"tvtp" — smoothed-probability weighted average of regime correlations.

  • Covariance build: Reconstruct \(R_t\) from the pairwise vector (columns ordered by combn(K, 2)), set \(D_t = \mathrm{diag}(\sigma_{t,1},\dots,\sigma_{t,K})\), and \(\Sigma_t = D_t R_t D_t\).

  • BIC: Parameter count \(k\) is N * ncol(X) + N * K * (K - 1) / 2 for "tvtp", N * (N - 1) + N * K * (K - 1) / 2 for "noX", and K * (K - 1) / 2 for "const".

See Also

rsdc_hamilton, rsdc_estimate, rsdc_minvar, rsdc_maxdiv

Examples

Run this code
set.seed(123)
T <- 60; K <- 3; N <- 2
y <- scale(matrix(rnorm(T*K), T, K))
vols <- matrix(0.2 + 0.05*abs(sin(seq_len(T)/7)), T, K)
rho <- rbind(c(0.10, 0.05, 0.00), c(0.60, 0.40, 0.30))
Pfix <- matrix(c(0.9, 0.1, 0.2, 0.8), 2, 2, byrow = TRUE)
rsdc_forecast("noX", N, y, NULL,
              list(correlations = rho, transition_matrix = Pfix, log_likelihood = -200),
              vols, 1:K)

Run the code above in your browser using DataLab