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?