Skip to contents

Estimate leave-future-out expected log predictive density for an STbayes model.

Usage

STb_lfo(
  lfo_type = c("parallel", "sequential"),
  fit,
  STb_data,
  stan_model,
  M,
  L,
  k_thres = 0.7,
  ...
)

Arguments

lfo_type

String specifying how future observations are left out. "parallel" predicts the next observations within each trial. "sequential" moves through trials sequentially.

fit

A fitted STbayes model object to use as the initial reference fit.

STb_data

A formatted STbayes data object returned by import_user_STb().

stan_model

Character string containing the Stan model code returned by generate_STb_model().

M

Integer of future observations to predict at each step.

L

Integer of observations to condition on before the first prediction/refit. This should be larger than the number of demonstrators.

k_thres

Numeric. Pareto-\(k\) threshold above which the model is refit. Defaults to 0.7.

...

Additional arguments passed to the model refitting step.

Value

An object with attributes:

pointwise

A data frame containing pointwise elpd_lfo and pareto_k values.

estimates

A named numeric vector containing summaries elpd_lfo, se_elpd_lfo, lfoic, and se_lfoic.

refits

Observation indices at which the model was refit.

Details

The function refits the model at selected points and uses Pareto-smoothed importance sampling between refits to approximate M-step-ahead predictive performance. Cross-validation can be done either within trials in parallel or sequentially through the full event sequence.