wilson_hilferty: Modified Wilson-Hilferty approximation

View source: R/wilson_hilferty.R

wilson_hilfertyR Documentation

Modified Wilson-Hilferty approximation

Description

Implements the modified Wilson-Hilferty (1931) approximation used by GUIDE to convert a chi-square random variable to an approximate chi-square random variable with one degree of freedom.

Usage

wilson_hilferty(x, df)

Arguments

x

Numeric value of the observed chi-square statistic.

df

Integer specifying the degrees of freedom associated with x.

Value

An approximate chi-square statistic with one degree of freedom.

Examples

wilson_hilferty(2056, df = 4)
wilson_hilferty(1831, df = 20)

set.seed(1144)  # for reproducibility
x <- rchisq(1000, df = 10)
w <- sapply(x, FUN = function(x) wilson_hilferty(x, df = 10))
px <- pchisq(x, df = 10)
pw <- pchisq(round(w), df = 1)
plot(px, pw)
abline(0, 1, lty = 2, col = 2)
cor(px, pw)

bgreenwell/treemisc documentation built on Oct. 26, 2022, 12:56 a.m.