hdeffsev2.RdComputes the severity of the Hauck-Donner effect for each regression coefficient of a fitted VGLM.
hdeffsev0(x, y, dy, ddy, allofit = FALSE, eta0 = 0, COPS0 = eta0,
severity.table = c("None", "Faint", "Weak",
"Moderate", "Strong", "Extreme", "Undetermined"))
hdeffsev2(x, y, dy, ddy, allofit = FALSE, ndepends = FALSE,
eta0 = 0,
severity.table = c("None", "Faint", "Weak",
"Moderate", "Strong", "Extreme",
"Undetermined")[if (ndepends) TRUE else
c(1, 4, 6, 7)], tol0 = 0.1)Numeric vectors;
x are the estimates (sorted), and
y are the signed Wald statistics.
Numeric vectors;
the first and second derivatives of the Wald statistics.
They can be computed by hdeff.
Logical. If TRUE then other quantities are
returned in a list.
The default is a vector with elements selected from
the argument severity.table.
Character vector with 6 values plus the last value for initialization. Usually users should not assign anything to this argument.
Numeric. The hypothesized value.
The default is appropriate for most symmetric
binomialff links, and also
for poissonff regression
with the natural parameter.
Logical. Use boundaries that depend on the
sample size \(n\)?
For hdeffsev2 the default is to use boundaries
that do not depend on \(n\), and consequently
there are fewer severity measures.
These do not use the normal or tangent lines;
instead they are based only on the signs of
dy and ddy.
Numeric. See Yee (2023).
Numeric. Any estimate whose absolute value is less than
tol0 is assigned the first value of
the argument severity.table, i.e., none.
This is to handle a singularity at the origin:
the estimates might be extremely close to 0.
Note: The function
hdeffsev0
has a bug or two in it but
they should be fixed later this year (2025).
Instead, hdeffsev
is recommended.
Function hdeffsev0 is currently rough-and-ready.
It is possible to use the first two derivatives obtained
from hdeff to categorize the severity of the
the Hauck-Donner effect (HDE).
It is effectively assumed that, starting at
the origin
and going right,
the curve is made up of a convex segment followed by
a concave segment and then the convex segment.
Midway in the concave segment the first
derivative is 0, and
beyond that the HDE is really manifest because the
derivative remains negative.
For "None" the estimate lies on the convex
part of the curve near the origin, hence there is
very little HDE at all.
For "Weak" the estimate lies on the
concave part of the curve but the Wald statistic is still
increasing as estimate gets away from 0, hence it is only
a mild form of the HDE.
For "Moderate",
"Strong"
and "Extreme"
the Wald statistic is
decreasing as the estimate gets away from eta0,
hence it
really does exhibit the HDE.
It is recommended that lrt.stat be used
to compute
LRT p-values, as they do not suffer from the HDE.
By default this function
(hdeffsev0)
returns a labelled vector with
elements selected from
severity.table.
If allofit = TRUE then Yee (2022) gives details
about some of the other list components,
e.g., a quantity called
zeta is the normal line projected onto the x-axis,
and its first derivative gives additional
information about the position
of the estimate along the curve.
Yee, T. W. (2022). On the Hauck-Donner effect in Wald tests: Detection, tipping points and parameter space characterization, Journal of the American Statistical Association, 117, 1763–1774. doi:10.1080/01621459.2021.1886936 .
For VGAM version 1.1-13,
hdeffsev() was renamed to hdeffsev0(),
hdeffsev2() to hdeffsev2() [no change],
and hdeffsev is new and based
on wsdm(vglmfit).
These functions are likely to change in the short future because it is experimental and far from complete. Improvements are intended.
The severity measures ideally should be based on tangent lines rather than normal lines so that the boundaries are independent of the sample size \(n\). Hence such boundaries differ a little from Yee (2022) which had a mixture of such.
The functions were written specifically for
binomialff, but they should work
for some other family functions.
Currently,
in order for "Strong" to be assigned correctly,
at least one such value is needed on the
LHS and/or RHS each. From those, two other boundary
points are obtained so that it creates two intervals.
deg <- 4 # myfun is a function that approximates the HDE
myfun <- function(x, deriv = 0) switch(as.character(deriv),
'0' = x^deg * exp(-x),
'1' = (deg * x^(deg-1) - x^deg) * exp(-x),
'2' = (deg*(deg-1)*x^(deg-2) - 2*deg*x^(deg-1) + x^deg)*exp(-x))
xgrid <- seq(0, 10, length = 101)
ansm <- hdeffsev0(xgrid, myfun(xgrid), myfun(xgrid, deriv = 1),
myfun(xgrid, deriv = 2), allofit = TRUE)
digg <- 4
cbind(severity = ansm$sev,
fun = round(myfun(xgrid), digg),
deriv1 = round(myfun(xgrid, deriv = 1), digg),
deriv2 = round(myfun(xgrid, deriv = 2), digg),
zderiv1 = round(1 + (myfun(xgrid, deriv = 1))^2 +
myfun(xgrid, deriv = 2) * myfun(xgrid), digg))
#> severity fun deriv1 deriv2 zderiv1
#> [1,] "None" "0" "0" "0" "1"
#> [2,] "None" "1e-04" "0.0035" "0.1014" "1"
#> [3,] "None" "0.0013" "0.0249" "0.3419" "1.0011"
#> [4,] "None" "0.006" "0.074" "0.6461" "1.0094"
#> [5,] "None" "0.0172" "0.1544" "0.961" "1.0403"
#> [6,] "None" "0.0379" "0.2654" "1.251" "1.1178"
#> [7,] "None" "0.0711" "0.403" "1.4936" "1.2687"
#> [8,] "None" "0.1192" "0.5621" "1.6765" "1.5158"
#> [9,] "None" "0.184" "0.7362" "1.7944" "1.8722"
#> [10,] "None" "0.2668" "0.9188" "1.8475" "2.337"
#> [11,] "None" "0.3679" "1.1036" "1.8394" "2.8947"
#> [12,] "None" "0.4874" "1.2848" "1.7762" "3.5165"
#> [13,] "None" "0.6246" "1.4573" "1.6655" "4.1639"
#> [14,] "None" "0.7784" "1.6166" "1.5153" "4.793"
#> [15,] "None" "0.9473" "1.7593" "1.334" "5.3589"
#> [16,] "None" "1.1296" "1.8827" "1.1296" "5.8204"
#> [17,] "None" "1.3231" "1.9847" "0.9097" "6.1427"
#> [18,] "None" "1.5258" "2.0643" "0.6811" "6.3005"
#> [19,] "None" "1.7352" "2.1209" "0.4499" "6.2787"
#> [20,] "None" "1.9492" "2.1544" "0.2214" "6.0728"
#> [21,] "None" "2.1654" "2.1654" "0" "5.6888"
#> [22,] "None" "2.3815" "2.1547" "-0.2106" "5.1413"
#> [23,] "None" "2.5956" "2.1237" "-0.4076" "4.4522"
#> [24,] "None" "2.8057" "2.0737" "-0.5887" "3.6487"
#> [25,] "None" "3.0098" "2.0065" "-0.7525" "2.7615"
#> [26,] "None" "3.2064" "1.9239" "-0.8978" "1.8225"
#> [27,] "None" "3.3941" "1.8276" "-1.0243" "0.8637"
#> [28,] "None" "3.5716" "1.7196" "-1.1317" "-0.0849"
#> [29,] "None" "3.7377" "1.6019" "-1.2205" "-0.9958"
#> [30,] "None" "3.8917" "1.4762" "-1.2911" "-1.8454"
#> [31,] "None" "4.0328" "1.3443" "-1.3443" "-2.614"
#> [32,] "None" "4.1604" "1.2079" "-1.381" "-3.2867"
#> [33,] "None" "4.2742" "1.0686" "-1.4025" "-3.8527"
#> [34,] "None" "4.3741" "0.9278" "-1.4098" "-4.3058"
#> [35,] "None" "4.4598" "0.787" "-1.4043" "-4.6435"
#> [36,] "None" "4.5315" "0.6474" "-1.3872" "-4.867"
#> [37,] "None" "4.5893" "0.5099" "-1.3598" "-4.9806"
#> [38,] "None" "4.6336" "0.3757" "-1.3234" "-4.9909"
#> [39,] "None" "4.6646" "0.2455" "-1.2792" "-4.9068"
#> [40,] "None" "4.6828" "0.1201" "-1.2284" "-4.7382"
#> [41,] "Extreme" "4.6888" "0" "-1.1722" "-4.4962"
#> [42,] "Extreme" "4.683" "-0.1142" "-1.1116" "-4.1924"
#> [43,] "Extreme" "4.6662" "-0.2222" "-1.0475" "-3.8385"
#> [44,] "Extreme" "4.6388" "-0.3236" "-0.981" "-3.4457"
#> [45,] "Extreme" "4.6017" "-0.4183" "-0.9127" "-3.0251"
#> [46,] "Extreme" "4.5554" "-0.5062" "-0.8436" "-2.5867"
#> [47,] "Extreme" "4.5007" "-0.587" "-0.7742" "-2.1399"
#> [48,] "Extreme" "4.4382" "-0.661" "-0.7052" "-1.6929"
#> [49,] "Extreme" "4.3687" "-0.7281" "-0.6371" "-1.2531"
#> [50,] "Extreme" "4.2928" "-0.7885" "-0.5703" "-0.8267"
#> [51,] "Extreme" "4.2112" "-0.8422" "-0.5053" "-0.4187"
#> [52,] "Extreme" "4.1246" "-0.8896" "-0.4424" "-0.0334"
#> [53,] "Extreme" "4.0335" "-0.9308" "-0.3819" "0.3261"
#> [54,] "Extreme" "3.9386" "-0.9661" "-0.3239" "0.6576"
#> [55,] "Extreme" "3.8405" "-0.9957" "-0.2687" "0.9595"
#> [56,] "Extreme" "3.7397" "-1.0199" "-0.2163" "1.2312"
#> [57,] "Extreme" "3.6367" "-1.039" "-0.167" "1.4723"
#> [58,] "Extreme" "3.532" "-1.0534" "-0.1207" "1.6835"
#> [59,] "Extreme" "3.4261" "-1.0633" "-0.0774" "1.8654"
#> [60,] "Extreme" "3.3195" "-1.069" "-0.0372" "2.0193"
#> [61,] "Extreme" "3.2125" "-1.0708" "0" "2.1467"
#> [62,] "Extreme" "3.1054" "-1.0691" "0.0342" "2.2492"
#> [63,] "Extreme" "2.9988" "-1.0641" "0.0655" "2.3288"
#> [64,] "Extreme" "2.8927" "-1.0561" "0.094" "2.3873"
#> [65,] "Extreme" "2.7876" "-1.0454" "0.1198" "2.4267"
#> [66,] "Extreme" "2.6837" "-1.0322" "0.1429" "2.449"
#> [67,] "Extreme" "2.5813" "-1.0169" "0.1636" "2.4562"
#> [68,] "Extreme" "2.4804" "-0.9996" "0.1818" "2.4501"
#> [69,] "Extreme" "2.3814" "-0.9806" "0.1978" "2.4325"
#> [70,] "Extreme" "2.2844" "-0.9601" "0.2116" "2.4051"
#> [71,] "Extreme" "2.1894" "-0.9383" "0.2234" "2.3696"
#> [72,] "Extreme" "2.0967" "-0.9155" "0.2333" "2.3273"
#> [73,] "Extreme" "2.0064" "-0.8917" "0.2415" "2.2797"
#> [74,] "Extreme" "1.9184" "-0.8672" "0.248" "2.2279"
#> [75,] "Extreme" "1.8329" "-0.8422" "0.253" "2.1731"
#> [76,] "Extreme" "1.75" "-0.8167" "0.2567" "2.1161"
#> [77,] "Extreme" "1.6696" "-0.7909" "0.259" "2.0579"
#> [78,] "Extreme" "1.5918" "-0.7649" "0.2602" "1.9992"
#> [79,] "Extreme" "1.5166" "-0.7389" "0.2603" "1.9406"
#> [80,] "Extreme" "1.444" "-0.7129" "0.2594" "1.8828"
#> [81,] "Extreme" "1.3741" "-0.687" "0.2576" "1.826"
#> [82,] "Extreme" "1.3066" "-0.6614" "0.2551" "1.7708"
#> [83,] "Extreme" "1.2418" "-0.636" "0.2519" "1.7173"
#> [84,] "Extreme" "1.1794" "-0.611" "0.2481" "1.6659"
#> [85,] "Extreme" "1.1196" "-0.5864" "0.2437" "1.6167"
#> [86,] "Extreme" "1.0621" "-0.5623" "0.2389" "1.5699"
#> [87,] "Extreme" "1.0071" "-0.5387" "0.2337" "1.5255"
#> [88,] "Extreme" "0.9544" "-0.5156" "0.2281" "1.4835"
#> [89,] "Extreme" "0.9039" "-0.4931" "0.2222" "1.444"
#> [90,] "Extreme" "0.8557" "-0.4711" "0.2162" "1.407"
#> [91,] "Extreme" "0.8097" "-0.4498" "0.2099" "1.3723"
#> [92,] "Extreme" "0.7657" "-0.4292" "0.2035" "1.34"
#> [93,] "Extreme" "0.7238" "-0.4091" "0.197" "1.31"
#> [94,] "Extreme" "0.6839" "-0.3897" "0.1905" "1.2822"
#> [95,] "Extreme" "0.6459" "-0.371" "0.1839" "1.2564"
#> [96,] "Extreme" "0.6097" "-0.353" "0.1773" "1.2327"
#> [97,] "Extreme" "0.5753" "-0.3356" "0.1708" "1.2108"
#> [98,] "Extreme" "0.5425" "-0.3188" "0.1643" "1.1908"
#> [99,] "Extreme" "0.5115" "-0.3027" "0.1578" "1.1724"
#> [100,] "Extreme" "0.482" "-0.2872" "0.1515" "1.1555"
#> [101,] "Extreme" "0.454" "-0.2724" "0.1453" "1.1402"