SHGInterface: SHGInterface

SHGInterfaceR Documentation

SHGInterface

Description

The SHG Interface class provides an Rcpp interface to the Smoking History Generator (SHG)

Details

SHGInterface Class

Value

An SHGInterface reference object (R6-style external pointer) wrapping the C++ simulation engine. Configure fields, then call simulation methods such as runSimFromFixedValues or runSimFromDataFrame; use getConfig / useConfig for settings and shg_load_params (via load_params()) for parameter bundles.

Fields

number_of_segments

Number of segments to use for simulation. Use -1 for auto-calculation (default), 1 for single segment, or N > 1 for explicit segment count. Auto-calculation uses: min(cores * 10, repeat / 1000). Note: MersenneTwister RNG is restricted to 1 segment.

num_threads

Thread count: -1 = auto (all cores, multi-threaded), 1 = single-threaded, N = use N threads. Default: -1. Note: MersenneTwister RNG requires num_threads = 1.

rng_strategy

'RngStream' for MRG32k3a (default) or 'MersenneTwister' for Mersenne Twister RNG. 'RngStream' is recommended for reproducibility especially with multi-threaded simulations. Note: MersenneTwister RNG is restricted to single-segment, non-parallel execution due to limitations in maintaining IID properties across segments.

input_data_folder

Set or get the base folder for input data files

initiation_filename

Set or get the initiation filename

cessation_filename

Set or get the cessation filename

mortality_filename

Set or get the mortality probabilities filename (e.g. acm.csv or ocm-excl-lung-cancer.csv)

smok_params_source

URL or local path of the last load_params() smoking zip (empty if unset)

mort_params_source

URL or local path of the last load_params() mortality zip (empty if unset)

mort_params_type

Mortality table from last load_params(): acm or ocm (empty if unset)

params_cache_dir

Read-only. Directory where load_params() stores extracted bundles (same as shg_params_cache_dir()). Delete this folder to clear the cache manually.

cpd_filename

Set or get the cpd filename

immediate_cessation_year

Set or get Immediate Cessation Year; If 0, no immediate cessation

mt_seeds

Set or get MersenneTwister seeds. Must be a numeric vector of exactly 4 values (one for each stream: initiation, cessation, life table, individual). If not set, default seeds are used. Only used when rng_strategy is "MersenneTwister".

rngstream_seed

Set or get RngStream seed. Must be a numeric vector of exactly 6 values (a single seed vector that generates 4 substreams, one for each stream: initiation, cessation, life table, individual). If not set, default seed is used. Only used when rng_strategy is "RngStream".


SmokingHistoryGenerator documentation built on June 13, 2026, 1:08 a.m.