lfo: Leave-Future-Out Cross-Validation

Description Usage Arguments Details Value References Examples

View source: R/lfo.R

Description

Estimates the leave-future-out (LFO) information criterion for walker and walker_glm models.

Usage

1
lfo(object, L, exact = FALSE, verbose = TRUE, k_thres = 0.7)

Arguments

object

Output of walker or walker_glm.

L

Positive integer defining how many observations should be used for the initial fit.

exact

If TRUE, computes exact 1-step predictions by re-estimating the model repeatedly. If FALSE (default), uses approximate method based on Bürkner, Gabry and Vehtari (2020).

verbose

If TRUE (default), print the progress of the LFO computations to the console.

k_thres

Threshold for the pareto k estimate triggering refit. Default is 0.7.

Details

The LFO for non-Gaussian models is (currently) based on the corresponding Gaussian approximation and not the importance sampling corrected true posterior.

Value

List with components ELPD (Expected log predictive density), ELPDs (observation-specific ELPDs), ks (Pareto k values in case of approximation was used), and refits (time points where model was re-estimated)

References

Paul-Christian Bürkner, Jonah Gabry & Aki Vehtari (2020). Approximate leave-future-out cross-validation for Bayesian time series models, Journal of Statistical Computation and Simulation, 90:14, 2499-2523, DOI: 10.1080/00949655.2020.1783262.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
fit <- walker(Nile ~ -1 + 
  rw1(~ 1, 
    beta = c(1000, 100), 
    sigma = c(2, 0.001)), 
  sigma_y_prior = c(2, 0.005), 
  iter = 2000, chains = 1)
 
fit_lfo <- lfo(fit, L = 20, exact = FALSE)
fit_lfo$ELPD

## End(Not run)

walker documentation built on Sept. 11, 2021, 9:07 a.m.