Skip to contents

Combines eleven classical and directed goodness-of-fit statistics with weights that were fixed offline and ship frozen, and calibrates the combination by a parametric bootstrap at the fitted parameters. Nothing is retrained when you call it.

Usage

legoft(object, B = 199, seed = NULL, weights = NULL)

Arguments

object

a fitted binomial glm.

B

number of parametric-bootstrap replicates for the reference distribution. 199 gives a smallest attainable p-value of 0.005; raise it for smaller p-values.

seed

optional integer for reproducibility.

weights

optional named vector of member weights; defaults to the frozen rule. Supplying your own makes the result no longer the shipped procedure – say so if you report it.

Value

an object of class "legoft": the statistic, its bootstrap p-value, the member p-values, and B_used.

Details

The p-value is exact in finite samples when the null parameters are known. With the parameters estimated – the case here – the calibration is asymptotic; simulation at \(n = 500\) put the empirical size at 0.037 against a nominal 0.05.

See also

legoft.localize for which domain of evidence carries the misfit.

Examples

# \donttest{
set.seed(1)
x1 <- runif(300, -3, 3); x2 <- rnorm(300)
y  <- rbinom(300, 1, plogis(0.3 + 0.8 * x1 - 0.5 * x2 + 0.25 * x1^2))
fit <- glm(y ~ x1 + x2, family = binomial())
legoft(fit, B = 99, seed = 1)
#> 
#> LEGofT (frozen weights, parametric-bootstrap calibration)
#> 
#>   statistic = 9520.2744    p-value = 0.0200    (B = 99)
#> 
# }