CBPS
CBPS copied to clipboard
`Error: missing or infinite values in 'x'` from `CBPS.4Treat`
We are using the boot package to run bootstraps of weighted cox proportional hazards models. We have successfully run 8 of these models with 1000 bootstrap iterations, but have been hitting an error on the most recent model when running more than 900 iterations.
Included in these bootstraps are calls to WeightIt::weightit
.
In some iterations (but not nearly all of them – and we can reproduce them when running a single iteration), we get this message back from WeightIt::weightit
:
Error: missing or infinite values in 'x'
Below is the stacktrace right before the error.
To the best of our understanding the error comes from MASS::cov.trob
at https://github.com/cran/MASS/blob/70ddb7dfd74ba96d4f44b9658af44745265b93d2/R/cov.trob.R#L22
And this is called via MASS::ginv
called from https://github.com/kosukeimai/CBPS/blob/d2f40a3f854003a8be05040bf2028e7d3bcdf9e1/R/CBPSMultiTreat.r#L410
The dataset is 16484 x 13 after running it through mice::mice
single imputation of missing values.
Our WeightIt::weightit
call is
WeightIt::weightit(factor1 ~ numeric2 + numeric3 + numeric4 + factor5 + factor6 + factor7 + numeric8 + factor9 + factor10 + factor11,
moments = 1, # power of continuous covs to be balanced
int = FALSE, # incorporate all covariate interactions
data = mice_completed_data,
method = "CBPS",
estimand = "ATE",
over = TRUE, # True optimizes for pred and cov balance
include.obj = TRUE,
stabilize = TRUE
)
Do you have any impressions of how we are getting this error? What other diagnostics would be helpful? Interestingly, if we run this same call with 16483 rows, we do not get an error.
My hunch is that for some bootstrap draws some of the covariates are linearly dependent. For example, it could be that some categorical variables have few observations for some values and they are not sampled for some bootstrap draws. I might be wrong though.