SKemp
SKemp

Reputation: 21

Error in rep(" ", spaces1) : invalid 'times' argument

I'm trying to carry out covariate balancing using the ebal package. The basic code is:

W1 <- weightit(Conformidad ~ SexoCon + DurPetFiscPrisión1 +
                Edad + HojaHistPen + NacionCon + AnteVivos +
                TipoAbog + Reincidencia + Habitualidad + Delitos,
                data = Suspension1,
                method = "ebal", estimand = "ATT")

I then want to check the balance using the summary function:

summary(W1)

This originally worked fine but now I get the error message:

Error in rep(" ", spaces1) : invalid 'times' argument

It's the same dataset and same code, except I changed some of the covariates. But now even when I go back to original covariates I get the same error. Any ideas would be very appreciated!!

Upvotes: 2

Views: 325

Answers (2)

Pr. Mortimer
Pr. Mortimer

Reputation: 1

I encountered the same error message. This happens when the treatment variable is coded as factor or character, but not as numeric in weightit. To make summary() work, you need to use 1 and 0.

Upvotes: 0

Noah
Noah

Reputation: 4414

I'm the author of WeightIt. That looks like a bug. I'll take a look at it. Are you using the most updated version of WeightIt?

Also, summary() doesn't assess balance. To do that, you need to use cobalt::bal.tab(). summary() summarizes the distribution of the weights, which is less critical than examining balance. bal.tab() displays the effect sample size as well, which is probably the most important statistic produced by summary().

Upvotes: 1

Related Questions