halfmoon (development version)
check_balance()gains anexposure_typeargument, one of"binary","categorical", or"continuous". It defaults to"auto", which reads the type from.exposureand reports what it found.options(halfmoon.quiet = TRUE)silences that report..metricsincheck_balance()now defaults toNULL, which computes every metric that applies to the exposure type: the standardized mean difference, the variance ratio, the Kolmogorov-Smirnov statistic, and the energy distance for a binary or categorical exposure, and the weighted correlation and the energy distance for a continuous one. Results for binary and categorical exposures are unchanged. Asking for a metric that does not apply to the exposure type is now an error, so a continuous exposure no longer produces a standardized mean difference for every distinct value it takes, and a binary exposure no longer produces a correlation.check_balance()computes the energy distance for the exposure type it resolved rather than from the count of distinct exposure values. A numeric exposure with many repeated values, such as a change score on a bounded count, reads as categorical and now contributes a between-group energy distance instead of a continuous one. Passexposure_type = "continuous"for the previous behavior. A direct call tobal_energy()is unchanged.plot_balance()marks the reference for the correlation metric at 0.ess()is now a re-export of the generic of the same name from causalgenerics. Attaching halfmoon alongside another package that re-exports that same generic no longer produces a masking conflict, because both packages export the one object. A package that defines its own unrelatedess()still masks, as before. The calculation is unchanged for numeric weights.Because the generic names its first argument
x,ess()no longer accepts the argument namewts. Pass the weights positionally, as iness(w).ess(), andbal_ess()through it, now error on non-numeric input instead of returning a meaningless number. Previouslyess(NULL)andbal_ess(NULL)returnedNaN, and factors, logicals, data frames, dates, time differences, and complex vectors each produced a value:bal_ess(factor("a"))returned1.8.ess(rep(0, 5))andess(numeric(0))still returnNaN.
