# NOT RUN {
if (require("rstanarm")) {
fit <- stan_glm(mpg ~ wt + am, data = mtcars, chains = 1)
hdi(fit)
# fit logistic regression model
fit <- stan_glm(
vs ~ wt + am,
data = mtcars,
family = binomial("logit"),
chains = 1
)
# compute hdi, transform on "odds ratio scale"
hdi(fit, trans = exp)
# compute rope, on scale of linear predictor. finds proportion
# of posterior distribution values between -1 and 1.
rope(fit, rope = c(-1, 1))
# compute rope, boundaries as "odds ratios". finds proportion of
# posterior distribution values, which - after being exponentiated -
# are between .8 and 1.25 (about -.22 and .22 on linear scale)
rope(fit, rope = c(.8, 1.25), trans = exp)
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab