
Construct a typed spec_ir statistical and simulation specification
Source: R/spec-ir.R
new_spec_ir.RdCreates a versioned S3 spec_ir object describing a statistical or Monte Carlo
simulation study. Missing subsections are populated with statistically sensible
defaults, and plain-language explanations are recorded in defaults_rationale.
Usage
new_spec_ir(
design_type = "monte_carlo_lm",
title = "Untitled Statistical Study",
description = "",
source_prompt = NULL,
tags = character(),
hierarchy = list(),
predictors = NULL,
predictor_corr = NULL,
outcome = list(),
effects = list(),
missingness = list(),
estimator = list(),
simulation = list(),
defaults_rationale = list(),
schema_version = SPEC_SCHEMA_VERSION,
validate = TRUE
)Arguments
- design_type
Character scalar, one of
spec_design_types().- title
Character scalar title for the specification.
- description
Character scalar description.
- source_prompt
Optional character scalar capturing the originating NL prompt.
Optional character vector of descriptive tags.
- hierarchy
Optional named list specifying data hierarchy (
levels,n_obs,n_clusters,cluster_size,cluster_name,unit_name,icc).- predictors
Optional list of predictor specifications (see
spec_predictor()).- predictor_corr
Optional numeric positive-definite correlation matrix of dimension
length(predictors) x length(predictors)specifying correlations among same-level predictors (defaults toNULLfor independent predictors).- outcome
Optional named list specifying
name,family,link, andresidual_sd.- effects
Optional named list specifying
intercept,fixed,focal_predictor, andrandom(intercept,intercept_sd,slopes,corr_matrix).- missingness
Optional named list specifying
mechanism("none","MCAR","MAR"),rate,target,auxiliary, andstrength.- estimator
Optional named list specifying
engine,reml,conf_level, andmissing_handling.- simulation
Optional named list specifying
n_reps,seed,alpha, andparameter_grid.- defaults_rationale
Optional named list mapping dotted IR paths to plain-language explanations of inferred defaults.
- schema_version
Character schema version (defaults to
"1.0.0").- validate
Logical; if
TRUE(default), validates the resulting IR withassert_valid_spec_ir().
Examples
spec <- new_spec_ir(
design_type = "multilevel_sim",
title = "School Achievement Study",
hierarchy = list(levels = 2L, n_clusters = 40L, cluster_size = 20L, icc = 0.2),
simulation = list(n_reps = 100L, seed = 42L)
)
print(spec)
#>
#> ── spec_ir v1.2.0 [valid] ──
#>
#> Title: School Achievement Study
#> Design: multilevel_sim | Estimator: lmer
#> Hierarchy: 2-level (40 clusters x 20 observations = 800 total; ICC = 0.2)
#> Outcome: y (gaussian, link = identity)
#> Predictors: x1 [L1, normal, beta=0.3]
#> Simulation: 100 reps | alpha = 0.05 | seed = 42 | grid: none