Checks that all variables referenced in the formula exist in the supplied data frame(s) and that they have appropriate types and ranges. This is typically called internally by the fitting function, but can be used directly for early error checking.
Arguments
- object
An object of class
"hbb_formula", as returned byhbb_formula().- data
A data frame containing provider-level variables (response, trials, fixed effects, grouping variable).
- state_data
An optional data frame containing state-level policy variables. Required if
object$policyis notNULL. Must contain a column matchingobject$groupfor merging.
Details
The following checks are performed:
objectis anhbb_formula.datais a data frame with at least one row.The response variable exists and contains non-negative integers.
The trials variable exists and contains positive integers.
Response does not exceed trials for any observation.
All fixed effect variables exist and are numeric.
The grouping variable (if any) exists and is coercible to integer.
If
state_datais supplied: all policy variables exist instate_data, the grouping variable exists instate_data, and policy variables are numeric.
See also
Other formula:
hbb_formula()
Examples
f <- hbb_formula(y | trials(n_trial) ~ poverty + urban)
data(nsece_synth_small)
validate_hbb_formula(f, nsece_synth_small)