Construct the appropriate brmsformula used internally by
testing_through_time, depending on the response distribution
(Gaussian vs. Binomial), whether a categorical predictor is provided, the
multilevel mode ("summary" vs. "group"), and the chosen random/varying
effects structure.
Arguments
- family
A family object describing the response distribution. Must be either
gaussian()orbinomial()(as used intesting_through_time).- multilevel
Character; which model family to build. One of
"summary"(participant-level varying effects) or"group"(population-level GAM without varying effects).- predictor_type
Character; type of predictor. One of
"none","categorical", or"continuous".- within_between
Character; only used when
predictor_type = "categorical"andmultilevel = "summary". Must be one of"within-subject"or"between-subject"to determine whether to include a varying slope(1 + predictor | participant)or only(1 | participant).- kvalue
Numeric; basis dimension
kused ins(time, ..., k = kvalue).- bs
Character; spline basis used in
s(time, bs = bs, ...)(e.g.,"tp").- include_ar_term
Logical; if
TRUE, adds an AR(1) autocorrelation structure within participant via .autocor = brms::ar(time = "time", gr = "participant", p = 1, cov = FALSE).- varying_smooth
Logical; if
TRUE(default), add a factor-smooth interactions(participant, time, bs = "fs", ...)inmultilevel = "summary"models. IfFALSE, only include the intercept/slope varying effects.- include_by_smooth
Logical; if
TRUE(default) andpredictor_type = "categorical", the time smooth is specified withby = predictor.- use_se
Logical; whether to include known or internally computed measurement error via
y | se(outcome_sd)in the model formula.
Value
A brmsformula object.
Details
The function assumes that the data passed to brm() has already been
reshaped to use the internal column names expected by testing_through_time:
time, participant, predictor (optional), and one of
outcome_mean / outcome_sd (Gaussian) or success / trials
(Binomial).
Examples
if (FALSE) { # \dontrun{
# Gaussian, summary, no predictor
make_bgam_formula(
family = gaussian(),
multilevel = "summary",
predictor_type = "none",
kvalue = 20, bs = "tp"
)
# Binomial, summary, within-subject predictor
make_bgam_formula(
family = binomial(),
multilevel = "summary",
predictor_type = "categorical",
within_between = "within-subject",
kvalue = 20, bs = "tp"
)
} # }
