nc_test {longevity} | R Documentation |
Score test of Northrop and Coleman
Description
This function computes the score test with the piecewise generalized Pareto distribution under the null hypothesis that the generalized Pareto with a single shape parameter is an adequate simplification. The score test statistic is calculated using the observed information matrix; both hessian and score vector are obtained through numerical differentiation.
Usage
nc_test(
time,
time2 = NULL,
event = NULL,
thresh = 0,
ltrunc = NULL,
rtrunc = NULL,
type = c("right", "left", "interval", "interval2"),
weights = rep(1, length(time)),
test = c("score", "lrt"),
arguments = NULL,
...
)
Arguments
time |
excess time of the event of follow-up time, depending on the value of event |
time2 |
ending excess time of the interval for interval censored data only. |
event |
status indicator, normally 0=alive, 1=dead. Other choices are |
thresh |
a vector of thresholds |
ltrunc |
lower truncation limit, default to |
rtrunc |
upper truncation limit, default to |
type |
character string specifying the type of censoring. Possible values are " |
weights |
weights for observations |
test |
string, either |
arguments |
a named list specifying default arguments of the function that are common to all |
... |
additional parameters, currently ignored |
Details
The score test is much faster and perhaps less fragile than the likelihood ratio test: fitting the piece-wise generalized Pareto model is difficult due to the large number of parameters and multimodal likelihood surface.
The reference distribution is chi-square
Value
a data frame with the following variables:
-
thresh
: threshold for the generalized Pareto distribution -
nexc
: number of exceedances -
score
: score statistic -
df
: degrees of freedom -
pval
: the p-value obtained from the asymptotic chi-square approximation.
Examples
set.seed(1234)
n <- 100L
x <- samp_elife(n = n,
scale = 2,
shape = -0.2,
lower = low <- runif(n),
upper = upp <- runif(n, min = 3, max = 20),
type2 = "ltrt",
family = "gp")
test <- nc_test(
time = x,
ltrunc = low,
rtrunc = upp,
thresh = quantile(x, seq(0, 0.5, by = 0.1)))
print(test)
plot(test)