View source: R/CCMnet_theoretical_check.R
| sample_theoretical | R Documentation |
This function draws samples directly from the target probability distributions
specified in a ccm_sample object. These samples serve as a "ground truth"
to evaluate whether the MCMC chain has converged to the intended target.
sample_theoretical(object, n_sim = nrow(object$mcmc_stats))
object |
An object of class |
n_sim |
Integer. The number of independent samples to draw from the theoretical target distributions. Default is equal to the number of CCM samples. |
This function performs direct i.i.d. sampling (e.g., using rpois,
rnorm, etc.) based on the parameters stored in the ccm_sample
object. It does not use MCMC. The resulting samples are used by
plot.ccm_sample when include_theoretical = TRUE is specified.
The input ccm_sample object with the theoretical slot
populated. This slot contains a data frame of statistics sampled directly
from the target distributions.
# 1. Generate MCMC samples
ccm_sample <- sample_ccm(
network_stats = "edges",
prob_distr = "poisson",
prob_distr_params = list(list(350)),
population = 50
)
# 2. Generate theoretical samples for comparison
ccm_sample <- sample_theoretical(ccm_sample, n_sim = 1000)
# 3. Compare MCMC to theoretical target
plot(ccm_sample, stats = "edges", type = "hist", include_theoretical = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.