API / Docstrings
UnfoldStats.calculate_ΣinvUnfoldStats.contained_or_equalUnfoldStats.cvMANOVAUnfoldStats.cvMANOVAUnfoldStats.extract_coefsUnfoldStats.extract_coefsUnfoldStats.extract_symbolUnfoldStats.get_predictor_string
UnfoldStats.calculate_Σinv — Method
calculate_Σinv(Ξ;λ=0.)Calculate the regularized inverse of the noise covariance matrix from the residuals Ξ, with optional regularization parameter λ. Regularization towards the diagonal is used, the Ledoit-Wolf shrinkage method.
Arguments
Ξ: The residuals, used to estimate the noise covariance (ch x time)λ: Regularization parameter for the noise covariance estimation (default: 0.0 - recommended to be quite small in 2014 paper)
UnfoldStats.contained_or_equal — Method
contained_or_equal(p, e)Test if p equals e or whether e contains p if e is a tuple.
UnfoldStats.cvMANOVA — Method
cvMANOVA(m,eeg)Arguments
m: A fitted UnfoldModel with aLinearModelFitCVmodelfit.eeg: EEG data used to estimate the noise covariance matrix from the training data (chan x time x trials). Subset if you only want to use e.g. the baseline.
UnfoldStats.cvMANOVA — Method
cvMANOVA(β_train,β_test,X_train,X_test,Y_train;C, C_test=C,λ=0.05)A function to perform cross-validated MANOVA (cvMANOVA) on the training and test estimates from a cross validated modelfit This function calculates the cvMANOVA D statistic for each time point based on the training and test estimates, the design matrices. It estimates the noise covariance matrix estimated from the given training data.
Arguments
β_train: The parameter estimates from the training data (chan, time, coeff).β_test: The parameter estimates from the test data (chan, time, coeff).X_train: The design matrix for the training data.X_test: The design matrix for the test data.Y_train: The observed data for the training set, used to estimate the noise covariance - subset if you only want to use e.g. the baseline.
Keyword Arguments
C: The contrast matrix for the training data (no default).C_test: The contrast matrix for the test data (default: same as C).λ: Regularization parameter for the noise covariance estimation (default: 0.0 - recommended to be quite small in 2014 paper)
UnfoldStats.extract_coefs — Method
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.
UnfoldStats.extract_coefs — Method
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.
UnfoldStats.extract_symbol — Method
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.
UnfoldStats.get_predictor_string — Method
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"