Skip to contents

Auxiliary function to estimate the estimator's variance (_i.e. standard error squared) from an asymptotically normal confidence interval of level 1 - alpha by implementing the following function:

\[ \text{var} = \Bigg(\dfrac{U - L}{2\cdot Z_{1 - \alpha/2}}\Bigg)^2 \] where U and L are the upper and lower bounds of the interval

Usage

estimator_var_from_ci(upper_limit, lower_limit, confidence_level = 0.95)

Arguments

upper_limit

Upper bound for the confidence interval

lower_limit

Lower bound for the confidence interval

confidence_level

Confidence level of the confidence interval

Value

The variance of the estimator

Note

Remember that the variance of the mean-estimator from asymptotically normal confidence intervals is the estimator's standard error squared

Examples

# Calculate the confidence interval for a normal mean
x <- rnorm(100)
interval_mu_x <- t.test(x)$conf.int
estimator_var_from_ci(interval_mu_x[1], interval_mu_x[2], 0.95)
#> [1] 0.008076336