UnfoldStats
Documentation for UnfoldStats.
UnfoldStats.contained_or_equal
UnfoldStats.extract_coefs
UnfoldStats.extract_coefs
UnfoldStats.extract_symbol
UnfoldStats.get_predictor_string
UnfoldStats.contained_or_equal
— Methodcontained_or_equal(p, e)
Test if p
equals e
or whether e
contains p
if e
is a tuple.
UnfoldStats.extract_coefs
— Methodextract_coefs(model::UnfoldModel, predictor, basisname)
Return the coefficients of an Unfold model for a certain predictor
and basisname
.
For extracting the terms of a predictor variable predictor
must be a symbol e.g. :continuous. For extracting the intercept predictor
should be a String, i.e. "(Intercept)".
basisname
must match one of the basis names which can be found in coeftable(model)
.
Note: If a predictor variable has more than one term in the formula (e.g. a spline set, a categorical variable with several levels or an interaction), the coefficients for all terms are returned.
The dimensions of the returned coefficients are channel x times x coefficients.
UnfoldStats.extract_coefs
— Methodextract_coefs(models::Vector{<:UnfoldModel}, predictor, basisname)
When applied to a vector of Unfold models, extracts the coefficients (matching the predictor and basisname) for all models (usually subjects) and concatenates them.
The dimensions of the returned coefficients are channel x times x coefficients x subjects.
UnfoldStats.extract_symbol
— Methodextract_symbol(t::AbstractTerm)
Return the symbol(s) underlying a term from a model formula, repeated by their actual coefficient number (after StatsModels.apply_schema).
Examples
julia> f = @formula 0 ~ 1 + spl(continuous, 4) + continuous + condition + pet + condition & pet
julia> ... # apply schema using an event dataframe, according to StatsModels
julia> extract_symbol(f)
8-element Vector{Any}:
"(Intercept)"
:continuous
:continuous
:continuous
:continuous
:condition
:pet
(:condition, :pet)
We get the actual symbols of each predictor - this is different to a function that would return the symbol for each term, which would be ["(Intercept)", :continuous,:continuous,:condition,:pet,(:condition,:pet) ]
The difference between those two cases would get even more stark, if a basisfunction is in play as it timeexpand terms into many more predictors.
UnfoldStats.get_predictor_string
— Methodget_predictor_string(p)
Return string representation based on the type of p
.
This function is used for a useful display of variables e.g. in an error message.
Examples
julia> UnfoldStats.get_predictor_string(:condition)
":condition"