vlt.stats.get_lme_effect_sizes
GET_LME_EFFECT_SIZES Computes effect sizes for a Linear Mixed Effects model.
effectSizes = GET_LME_EFFECT_SIZES(lme) takes a fitted LinearMixedModel
object and returns a structure containing the raw Beta, Cohen's d
approximation, Standardized Beta, and N (number of observations) for
each fixed effect term.
ERROR CONDITION:
This function checks for interaction terms (e.g., 'A:B'). If any are
present, it throws an error as requested, because simple main effect
calculations are misleading in the presence of interactions.
METHODS / FORMULAS:
1. Cohen's d Approximation:
Measures the shift in the response variable relative to the raw
standard deviation of the data.
Formula: d = Beta / sigma_y
Where:
Beta = The estimated fixed effect coefficient (Raw Estimate).
sigma_y = The standard deviation of the response variable (y).
2. Standardized Beta (Beta_std):
Measures the change in the outcome (in standard deviations) for a
1 standard deviation change in the predictor.
Formula: Beta_std = Beta * (sigma_x / sigma_y)
Where:
sigma_x = The standard deviation of the specific column in the
fixed effects design matrix corresponding to that term.
(For categorical variables, this is the SD of the 0/1
dummy vector).
3. N (Number of Observations):
For binary/dummy terms (including Intercept), this is the count of
observations where the term is 1.
For continuous variables (or non-binary columns), this is the total
number of observations used in the model.
INPUT:
lme - A fitted LinearMixedModel object (from fitlme).
OUTPUT:
effectSizes - A structure containing vectors for:
.TermNames (Cell array of coefficient names)
.RawBeta (The original estimates)
.CohensD (The approximated Cohen's d)
.StdBeta (The standardized coefficients)
.N (The number of observations per level/term)
Example:
lme = fitlme(tbl, 'ReactionTime ~ Drug + (1|Subject)');
es = get_lme_effect_sizes(lme);