Sample from the grid
Usage
sample_grid(
grid,
n_samples = 2000L,
prior_h = NULL,
prior_psi = c(0.25, 0.5, 0.25),
seed = NULL
)Arguments
- grid
A
data.framecontaining validated grid-cell summaries withCell, objective/nll,h,psi, and optionalm0/m10orfixed_m0/fixed_m10columns. A legacylistof fitted objects fromrun_grid()is also accepted for compatibility.- n_samples
Integer specifying the number of samples to draw from the grid. Default is
2000.- prior_h
Optional numeric prior weights for the unique steepness values. If
NULL, equal weights are used.- prior_psi
Optional numeric prior weights for the unique
psivalues. Default isc(0.25, 0.5, 0.25).- seed
Optional integer random seed for reproducible grid-cell sampling.
Value
A list with three elements:
- grid_cells
Integer
vectorof lengthn_samplesindicating which grid cells were sampled.- grid_freq
A
tibblesummarising the frequency of each grid cell in the sample, including columns forCell,nll,m0,m10,h,psi, andFreq.- grid_prob
A
tibblecontaining the sampling probabilities.
Details
The current data-frame route samples deterministic MLE cells using
relative likelihood and structural-prior weights. It is not the balanced
posterior-draw allocation used by grid_mcmc_to_tmbfit(). Supplying
seed calls set.seed() and does not restore the caller's prior
random-number state. The list-object route assumes the historical
direct-anchor M0/M10 parameterization and is retained only for
compatibility.
