1
$\begingroup$

I am imputing average follow-up for a meta-analysis using MICE. In studies reporting a maximum follow-up duration, I attempted to constrain imputations so average follow-up is always less than the maximum follow-up.

I used the custom imputation function described in the excellent community top-post here Multiple imputation for missing values

I used the following adjusted code to do so:

function (y, ry, x, donors = 5, type = 1, ridge = 1e-05, version = "", 
          ...) 
{
    max <- max(data[,"maxfollowup"], na.rm=TRUE)
                  )
    repeat{
        vals <- mice.impute.pmm(y, ry, x, donors = 5, type = 1, ridge = 1e-05,
                                version = "", ...)
        if (all(vals < max)){
            break
        }
    }
    return(vals)
}

In reviewing the imputed data, however, some imputed values are greater than the upper limit of the follow-up range. See last row in picture where average > max follow-up. Presumably I did not adjust the code correctly. Where did I go wrong?

See last row

$\endgroup$
2
  • $\begingroup$ What is "uprange"? If it's the maximum duration of follow-up, then why is it changing with each imputation? $\endgroup$ Jan 6 at 16:19
  • $\begingroup$ Yes "uprange" is the maximum follow-up duration. Where do you see that it is changing with each imputation? I actually solved the problem, will post below. $\endgroup$
    – rdmirza
    Jan 8 at 23:59

1 Answer 1

0
$\begingroup$

Applying constraints insofar as my question was concerned is documented well in this MICE vingette (1)

Here's the embarrassingly simple code:

long <- complete(imp, "long", include = TRUE)  
long$avg <- with(long, ifelse(avg < uprange, avg, uprange))  
imp <- as.mids(long) 

1: https://www.gerkovink.com/miceVignettes/Passive_Post_processing/Passive_imputation_post_processing.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.