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!