block_correlation: Create clustered-period correlation structures

View source: R/correlation.R

block_correlationR Documentation

Create clustered-period correlation structures

Description

Create clustered-period correlation structures

Usage

block_correlation(
  n_individuals,
  n_periods,
  within_period,
  between_period = 0,
  within_individual = NULL,
  decay = NULL,
  design = c("cross_sectional", "cohort"),
  n_clusters = 1L
)

Arguments

n_individuals

Individuals per period. Supply one value, one value per cluster, or one value per cluster-period combination.

n_periods

Number of periods.

within_period

Correlation between different individuals in the same period.

between_period

Correlation between different individuals in different periods for an exchangeable structure.

within_individual

Correlation for the same individual across periods in a cohort design.

decay

Optional period-to-period correlation decay. Supplying this selects a decay structure.

design

Cross-sectional or closed-cohort design.

n_clusters

Number of cluster-specific structures.

Value

A base data.frame with one row per cluster and correlation-matrix cell, and columns row, column, correlation and cluster. The row and column labels are of the form ⁠period_<p>_unit_<u>⁠.

Examples

block_correlation(
  n_individuals = 3,
  n_periods = 4,
  within_period = 0.3,
  between_period = 0.1,
  design = "cross_sectional"
)

simulab documentation built on Oct. 15, 2026, 5:08 p.m.