correlation_structure: Create a tidy correlation structure

View source: R/correlation.R

correlation_structureR Documentation

Create a tidy correlation structure

Description

Create a tidy correlation structure

Usage

correlation_structure(
  n_variables,
  rho = 0,
  structure = c("independent", "exchangeable", "ar1", "custom"),
  correlation = NULL,
  variable_names = NULL
)

Arguments

n_variables

Number of variables.

rho

Correlation coefficient used by exchangeable and AR(1) structures.

structure

Correlation structure: one of "independent", "exchangeable", "ar1", or "custom". If left unset it is chosen from the other arguments: "custom" when correlation is supplied, "exchangeable" when a non-zero rho is supplied, and "independent" otherwise. Passing "independent" together with a non-zero rho is a contradiction and raises a simulab_contradictory_structure error.

correlation

Custom correlation matrix.

variable_names

Optional variable names.

Value

A base data.frame with one row per matrix cell and columns row, column, and correlation.

Examples

correlation_structure(
  n_variables = 3,
  rho = 0.5,
  structure = "ar1"
)

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