| hypothesis | R Documentation |
Evaluates one or more hypothesis expressions against the posterior draws of
a smoothbp_fit object, returning posterior probabilities and evidence
ratios.
hypothesis(object, hypotheses, ci = 0.95, ...)
object |
A |
hypotheses |
A character vector of hypothesis strings. |
ci |
Width of the credible interval (0 < ci < 1). Default 0.95. |
... |
Unused. |
An object of class c("smoothbp_hypothesis", "data.frame")
with one row per hypothesis and columns:
HypothesisThe original hypothesis string.
EstimatePosterior mean of the contrast.
Est.ErrorPosterior SD of the contrast.
CI.lower, CI.upperCredible interval bounds.
P(H)Posterior probability of the hypothesis.
Evid.RatioEvidence ratio P(H)/(1-P(H)).
StarInformal star coding based on the evidence ratio.
Write hypotheses as character strings using exact parameter names as they
appear in fit$param_names (e.g. "b2_(Intercept)",
"omega_(Intercept)"). No backtick-quoting is needed; the function
handles special characters internally.
Two forms are accepted:
An expression containing >, <,
>=, or <=. The hypothesis is evaluated as a contrast:
the left-hand side minus the right-hand side (direction-adjusted), and
P(H \mid \text{data}) is the proportion of posterior draws
satisfying the condition.
Examples: "b2_(Intercept) > 0",
"omega_(Intercept) < 4",
"b2_(Intercept) - b1_(Intercept) > 0".
A numeric expression without a comparison operator. The
function summarises the posterior distribution of the derived quantity
and reports P(\text{expression} > 0) as the directional
probability.
Example: "b2_(Intercept) - b1_(Intercept)".
Point-null hypotheses (==) are not supported because they require
the Savage-Dickey density ratio; use bayestestR::rope() for
interval-based equivalence testing instead.
ER = \frac{P(H \mid \text{data})}{1 - P(H \mid \text{data})}
An ER of 19 corresponds to P(H) = 0.95; ER = 1 means the posterior
is equally split. Star codes: *** ER > 99, ** ER > 19,
* ER > 3.
## Not run:
# Is the change in slope positive?
hypothesis(fit, "b2_(Intercept) > 0")
# Does the change-point fall before time 4?
hypothesis(fit, "omega_(Intercept) < 4")
# Multiple hypotheses at once
hypothesis(fit, c(
"b2_(Intercept) > 0",
"omega_(Intercept) < 4",
"b2_(Intercept) - b1_(Intercept) > 0"
))
# Posterior summary of a contrast (no comparison operator)
hypothesis(fit, "b2_(Intercept) - b1_(Intercept)")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.