Learn R Programming

hypothesize (version 0.10.0)

wald_test: Wald Test

Description

Computes the Wald test statistic and p-value for testing whether a parameter equals a hypothesized value.

Usage

wald_test(estimate, se, null_value = 0)

Value

A hypothesis_test object of subclass wald_test containing:

stat

The Wald statistic \(W = z^2\)

p.value

Two-sided p-value from chi-squared(1) distribution

dof

Degrees of freedom (always 1 for univariate Wald test)

z

The z-score \((\hat{\theta} - \theta_0) / SE\)

estimate

The input estimate

se

The input standard error

null_value

The input null hypothesis value

Arguments

estimate

Numeric. The estimated parameter value \(\hat{\theta}\).

se

Numeric. The standard error of the estimate, \(SE(\hat{\theta})\).

null_value

Numeric. The hypothesized value \(\theta_0\) under the null hypothesis. Default is 0.

Relationship to Other Tests

The Wald test is one of the "holy trinity" of likelihood-based tests, alongside the likelihood ratio test (lrt()) and the score test. For large samples, all three are asymptotically equivalent, but they can differ substantially in finite samples.

Details

The Wald test is a fundamental tool in statistical inference, used to test the null hypothesis \(H_0: \theta = \theta_0\) against the alternative \(H_1: \theta \neq \theta_0\).

The test is based on the asymptotic normality of maximum likelihood estimators. Under regularity conditions, if \(\hat{\theta}\) is the MLE with standard error \(SE(\hat{\theta})\), then:

$$z = \frac{\hat{\theta} - \theta_0}{SE(\hat{\theta})} \sim N(0, 1)$$

The Wald statistic is typically reported as \(W = z^2\), which follows a chi-squared distribution with 1 degree of freedom under \(H_0\). This formulation generalizes naturally to multivariate parameters.

The p-value is computed as \(P(\chi^2_1 \geq W)\), giving a two-sided test. The z-score is stored in the returned object for reference.

See Also

lrt() for likelihood ratio tests, z_test() for testing means

Examples

Run this code
# Test whether a regression coefficient differs from zero
# Suppose we estimated beta = 2.5 with SE = 0.8
w <- wald_test(estimate = 2.5, se = 0.8, null_value = 0)
w

# Extract components
test_stat(w)        # Wald statistic (chi-squared)
w$z                 # z-score
pval(w)             # p-value
is_significant_at(w, 0.05)

# Test against a non-zero null
# H0: theta = 2 vs H1: theta != 2
wald_test(estimate = 2.5, se = 0.8, null_value = 2)

Run the code above in your browser using DataLab