IQSS / cem

17 stars 5 forks source link

Provide a graceful fail #4

Open goshevs opened 6 years ago

goshevs commented 6 years ago

CEM gives a pretty irritating error message when I believe it cannot make a single match. Here is an illustration:

library(MASS) library(cem)

set.seed(12345)

meanv <- rep(0, 15) sigma <- diag(15) mydata <- data.frame(abs(round(mvrnorm(60, meanv, sigma), 0))) mydata$tr <- rbinom(60, 1, 0.5) myvars <- names(mydata) subdata <- mydata[,c(myvars[1:7], "tr")] mat <- cem(treatment = "tr", data = subdata, keep.all=TRUE) print(mat) # single match

Now, re-runing by adding one more variable gives:

subdata <- mydata[,c(myvars[1:8], "tr")] mat <- cem(treatment = "tr", data = subdata, keep.all=TRUE)

Error in [.default(tmp, x, bg) : subscript out of bounds

Please, provide a graceful fail as the current error is confusing to users.