Thin results of running monty_sample(), reducing autocorrelation
between samples and saving space. This function may be useful
before running onward simulations, or before saving output to
disk.
Usage
monty_samples_thin(
samples,
thinning_factor = NULL,
burnin = NULL,
save_full_chains = FALSE
)Arguments
- samples
A
monty_samplesobject, from runningmonty_sample()- thinning_factor
Optional integer thinning factor. If given, then we save every
thinning_factor'th step. So ifthinning_factor = 2we save every second step, and if 10, we'd save every 10th. We will always include the last point in the chain, and exclude points counting backwards.- burnin
Number of steps to discard as burnin from the start of the chain.
- save_full_chains
Logical, indicating whether or not the full chains of the parameters (without discarding the burnin and thinning) should additionally be saved. This is useful if you are thinning to reduce the size of observations but still want to retain the full chains of the parameters for evaluation purposes.
Value
A monty_samples object (as for monty_sample()),
typically with fewer samples.
Limitations
Subsetting parameters ($pars) and density ($density) is easy
enough, but the main use of this function is subsetting chains
that have observations, otherwise you could simply cast to
samples_df and use functions from the posterior package.
We can only subset observations where the observer was able to tidy them up into a nice array for us. This will typically be the case (for example when using odin/dust, trajectories will be in a nice array).
More specifically, an array is "nice" if the last two dimensions
represent samples and chains; in that case we subset along the
samples dimension and leave everything else alone. For each
element of $observations that cannot be subsetted, we will issue
a warning.
We cannot generally subset "details", and will pass that along unmodified.
