R/curve_rstar.R
curve_rstar.RdConverts an object produced by likelihoodAsy::rstar.ci() into a
consonance (confidence) function based on higher-order likelihood
asymptotics. The r* statistic (Barndorff-Nielsen; Skovgaard) yields
interval estimates and P-values that are second-order accurate, unlike
the first-order Wald and likelihood-root intervals produced by the
other constructors in this package. This is especially relevant for
small samples and models with many nuisance parameters, where
first-order consonance functions can be visibly miscalibrated.
curve_rstar(object, statistic = "rstar", steps = 1000, table = TRUE)An object of class rstarci produced by
likelihoodAsy::rstar.ci().
Indicates which statistic should be inverted to form
the consonance function. The default, "rstar", uses the modified
(second-order) likelihood root r*. The alternative "r" uses the
first-order likelihood root, which is useful for comparing the two
functions with plot_compare().
Indicates how many consonance intervals should be computed. The default is 1000, which corresponds to a fine grid of levels; fewer steps will lead to a less smooth function.
Indicates whether or not a table output with some relevant statistics should be generated. The default is TRUE and generates a table which is included in the list object.
A list with 3 items where the dataframe of standard values such as the levels and the interval limits are in the first object, the values needed for the consonance density in the second object, and the table of relevant statistics in the third if table = TRUE.
The confidence limits at each level are obtained by inverting the
monotone relationship between the parameter of interest and the
statistic with the same interpolating smoothing spline used
internally by likelihoodAsy (Bellio & Pierce), so limits at
the 90\
$CIr) from the input object.
Levels that would require extrapolating beyond the grid of
psivals covered by the input object are dropped with a
message, since spline extrapolation outside the computed range of
the statistic is not reliable.
Pierce DA, Bellio R. Modern likelihood-frequentist inference. International Statistical Review. 2017;85:519-541.
Bellio R, Pierce DA. likelihoodAsy: Functions for Likelihood Asymptotics.
if (FALSE) { # \dontrun{
library(likelihoodAsy)
# log likelihood, data generator, and interest function as in
# the likelihoodAsy vignette (Weibull regression on the leuk data)
rs.int <- rstar.ci(
data = data.fz, thetainit = c(0, 0, 0), floglik = loglik.Wbl,
fpsi = psifcn.Wbl, datagen = gendat.Wbl, seed = 1223
)
curve1 <- curve_rstar(rs.int)
ggcurve(curve1[[1]], type = "c")
} # }