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

wald_test(estimate, se, null_value = 0)

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.

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

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.

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.

See also

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

Examples

# 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
#> Hypothesis test ( wald_test )
#> -----------------------------
#> Test statistic:  9.765625 
#> P-value:  0.001778051 
#> Degrees of freedom:  1 
#> Significant at 5% level:  TRUE 

# Extract components
test_stat(w)        # Wald statistic (chi-squared)
#> [1] 9.765625
w$z                 # z-score
#> [1] 3.125
pval(w)             # p-value
#> [1] 0.001778051
is_significant_at(w, 0.05)
#> [1] TRUE

# Test against a non-zero null
# H0: theta = 2 vs H1: theta != 2
wald_test(estimate = 2.5, se = 0.8, null_value = 2)
#> Hypothesis test ( wald_test )
#> -----------------------------
#> Test statistic:  0.390625 
#> P-value:  0.5319711 
#> Degrees of freedom:  1 
#> Significant at 5% level:  FALSE