My goal is to run a longitudinal analysis of 2-arm study with repeated observations (5 timepoints) to compare certain clinical outcome at a certain timepoint (e.g. t3) between the arms, i.e. Arm1_t3 vs. Arm2_t3 using all available data and account for the dependency.
The model itself has a simple fixed structure: time * treatment.
This is a marginal model (no mixed models, no random effects are to be employed), called MMRM, fit using the Generalized Least Square (like PROC MIXED REPEATED in SAS) to account for heteroscedasticity and dependency, with unstructured covariance and Satterthwaite degrees of freedom.
The response can have gaps at various timepoints (called intermittent gaps, non-monotonous gaps). The MMRM is unbiased under MCAR and MAR, but for certain request from a statistical reviewer I want to perform a sensitivity analysis using the MMRM over MI data.
So, my goal is to fit the model over several imputed datasets, obtain the model coefficients and the variance-covariance matrix, pool them somehow, and use it with emmeans (or multcomp) to test certain contrasts.
BTW, I was curious what will ChatGPT say about that and it generated code, that doesn't work :) as there is no mice.impute.gls() function. Is there maybe some way to use this estimation method to accomplish the task anyway?
Both to perform the imputation and then - to pool results from this model?
library(mice)
library(nlme)
library(lme4) # for the dataset
# Create a dataset with missing values
data(sleepstudy)
sleepstudy$Days[c(1,10,20,30,40)] = NA
# Perform multiple imputation
imputed_data <- mice(sleepstudy, method = 'gls', m = 5) # doesn't work
iter imp variable
1 1Error in get(fn) : object 'mice.impute.gls' not found
# Analyze the imputed data
fit_list <- with(data = imputed_data, expr = lapply(1:5, function(i) gls(Reaction ~ Days, data = .imp[i], correlation = corAR1())))
# Combine the results
pooled_results <- pool(fit_list)
summary(pooled_results)
My goal is to run a longitudinal analysis of 2-arm study with repeated observations (5 timepoints) to compare certain clinical outcome at a certain timepoint (e.g. t3) between the arms, i.e. Arm1_t3 vs. Arm2_t3 using all available data and account for the dependency.
The model itself has a simple fixed structure: time * treatment.
This is a marginal model (no mixed models, no random effects are to be employed), called MMRM, fit using the Generalized Least Square (like PROC MIXED REPEATED in SAS) to account for heteroscedasticity and dependency, with unstructured covariance and Satterthwaite degrees of freedom.
The response can have gaps at various timepoints (called intermittent gaps, non-monotonous gaps). The MMRM is unbiased under MCAR and MAR, but for certain request from a statistical reviewer I want to perform a sensitivity analysis using the MMRM over MI data.
So, my goal is to fit the model over several imputed datasets, obtain the model coefficients and the variance-covariance matrix, pool them somehow, and use it with emmeans (or multcomp) to test certain contrasts.
BTW, I was curious what will ChatGPT say about that and it generated code, that doesn't work :) as there is no mice.impute.gls() function. Is there maybe some way to use this estimation method to accomplish the task anyway?
Both to perform the imputation and then - to pool results from this model?
EDIT: OK, I found something that works with MRMM (via mmrm package): https://cran.r-project.org/web/packages/rbmi/index.html