Computes the score test statistic and p-value for testing whether a parameter equals a hypothesized value, using the score function and Fisher information evaluated at the null.

score_test(score, fisher_info, null_value = NULL)

Arguments

score

Numeric scalar or vector. The score function \(U(\theta_0) = \partial \ell / \partial \theta\) evaluated at the null value.

fisher_info

Numeric scalar or matrix. The Fisher information \(I(\theta_0)\) evaluated at the null value.

null_value

Optional. The null hypothesis value, stored for reference but not used in computation.

Value

A hypothesis_test object of subclass score_test containing:

stat

The score statistic \(S\)

p.value

P-value from chi-squared distribution

dof

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

score

The input score value(s)

fisher_info

The input Fisher information

null_value

The input null hypothesis value (if provided)

Details

The score test is one of the "holy trinity" of likelihood-based tests, alongside the Wald test (wald_test()) and the likelihood ratio test (lrt()). All three are asymptotically equivalent under \(H_0\), but they differ in what they require:

  • Wald test: Needs the MLE and its standard error – requires fitting the alternative model.

  • LRT: Needs maximized log-likelihoods under both models – requires fitting both.

  • Score test: Needs only the score and information at \(\theta_0\) – requires fitting only the null model.

This makes the score test computationally attractive when the null model is simple but the alternative is expensive to fit.

For the univariate case: $$S = \frac{U(\theta_0)^2}{I(\theta_0)} \sim \chi^2_1$$

For the multivariate case with \(k\) parameters: $$S = U(\theta_0)^\top I(\theta_0)^{-1} U(\theta_0) \sim \chi^2_k$$

The function detects scalar vs. vector input and dispatches accordingly.

See also

wald_test(), lrt() for the other members of the trinity

Examples

# Univariate score test
score_test(score = 2, fisher_info = 2)
#> Hypothesis test (score_test)
#> -----------------------------
#> Test statistic: 2
#> P-value: 0.157299207050284
#> Degrees of freedom: 1
#> Significant at 5% level: FALSE

# Compare the trinity on the same problem
score_test(score = 2, fisher_info = 2)
#> Hypothesis test (score_test)
#> -----------------------------
#> Test statistic: 2
#> P-value: 0.157299207050284
#> Degrees of freedom: 1
#> Significant at 5% level: FALSE
wald_test(estimate = 6, se = sqrt(6/10), null_value = 5)
#> Hypothesis test (wald_test)
#> -----------------------------
#> Test statistic: 1.66666666666667
#> P-value: 0.196705602458947
#> Degrees of freedom: 1
#> Significant at 5% level: FALSE

# Multivariate
score_test(score = c(1, 2), fisher_info = diag(c(1, 1)))
#> Hypothesis test (score_test)
#> -----------------------------
#> Test statistic: 5
#> P-value: 0.0820849986238988
#> Degrees of freedom: 2
#> Significant at 5% level: FALSE