Description Usage Arguments Details Value Author(s) References Examples
Calculates symmetric Wald confidence intervals.
1 2 3 4 5 6 7 8 9 10 |
thetahat |
Numeric. Parameter estimate ≤ft( \hat{θ} \right). |
sehat |
Numeric.
Estimated standard error of |
null |
Numeric.
Hypothesized value of |
alpha |
Numeric vector.
Significance level
≤ft( α \right) .
By default,
|
dist |
Character string.
|
df |
Numeric.
Degrees of freedom (df) if |
eval |
Logical.
Evaluate confidence intervals using
|
theta |
Numeric. Population parameter ≤ft( θ \right) . |
As the sample size approaches infinity ≤ft( n \to ∞ \right), the distribution of \hat{θ} approaches the normal distribution with mean equal to θ and variance equal to \widehat{\mathrm{Var}} ≤ft( \hat{θ} \right)
\hat{θ} \mathrel{\dot\sim} \mathcal{N} ≤ft( θ, \widehat{\mathrm{Var}} ≤ft( \hat{θ} \right) \right) .
As such, \hat{θ} can be expressed in terms of z-scores from a standard normal distribution
\frac{ \hat{θ} - θ } { \widehat{\mathrm{se}} ≤ft( \hat{θ} \right) } \mathrel{\dot\sim} \mathcal{N} ≤ft( 0, 1 \right)
where \widehat{\mathrm{se}} ≤ft( \hat{θ} \right) = √{ \widehat{\mathrm{Var}} ≤ft( \hat{θ} \right) } .
To form a confidence interval around \hat{θ}, the z-score associated with a particular alpha level can be plugged-in the equation below.
\hat{θ} \pm z_{\frac{α}{2}} \times \widehat{\mathrm{se}} ≤ft( \hat{θ} \right)
Note that this is valid only when n \to ∞. In finite samples, this is only an approximation. Gosset derived a better approximation in the context of \hat{θ} = \bar{x}
\frac{ \hat{θ} - θ } { \widehat{\mathrm{se}} ≤ft( \hat{θ} \right) } \mathrel{\dot\sim} t ≤ft( ν \right)
where t is the Student's t distribution and ν, the degrees of freedom n - 1, is the Student's t distribution parameter. As such, the symmetric Wald confidence interval is given by
\hat{θ} \pm t_{ ≤ft( \frac{ α } { 2 } , ν \right) } \times \widehat{\mathrm{se}} ≤ft( \hat{θ} \right) .
Note that in large sample sizes, t converges to z.
Returns a vector with the following elements:
Square root of Wald test statistic.
p-value.
Estimated d=standard error of thetahat ≤ft( \widehat{\mathrm{se}} ≤ft( \hat{θ} \right) \right).
Estimated confidence limits corresponding to alpha.
If eval = TRUE
,
also returns
Logical. Tests if confidence interval contains zero.
Logical. Tests if confidence interval contains theta.
Length of confidence interval.
Shape of confidence interval.
Ivan Jacob Agaloos Pesigan
Wikipedia: Confidence interval
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #############################################################
# Generate sample data from a normal distribution
# with mu = 0 and sigma^2 = 1.
#############################################################
set.seed(42)
n <- 10000
x <- rnorm(n = n)
#############################################################
# Estimate the population mean mu using the sample mean xbar.
#############################################################
# Parameter estimate xbar
thetahat <- mean(x)
thetahat
# Closed form solution for the standard error of the mean
sehat <- sd(x) / sqrt(n)
sehat
#############################################################
# Generate Wald confidence intervals
# for alpha = c(0.001, 0.01, 0.05).
#############################################################
wald(
thetahat = thetahat,
sehat = sehat
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.