ci | R Documentation |
Compute Confidence/Credible/Compatibility Intervals (CI) or Support Intervals (SI) for Bayesian and frequentist models. The Documentation is accessible for:
ci(x, ...)
## S3 method for class 'numeric'
ci(x, ci = 0.95, method = "ETI", verbose = TRUE, BF = 1, ...)
## S3 method for class 'data.frame'
ci(x, ci = 0.95, method = "ETI", BF = 1, rvar_col = NULL, verbose = TRUE, ...)
## S3 method for class 'brmsfit'
ci(
x,
ci = 0.95,
method = "ETI",
effects = "fixed",
component = "conditional",
parameters = NULL,
verbose = TRUE,
BF = 1,
...
)
x |
A |
... |
Currently not used. |
ci |
Value or vector of probability of the CI (between 0 and 1)
to be estimated. Default to |
method |
Can be "ETI" (default), "HDI", "BCI", "SPI" or "SI". |
verbose |
Toggle off warnings. |
BF |
The amount of support required to be included in the support interval. |
rvar_col |
A single character - the name of an |
effects |
Should variables for fixed effects ( For models of from packages brms or rstanarm there are additional options:
|
component |
Which type of parameters to return, such as parameters for the conditional model, the zero-inflated part of the model, the dispersion term, etc. See details in section Model Components. May be abbreviated. Note that the conditional component also refers to the count or mean component - names may differ, depending on the modeling package. There are three convenient shortcuts (not applicable to all model classes):
|
parameters |
Regular expression pattern that describes the parameters
that should be returned. Meta-parameters (like |
A data frame with following columns:
Parameter
The model parameter(s), if x
is a model-object. If x
is a
vector, this column is missing.
CI
The probability of the credible interval.
CI_low
, CI_high
The lower and upper credible interval limits for the parameters.
Possible values for the component
argument depend on the model class.
Following are valid options:
"all"
: returns all model components, applies to all models, but will only
have an effect for models with more than just the conditional model
component.
"conditional"
: only returns the conditional component, i.e. "fixed
effects" terms from the model. Will only have an effect for models with
more than just the conditional model component.
"smooth_terms"
: returns smooth terms, only applies to GAMs (or similar
models that may contain smooth terms).
"zero_inflated"
(or "zi"
): returns the zero-inflation component.
"location"
: returns location parameters such as conditional
,
zero_inflated
, or smooth_terms
(everything that are fixed or random
effects - depending on the effects
argument - but no auxiliary
parameters).
"distributional"
(or "auxiliary"
): components like sigma
,
dispersion
, beta
or precision
(and other auxiliary parameters) are
returned.
For models of class brmsfit
(package brms), even more options are
possible for the component
argument, which are not all documented in detail
here. See also ?insight::find_parameters
.
When it comes to interpretation, we recommend thinking of the CI in terms of an "uncertainty" or "compatibility" interval, the latter being defined as "Given any value in the interval and the background assumptions, the data should not seem very surprising" (Gelman & Greenland 2019).
There is also a plot()
-method implemented in the see-package.
Gelman A, Greenland S. Are confidence intervals better termed "uncertainty intervals"? BMJ 2019;l5381. 10.1136/bmj.l5381
Other ci:
bci()
,
eti()
,
hdi()
,
si()
,
spi()
library(bayestestR)
posterior <- rnorm(1000)
ci(posterior, method = "ETI")
ci(posterior, method = "HDI")
df <- data.frame(replicate(4, rnorm(100)))
ci(df, method = "ETI", ci = c(0.80, 0.89, 0.95))
ci(df, method = "HDI", ci = c(0.80, 0.89, 0.95))
model <- suppressWarnings(rstanarm::stan_glm(
mpg ~ wt,
data = mtcars, chains = 2, iter = 200, refresh = 0
))
ci(model, method = "ETI", ci = c(0.80, 0.89))
ci(model, method = "HDI", ci = c(0.80, 0.89))
bf <- BayesFactor::ttestBF(x = rnorm(100, 1, 1))
ci(bf, method = "ETI")
ci(bf, method = "HDI")
model <- emmeans::emtrends(model, ~1, "wt", data = mtcars)
ci(model, method = "ETI")
ci(model, method = "HDI")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.