eval_pred_dens | R Documentation |
eval_pred_dens
evaluates the one-step ahead predictive density of a fitted TVP model resulting from a call to
shrinkTVP at the points supplied in x
. For details on the approximation of the one-step ahead predictive density used,
see the vignette.
eval_pred_dens(x, mod, data_test, log = FALSE)
x |
a real number or a vector of real numbers, taken to be the points at which the predictive density will be evaluated. |
mod |
an object of class |
data_test |
a data frame with one row, containing the one-step ahead covariates. The names of the covariates have to match the
names of the covariates used during model estimation in the call to |
log |
a single logical value determining whether the density should be evaluated on the log scale or not. |
The value returned is a vector of length length(x)
, containing the values of the predictive density evaluated
at the points supplied in x
.
Peter Knaus peter.knaus@wu.ac.at
Other prediction functions:
LPDS()
,
fitted.shrinkTVP()
,
forecast_shrinkTVP()
,
predict.shrinkTVP()
,
residuals.shrinkTVP()
# Simulate data
set.seed(123)
sim <- simTVP(theta = c(0.2, 0, 0), beta_mean = c(1.5, -0.3, 0))
data <- sim$data
# Estimate model
res <- shrinkTVP(y ~ x1 + x2, data = data[1:199, ])
# Create sequence of x values where the density is to be evaluated
x_vals <- seq(0, 12, by = 0.1)
# Evaluate density and plot
dens <- eval_pred_dens(x_vals, res, data[200, ])
plot(x_vals, dens, type = "l")
# Add vertical line where true value of the one-step ahead y lies
abline(v = data$y[200])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.