ush.test | R Documentation |
ush.test
performs U-shape testing between the target and analyzed risk factor.
Testing is based on B-splines basis functions and change of the sign of the estimated coefficients.
ush.test(
x,
y,
p.value = 0.05,
min.pct.obs = 0.05,
min.pct.def = 0.01,
g = 20,
sc = c(NA, Inf, -Inf, NaN)
)
x |
Numeric vector to be tested for U-shape. |
y |
Numeric target vector (binary). |
p.value |
Threshold for p-value of statistical significance of the estimated coefficients next to basis functions. Default is 0.05. |
min.pct.obs |
Minimum percentage of observations per bin. Default is 0.05. |
min.pct.def |
Minimum |
g |
Number of knots used for testing the U-shape (integer). It should take values between 2 and 50 with default value of 20. |
sc |
Numeric vector with special case elements. Default values are |
The command ush.test
returns list of three objects. The first object (candidates
)
is the data frame with summary of tested candidate knots. Using the reported results of this data frame
user can conclude if U-shape exists at all (column where direction
is equal to TRUE
) and
check its statistical significance (column significance
- TRUE, FALSE
).
The second object (optimal
) reports optimal knot value (if exists).
It is selected as the knot with minimum deviance among all candidates for
which direction
and significance
are equal to TRUE
.
The last, third, object (basis.functions
) exports basis functions for optimal knot. Basis functions
will be exported only in case optimal knot is found.
If optimal knot is not found, then users are encouraged to inspect closer the results of candidate testing.
data(gcd)
res <- ush.test(x = gcd$amount, y = gcd$qual)
res
#optimal knot is not found so candidate can be defined as follows:
direction.t <- res$candidate[res$candidate$direction, ]
optimal.k <- direction.t$cp[direction.t$deviance%in%min(direction.t$deviance)]
optimal.k
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.