1

While using the weightIt package in R I encountered a strange error:

"error: treatment and covariates must have same number of units"

Now, checking the root code of the package and this specific error generation and it says the number of rows for the covariates must equal the length of the outcome variable. Makes sense.

I have checked both of these parameters (they are correct), and no fix. I tried just one of 8 covariates and no fix, missingness checks, and even made a data set which only contains the covariates of interest in the model.

Nothing seems to work. Has anyone experienced this error before?

It's straightforward code with a one-line run using categorical/binary variables (all covariates expect tsd) and one continuous (tsd) with the outcome of binary treatment (trt). Method shown below is empirical balancing calibration weighting and estimand is ATT:

weightit(trt~age65+stg+race+tsd+ec+met+shist+sex,method="ecbw",estimand="ATT")

Thank you!

user207581
  • 41
  • 3

1 Answers1

0

This bug has been fixed in the development version of WeightIt, which you can install using devtools::install_github("ngreifer/WeightIt"). The case is poor programming in the formula.tools package, which is loaded when using the logistf package, which I would guess is the culprit here.

In the future, this is not the place to ask about bugs in specific software. For WeightIt, please use the GitHub issues page to ask questions and report bugs.

Noah
  • 20,638
  • 2
  • 20
  • 58