Skip to content

scmBayesPost v0.4.6

Choose a tag to compare

@andrebonfrer andrebonfrer released this 02 Jun 01:54
· 2 commits to main since this release

scmBayesPost v0.4.6 — Bug fix

What was broken

build_iv_formula() was storing treatment, instruments, and
controls as formula attributes using attr(), but as.formula()
silently strips custom attributes when constructing the formula object.
This meant .parse_iv_formula() never found the attributes, always
fell back to the factor() heuristic, and misclassified plain numeric
controls (e.g. income_level) as instruments — giving incorrect
results in instrument_validity_report() and
test_instrument_strength().

What changed

build_iv_formula() now uses structure() to attach attributes after
as.formula(), which preserves them correctly. Attributes can be
verified with:

f.X <- build_iv_formula(
  outcome     = "outcome_var",
  instruments = "peer_adoption_rate",
  controls    = c("income_level", "factor(event_time)")
)

attr(f.X, "instruments")   # "peer_adoption_rate"
attr(f.X, "controls")      # c("income_level", "factor(event_time)")
attr(f.X, "treatment")     # "budgetdummy"

No changes to function signatures or output structure.

Installation

remotes::install_github("andrebonfrer/scmBayesPost@v0.4.6")