UnfoldStats

Documentation for UnfoldStats.

UnfoldStats.extract_coefsMethod
extract_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.

source
UnfoldStats.extract_coefsMethod
extract_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.

source
UnfoldStats.extract_symbolMethod
extract_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.

source
UnfoldStats.get_predictor_stringMethod
get_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"
source