Error when carrying out exp lincom function on multiple imputed data in R

97 Views Asked by At

I am trying to use (exp(lincom) to calculate the percentage change of GEE model outputs using (exp(lincom(data, variable)))-1. However, I had to account for missing data using MICE, thus changing the final data object to mipo (after pooling).

I am trying to calculate the percentage change of GEE model estimate outputs using exp(lincom(gee_imputed_data, variable)))-1, and the following error occurs; Error in UseMethod("vcov") : no applicable method for 'vcov' applied to an object of class "c('mira', 'matrix')" or no applicable method for 'vcov' applied to an object of class "c('mipo', 'data.frame'

Is there a way to carry this out on data following multiple imputation? Do I need to convert the data output ?

I carried out multiple imputation to produce imputed_data

I then carry out GEE on the imputed data to produce gee_imputed_data

gee_imputed_data<-with( imputed_data , geeglm( variable ~
          v1+
          v2+
          v3+             
  id = id,
  family = gaussian(),
  waves = t,
   corstr = "ar1"             
) )

following this I would like to use (exp(lincom(x, c("v1")))-1) to calculate the percentage change for variables in the model- however this does not work on the imputed data set gee_imputed_data or the pooled data

(exp(lincom(gee_imputed_data, c("v1")))-1)* 100 #   
Error in UseMethod("vcov") : 
  no applicable method for 'vcov' applied to an object of class "c('mira', 'matrix')"


pool.data<-pool(gee_imputed_data)
(exp(lincom(pool.data, c("v1")))-1)* 100 
Error in UseMethod("vcov") : 
  no applicable method for 'vcov' applied to an object of class "c('mipo', 'data.frame')"

The above equation has been used as successful approach on regular data following gee, however the type of data following MICE multiple imputations has posed a challenge. If anyone could please advise how I can continue with this method on this data object gee_imputed_data I would be very appreciative

I will add a reproducible example below

my_data <- data.frame(
  la_code = rep("E06000001", 12),
  year = 1:12,
  pop_est = c(90000, 92000, 88000, 91000, 94000, 95000, 87000, 93000, 89000, 92000, 91000, 92000),  # Manually entered values for pop_est
  impute_variable = c(50, 70, 80, 100, 60, 90, 40, 70, 90, 60, 50, 80)  
)

# Define imputation methods
imputation_methods <- c(
  "",              
  "",             
  "",              
  "pmm"            # impute_variable


# Multiple Imputation
imp_2 <- mice(my_data, m = 20, meth = imputation_methods,
              maxit = 5, pri = FALSE, seed = 6466)

# Analyze Imputed Data
gee_imp <- with(imp_2, geeglm(impute_variable ~
               year +
               offset(log(pop_est)),
               id = la_code,
               family = gaussian(link = "log"),
               waves = year,
               corstr = "ar1"))

# Summary of One Imputation
summary(gee_imp$analyses[[1]])

# Pool Imputations
pool.fit <- pool(gee_imp)

# Calculate an expression from pooled results
result <- (exp(lincom(pool.fit, c("year"))) - 1) * 100
0

There are 0 best solutions below