Hi Gabrielle,
When using fitrm in MATLAB to fit a repeated measures model, handling missing data is an important consideration. MATLAB's fitrm function can handle missing data to some extent, but it's crucial to understand how it affects your results and what assumptions are being made.
Handling Missing Data:
- Listwise Deletion: By default, fitrm uses listwise deletion for rows with any missing data in the response variables. This means that if any of the response variables (var_t1 to var_t4) have missing values for a particular observation, that entire observation will be excluded from the analysis.
- Impact on Results: If missing data is not missing completely at random (MCAR), listwise deletion can introduce bias. It's important to consider the mechanism of missingness and whether the missing data might skew your results.
Example code:
% Define the within-subject factor
Time = table([1; 2; 3; 4], 'VariableNames', {'Time'});
% Fit the repeated measures model
rm = fitrm(dataTable, 'var_t1-var_t4 ~ Grouping1 + Grouping2 + Gender + Age + BMI', 'WithinDesign', Time);
% Display the results
ranovatbl = ranova(rm);
disp(ranovatbl);
