Learn R Programming

CCMnet (version 0.1.4)

sample_ccm: Fit a Congruence Class Model (CCM)

Description

sample_ccm fits a Congruence Class Model using an MCMC framework to sample networks that match specific topological property distributions. It facilitates sampling based on specified network statistics (e.g., edges, degree distribution, mixing patterns) and their associated probability distributions.

Usage

sample_ccm(
  network_stats,
  prob_distr,
  prob_distr_params,
  population,
  sample_size = 1000L,
  burnin = 200000L,
  interval = 1000L,
  cov_pattern = NULL,
  initial_g = NULL,
  use_initial_g = FALSE,
  partial_network = as.integer(0),
  obs_nodes = NULL,
  Obs_stats = NULL,
  remove_var_last_entry = FALSE,
  stats_only = TRUE
)

Value

An object of class ccm_sample containing:

  • mcmc_stats: A data frame of sampled network statistics.

  • population: The number of nodes in the network.

  • prob_distr: The distributions used for constraints.

  • prob_distr_params: Parameters used for the constraints.

  • network_stats: The names of the statistics constrained.

  • cov_pattern: The covariate pattern used.

  • theoretical: Theoretical distribution values, if calculated.

  • g: A list of sampled graphs.

Arguments

network_stats

Character vector of statistic names to be constrained (e.g., "edges", "degree", "density").

prob_distr

Character vector of probability distribution names corresponding to each statistic.

prob_distr_params

List of parameter sets for each specified distribution.

population

Integer. The number of nodes in the network.

sample_size

Integer. Number of MCMC samples to return. Default is 1000.

burnin

Integer. Number of MCMC iterations to discard before sampling begins. Default is 200,000.

interval

Integer. Thinning interval (number of iterations between samples). Default is 1000.

cov_pattern

Integer vector. Optional group labels or covariate patterns for nodes.

initial_g

An igraph object. The starting graph for the MCMC chain.

use_initial_g

Logical. If TRUE, the MCMC chain starts from initial_g.

partial_network

Integer. Reserved for future use in partial network observation.

obs_nodes

Integer vector. Reserved for future use in specifying observed nodes.

Obs_stats

Character vector of additional network statistics to monitor during sampling.

remove_var_last_entry

Logical. If TRUE, removes the variance constraint from the last entry of the distribution.

stats_only

Logical. If TRUE, only sufficient statistics are returned; otherwise, network objects are included.

Examples

Run this code
# Basic sampling of a random graph with an edge constraint
ccm_sample <- sample_ccm(
  network_stats = list("edges"),
  prob_distr = list("poisson"),
  prob_distr_params = list(list(350)),
  population = 50 
)
summary(ccm_sample)
plot(ccm_sample, stats = "edges", type = "hist")

Run the code above in your browser using DataLab