Skip to contents

Helper constructor for defining a single predictor entry inside a new_spec_ir() specification.

Usage

spec_predictor(
  name,
  level = 1L,
  distribution = c("normal", "binary", "uniform", "time"),
  mean = NULL,
  sd = NULL,
  prob = NULL,
  min = NULL,
  max = NULL,
  centering = c("none", "grand_mean", "group_mean"),
  role = c("covariate", "focal", "treatment")
)

Arguments

name

Character scalar giving a valid R identifier for the predictor.

level

Integer scalar (1L or 2L) indicating the hierarchy level.

distribution

One of "normal", "binary", "uniform", or "time" (for wave-indexed longitudinal time predictors).

mean

Numeric mean for "normal" predictors (defaults to 0).

sd

Positive numeric SD for "normal" predictors (defaults to 1).

prob

Numeric probability in (0, 1) for "binary" predictors (defaults to 0.5).

min

Numeric lower bound for "uniform" predictors (defaults to 0).

max

Numeric upper bound for "uniform" predictors (defaults to 1).

centering

One of "none", "grand_mean", or "group_mean".

role

One of "covariate", "focal", or "treatment".

Value

A named list representing a predictor specification.

Examples

spec_predictor("x1", level = 1L, distribution = "normal", mean = 0, sd = 1)
#> $name
#> [1] "x1"
#> 
#> $level
#> [1] 1
#> 
#> $distribution
#> [1] "normal"
#> 
#> $mean
#> [1] 0
#> 
#> $sd
#> [1] 1
#> 
#> $prob
#> NULL
#> 
#> $min
#> NULL
#> 
#> $max
#> NULL
#> 
#> $centering
#> [1] "none"
#> 
#> $role
#> [1] "covariate"
#> 
spec_predictor("trt", level = 2L, distribution = "binary", prob = 0.5, role = "treatment")
#> $name
#> [1] "trt"
#> 
#> $level
#> [1] 2
#> 
#> $distribution
#> [1] "binary"
#> 
#> $mean
#> NULL
#> 
#> $sd
#> NULL
#> 
#> $prob
#> [1] 0.5
#> 
#> $min
#> NULL
#> 
#> $max
#> NULL
#> 
#> $centering
#> [1] "none"
#> 
#> $role
#> [1] "treatment"
#>