Skip to contents

Produces deterministic R formula, plain-text, and LaTeX mathematical representations of a validated spec_ir specification (including two-way and cross-level interactions, unbalanced cluster sizes, and heavy-tailed or skewed error distributions) for display in dynamic Shiny previews and Quarto reports.

Usage

spec_to_math(spec)

Arguments

spec

A valid spec_ir object.

Value

A named list with elements formula, text, and latex.

Examples

spec <- new_spec_ir(
  design_type = "multilevel_sim",
  hierarchy = list(levels = 2L, n_clusters = 50L, cluster_size = 20L, icc = 0.2)
)
spec_to_math(spec)
#> $formula
#> [1] "y ~ x1 + (1 | cluster)"
#> 
#> $text
#> [1] "Model: y ~ x1 + (1 | cluster) (gaussian, identity link)\nStructure: 2-level (50 clusters x 20 observations, expected N = 1000, ICC = 0.20) | Estimator: lmer\nFocal term: x1 (beta = 0.3) | Complete data (no missingness)"
#> 
#> $latex
#> [1] "\\begin{aligned}\n\\text{y}_{ij} &= \\beta_0 + \\beta_{1}\\,\\text{x1}_{ij} + u_{0j} + \\varepsilon_{ij}, \\quad \\varepsilon_{ij} \\sim \\mathcal{N}(0, 1^2) \\\\\nu_{0j} &\\sim \\mathcal{N}(0, 0.5^2) \\quad (\\text{ICC} = 0.2, \\; J = 50, \\; n_j = 20) \\\\\n\\text{Parameters:} &\\quad \\beta_0 = 0, \\; \\beta_{1} = 0.3\n\\end{aligned}"
#>