Calculates symmetric Wald confidence intervals.
wald( thetahat, sehat, null = 0, alpha = c(0.001, 0.01, 0.05), dist = "z", df, eval = FALSE, theta = 0 )
thetahat | Numeric. Parameter estimate \(\left( \hat{\theta} \right)\). |
---|---|
sehat | Numeric.
Estimated standard error of |
null | Numeric.
Hypothesized value of |
alpha | Numeric vector.
Significance level
\(\left( \alpha \right)\) .
By default,
|
dist | Character string.
|
df | Numeric.
Degrees of freedom (df) if |
eval | Logical.
Evaluate confidence intervals using
|
theta | Numeric. Population parameter \( \left( \theta \right) \). |
Returns a vector with the following elements:
Square root of Wald test statistic.
p-value.
Estimated d=standard error of thetahat \(\left( \widehat{\mathrm{se}} \left( \hat{\theta} \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.
As the sample size approaches infinity \(\left( n \to \infty \right)\), the distribution of \(\hat{\theta}\) approaches the normal distribution with mean equal to \(\theta\) and variance equal to \(\widehat{\mathrm{Var}} \left( \hat{\theta} \right)\) $$ \hat{\theta} \mathrel{\dot\sim} \mathcal{N} \left( \theta, \widehat{\mathrm{Var}} \left( \hat{\theta} \right) \right) . $$ As such, \( \hat{\theta} \) can be expressed in terms of \(z\)-scores from a standard normal distribution $$ \frac{ \hat{\theta} - \theta } { \widehat{\mathrm{se}} \left( \hat{\theta} \right) } \mathrel{\dot\sim} \mathcal{N} \left( 0, 1 \right) $$ where \( \widehat{\mathrm{se}} \left( \hat{\theta} \right) = \sqrt{ \widehat{\mathrm{Var}} \left( \hat{\theta} \right) } \).
To form a confidence interval around \(\hat{\theta}\), the \(z\)-score associated with a particular alpha level can be plugged-in the equation below. $$ \hat{\theta} \pm z_{\frac{\alpha}{2}} \times \widehat{\mathrm{se}} \left( \hat{\theta} \right) $$
Note that this is valid only when \(n \to \infty\). In finite samples, this is only an approximation. Gosset derived a better approximation in the context of \(\hat{\theta} = \bar{x}\) $$ \frac{ \hat{\theta} - \theta } { \widehat{\mathrm{se}} \left( \hat{\theta} \right) } \mathrel{\dot\sim} t \left( \nu \right) $$ where \(t\) is the Student's \(t\) distribution and \(\nu\), the degrees of freedom \(n - 1\), is the Student's \(t\) distribution parameter. As such, the symmetric Wald confidence interval is given by $$ \hat{\theta} \pm t_{ \left( \frac{ \alpha } { 2 } , \nu \right) } \times \widehat{\mathrm{se}} \left( \hat{\theta} \right) . $$ Note that in large sample sizes, \(t\) converges to \(z\).
Wikipedia: Confidence interval
############################################################# # 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#> [1] -0.01130945#> [1] 0.01006135############################################################# # Generate Wald confidence intervals # for alpha = c(0.001, 0.01, 0.05). ############################################################# wald( thetahat = thetahat, sehat = sehat )#> statistic p se ci_0.05 ci_0.5 ci_2.5 #> -1.124049082 1.739007796 0.010061348 -0.044416585 -0.037225765 -0.031029329 #> ci_97.5 ci_99.5 ci_99.95 #> 0.008410431 0.014606866 0.021797686