grantmcdermott / ritest

Randomization Inference on R model objects
http://grantmcdermott.com/ritest
Other
8 stars 1 forks source link

Support multiple resampvars #3

Open grantmcdermott opened 2 years ago

grantmcdermott commented 2 years ago

One approach would be to use grep instead of match here. E.g.

resampvar_pos = grep(resampvar, Xnames)      ## CHANGED
  resampvar_orig = NULL
  if (length(resampvar_pos)==0) {            ## CHANGED
    resampvar_orig = resampvar
    resampvar = paste0(resampvar, 1) 
    resampvar_pos = grep(resampvar, Xnames)  ## CHANGED
    ...

An additional advantage of grep is that it makes it easier to use regular expressions to glob a bunch of variables. E,g,

est = fixest::feols(y ~ x1 + i(period, treat, 5) | id+period, fixest::base_did)
grep("^period", names(coefficients(est)))
#>   2  3  4  5  6  7  8  9 10