bounds.Rd
Given a desired width, computes the lower and upper limit
for a confidence or credible interval. Can be combined
with functions like quantile
or
the quantile functions for assorted probability
distributions( e.g., qnorm
,
qbeta
, etc.).
bounds(width)
The width of the interval, a numeric value between 0 and 1.
A vector with the lower and upper limits.
# Lower and upper limits of 95% interval
bounds( .95 )
#> [1] 0.025 0.975
# Example data
x <- rnorm( 100, mean = 100, sd = 15 )
# 95% confidence interval around mean
mean(x) + qnorm( bounds( .95 ) ) * sem( x )
#> [1] 99.07612 105.16251
# Predicted
qnorm( bounds( .95 ), mean = 100, sd = 15/sqrt(100) )
#> [1] 97.06005 102.93995
# The 1st and 3rd quartiles
quantile( x, bounds( .5 ) )
#> 25% 75%
#> 94.13483 111.74774