GHRtools
  • Home
  • data4health
    • Overview
  • clim4health
    • Overview
  • GHRexplore
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
  • GHRmodel
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
    • Covariate structures
    • DLNMs in GHRmodel
  • GHRpredict
    • Overview
  • About GHR

On this page

  • Sample from the Posterior Predictive Distribution
    • Description
    • Arguments
    • Returns
    • Examples

Sample from the Posterior Predictive Distribution

Description

This function refits a specified model from a GHRmodels object and generates samples from its posterior predictive distribution.

sample_ppd(models, mod_id, s = 1000, nthreads = 8)

Arguments

  • models: A GHRmodels object.
  • mod_id: Character; model identifier (from models$mod_gof$model_id).
  • s: An integer specifying the number of samples to draw from the posterior predictive distribution.
  • nthreads: An integer specifying the number of threads for parallel computation to refit the model. Default is 8.

Returns

A data.frame containing columns for each of the posterior predictive samples and one column with observed data.

Examples

## Not run:


# Load example GHRmodels object from the package: 
model_list_file <- system.file("examples", "model_list.rds", package = "GHRmodel")
model_list <- readRDS(model_list_file)

# Generate 1000 samples from the posterior predictive distribution of model 3.
ppd_df <- sample_ppd( 
  model_list,
  mod_id = "mod3", 
  s = 1000,
  nthreads = 2)
## End(Not run)

Copyright 2025, GHR