sample_theoretical: Generate Samples from Target Distributions

View source: R/CCMnet_theoretical_check.R

sample_theoreticalR Documentation

Generate Samples from Target Distributions

Description

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.

Usage

sample_theoretical(object, n_sim = nrow(object$mcmc_stats))

Arguments

object

An object of class ccm_sample generated by sample_ccm.

n_sim

Integer. The number of independent samples to draw from the theoretical target distributions. Default is equal to the number of CCM samples.

Details

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.

Value

The input ccm_sample object with the theoretical slot populated. This slot contains a data frame of statistics sampled directly from the target distributions.

Examples

# 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)


CCMnet documentation built on March 2, 2026, 9:06 a.m.