Skip to contents

Performs the White test for heteroskedasticity by regressing the squared residuals of a linear model on the original regressors and their squared terms. The null hypothesis is homoskedasticity.

Usage

eda_white_test(data, years, alpha = 0.05)

Arguments

data

Numeric vector of observed annual maximum series values. Must be strictly positive, finite, and not missing.

years

Numeric vector of observation years corresponding to data. Must be the same length as data and strictly increasing.

alpha

Numeric scalar in \([0.01, 0.1]\). The significance level for confidence intervals or hypothesis tests. Default is 0.05.

Value

A list containing the results of the White test:

  • data: The data argument.

  • years: The years argument.

  • alpha: The significance level as specified in the alpha argument.

  • null_hypothesis: A string describing the null hypothesis.

  • alternative_hypothesis: A string describing the alternative hypothesis.

  • statistic: White test statistic based on sample size and r_squared.

  • p_value: The p-value derived from a Chi-squared distribution with df = 2.

  • reject: If TRUE, the null hypothesis was rejected at significance alpha.

Details

The White test regresses the squared residuals from a primary linear model lm(data ~ years) against both the original regressor and its square. The test statistic is calculated as \(nR^2\), where \(R^2\) is the coefficient of determination from the auxiliary regression and \(n\) is the number of elements in the time series. Under the null hypothesis, the test statistic has the \(\chi^2\) distribution with 2 degrees of freedom.

References

White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. Econometrica, 48(4), 817–838.

Examples

data <- rnorm(n = 100, mean = 100, sd = 10)
years <- seq(from = 1901, to = 2000)
eda_white_test(data, years)
#> $data
#>   [1] 107.85550 103.97192 106.98846 104.50714 106.40800 112.20660 110.78431
#>   [8]  96.80989  87.26127  93.49333  92.57200  87.74771  96.87723 110.71671
#>  [15]  98.46020  91.09966  84.26416 105.62013  94.57179 111.64665 103.88534
#>  [22] 108.28514 100.32738  93.51255  98.24003  91.33492 102.79443  74.37330
#>  [29] 105.36249 117.23348  98.92870 105.61287  89.23935 100.82991 101.78167
#>  [36]  91.55114 117.67981  82.68244 112.11189 107.36570 111.29951  90.78180
#>  [43] 101.56818  80.14524 110.30039 112.91148 105.00442 110.39921  87.44111
#>  [50]  98.86676 101.12835 111.51733  85.58585 103.89748 107.29353  86.04344
#>  [57]  96.94657 110.95199  88.58207  91.29411 109.85239  91.61905  91.71838
#>  [64] 110.01256 111.97043  95.29367  84.88836 103.47476  95.94925  96.50217
#>  [71]  84.59143  95.90070  89.02645 100.54988  90.44008 109.84374 109.39418
#>  [78]  87.61338  86.89788  92.04935  93.35320 108.44849  94.79207 103.34544
#>  [85]  93.20054  96.88521 113.29437 103.96915  98.51686  92.26959 118.54612
#>  [92] 111.78232 105.47654 106.94876 108.49706 103.51722 104.15862  84.53482
#>  [99]  87.53159 104.64329
#> 
#> $years
#>   [1] 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915
#>  [16] 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930
#>  [31] 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945
#>  [46] 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
#>  [61] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
#>  [76] 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
#>  [91] 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
#> 
#> $alpha
#> [1] 0.05
#> 
#> $null_hypothesis
#> [1] "The data is homoskedastic."
#> 
#> $alternative_hypothesis
#> [1] "The data is heteroskedastic."
#> 
#> $statistic
#> [1] 1.428001
#> 
#> $p_value
#> [1] 0.4896812
#> 
#> $reject
#> [1] FALSE
#>