Learn R Programming

hypothesize (version 0.11.0)

wald_test: Wald Test

Description

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

Usage

wald_test(estimate, se = NULL, vcov = NULL, null_value = 0)

Value

A hypothesis_test object of subclass wald_test containing:

stat

The Wald statistic \(W\)

p.value

Two-sided p-value from chi-squared distribution

dof

Degrees of freedom (1 for univariate, \(k\) for multivariate)

z

The z-score (univariate case only)

estimate

The input estimate

se

The input standard error (univariate case only)

vcov

The input variance-covariance matrix (multivariate case only)

null_value

The input null hypothesis value

Arguments

estimate

Numeric. The estimated parameter value \(\hat{\theta}\). A scalar for the univariate case or a vector for the multivariate case.

se

Numeric. Standard error of the estimate for the univariate case. Mutually exclusive with vcov.

vcov

Numeric matrix. Variance-covariance matrix for the multivariate case. Mutually exclusive with se.

null_value

Numeric. The hypothesized value \(\theta_0\) under the null hypothesis. Default is 0. A scalar for the univariate case or a vector of the same length as estimate for the multivariate case.

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\).

Univariate case (when se is provided): 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 reported as \(W = z^2\), which follows a chi-squared distribution with 1 degree of freedom under \(H_0\). The z-score is stored in the returned object for reference.

Multivariate case (when vcov is provided): For a \(k\)-dimensional parameter vector \(\hat{\theta}\) with variance-covariance matrix \(\Sigma\), the Wald statistic is:

$$W = (\hat{\theta} - \theta_0)' \Sigma^{-1} (\hat{\theta} - \theta_0) \sim \chi^2(k)$$

The p-value is computed as \(P(\chi^2_k \geq W)\).

See Also

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

Examples

Run this code
# Univariate: test whether a regression coefficient differs from zero
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
wald_test(estimate = 2.5, se = 0.8, null_value = 2)

# Multivariate: test two parameters jointly
est <- c(2.0, 3.0)
V <- matrix(c(1.0, 0.3, 0.3, 1.0), 2, 2)
w_mv <- wald_test(estimate = est, vcov = V, null_value = c(0, 0))
test_stat(w_mv)
dof(w_mv)           # 2
pval(w_mv)

Run the code above in your browser using DataLab