predloglik: Evaluates the predictive log likelihood using the predicted...

View source: R/utilities_fsvdraws.R

predloglikR Documentation

Evaluates the predictive log likelihood using the predicted covariance matrix

Description

predloglik approximates the predictive log likelihood by simulating from the predictive distribution of the covariance matrix and evaluating the corresponding multivariate normal distribution.

Usage

predloglik(
  x,
  y,
  ahead = 1,
  each = 1,
  alldraws = FALSE,
  indicator = rep(TRUE, ncol(y))
)

Arguments

x

Object of class 'fsvdraws', usually resulting from a call to fsvsample.

y

Matrix of dimension length(ahead) times m where the predictive density should be evaluated.

ahead

Vector of timepoints, indicating how many steps to predict ahead.

each

Single integer (or coercible to such) indicating how often should be drawn from the posterior predictive distribution for each draw that has been stored during MCMC sampling.

alldraws

Should all the draws be returned or just the final results? (Can be useful to assess convergence.)

indicator

Logical vector of length m indicating which component series should be evaluated. The default is to evaluate all of them.

Value

Vector of length length(ahead) with log predictive likelihoods.

See Also

Uses predcov. If m is large but only few factors are used, consider also using predloglikWB.

Other predictors: predcond(), predcor(), predcov(), predh(), predloglikWB(), predprecWB()

Examples


set.seed(1)

# Simulate a time series of length 1100:
sim <- fsvsim(n = 1100, series = 3, factors = 1)
y <- sim$y

# Estimate using only 1000 days:
res <- fsvsample(y[seq_len(1000),], factors = 1)

# Evaluate the 1, 10, and 100 days ahead predictive log
# likelihood:
ahead <- c(1, 10, 100)
scores <- predloglik(res, y[1000+ahead,], ahead = ahead, each = 10)
print(scores)



factorstochvol documentation built on Nov. 24, 2023, 5:08 p.m.