Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for E_loo() #43

Open
nicholasjclark opened this issue Apr 9, 2024 · 1 comment
Open

Add support for E_loo() #43

nicholasjclark opened this issue Apr 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@nicholasjclark
Copy link
Owner

PSIS-LOO can be used to generated weighted expectations and predictions, valuable for asking what predictions we would get if high-leverage "outliers" were downweighted: https://paul-buerkner.github.io/brms/reference/loo_predict.brmsfit.html.

@nicholasjclark nicholasjclark added the enhancement New feature or request label Apr 9, 2024
@nicholasjclark
Copy link
Owner Author

Need to also update loo.mvgam to use posterior predictions rather than the draws generated from Stan. This is better for getting a less biased view of model fit, particularly for highly flexible AR / RW models:

loo_hcs = function(x, ...){
  x$series_names <- levels(x$obs_data$series)
  logliks <- logLik(x, 
                    linpreds = predict(x,
                                       newdata = x$obs_data,
                                       type = 'link',
                                       summary = FALSE,
                                       process_error = TRUE),
                    newdata = x$obs_data,
                    family_pars = mvgam:::extract_family_pars(x))
  logliks <- logliks[,!apply(logliks, 2, function(x) all(!is.finite(x)))]
  releffs <- loo::relative_eff(exp(logliks),
                               chain_id = sort(rep(1:x$model_output@sim$chains,
                                                   (NROW(logliks) /
                                                      x$model_output@sim$chains))))
  loo::loo(logliks, r_eff = releffs, ...)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant