| Title: | Bias Correction via Iterative Bootstrap |
|---|---|
| Description: | An implementation of the iterative bootstrap procedure of Kuk (1995) <doi:10.1111/j.2517-6161.1995.tb02035.x> to correct the estimation bias of a fitted model object. This procedure has better bias correction properties than the bootstrap bias correction technique. |
| Authors: | Samuel Orso [aut, cre], Stéphane Guerrier [ctb], Yuming Zhang [ctb] |
| Maintainer: | Samuel Orso <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.2.1 |
| Built: | 2026-06-01 10:59:41 UTC |
| Source: | https://github.com/smac-group/ib |
Method for generating parametric bootstrap estimates from a fitted model.
bootstrap(object, B = 1000, extra_param = FALSE, ...)bootstrap(object, B = 1000, extra_param = FALSE, ...)
object |
an |
B |
an |
extra_param |
if |
... |
additional optional arguments to pass to |
This method is a simple wrapper around the ib method
where number of iterations is set to 1.
A matrix p (size of parameter) times B of bootstrapped estimates.
Samuel Orso
Method for extracting coefficients from an object in class union "Ib"
## S4 method for signature 'Ib' coef(object, ...)## S4 method for signature 'Ib' coef(object, ...)
object |
an object of class union "Ib" |
... |
further arguments to pass to |
Method for extracting effects from an object in class union "Ib"
## S4 method for signature 'Ib' effects(object, ...)## S4 method for signature 'Ib' effects(object, ...)
object |
an object of class union "Ib" |
... |
further arguments to pass to |
Method for extracting fitted values from an object in class union "Ib"
## S4 method for signature 'Ib' fitted(object, ...)## S4 method for signature 'Ib' fitted(object, ...)
object |
an object of class union "Ib" |
... |
further arguments to pass to |
Method for obtaining estimates from fitted model within any object of class union Ib.
getEst(x) ## S4 method for signature 'Ib' getEst(x)getEst(x) ## S4 method for signature 'Ib' getEst(x)
x |
an object of class union "Ib" |
This methods allow to access extra parameter
estimates. If extra_param=TRUE, it becomes equivalent
to coef.
an estimate (as in getExtra).
Method for obtaining a extra values generated by the iterative bootstrap procedure within any object of class union Ib.
getExtra(x) ## S4 method for signature 'Ib' getExtra(x)getExtra(x) ## S4 method for signature 'Ib' getExtra(x)
x |
an object of class union "Ib" |
a list with the following components:
| iteration | number of iterations () |
| of | value of the objective function
|
| estimate | value of the estimates
|
| test_theta | value for difference of thetas:
|
| ib_warn | optional warning message |
| boot | matrix of bootstrap estimates:
|
Method for obtaining the number of iteration from fitted model within any object of class union Ib.
getIteration(x) ## S4 method for signature 'Ib' getIteration(x)getIteration(x) ## S4 method for signature 'Ib' getIteration(x)
x |
an object of class union "Ib" |
This methods allow to access extra information about the number of iterations.
a number of iterations (as in getExtra).
Method for obtaining a fitted model within any object of class union Ib.
getObject(x) ## S4 method for signature 'Ib' getObject(x)getObject(x) ## S4 method for signature 'Ib' getObject(x)
x |
an object of class union "Ib" |
ib is used to correct the bias of a fitted model object
with the iterative bootstrap procedure.
ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'betareg' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'glm' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'glmerMod' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'lm' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'lmerMod' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'nls' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'vglm' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...)ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'betareg' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'glm' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'glmerMod' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'lm' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'lmerMod' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'nls' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...) ## S4 method for signature 'vglm' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...)
object |
an |
thetastart |
an optional starting value for the iterative procedure.
If |
control |
a |
extra_param |
if |
... |
additional optional arguments (see 'Details'). |
The iterative bootstrap procedure is described in Kuk (1995) and further studied by Guerrier et al. (2019) and Guerrier et al. (2020). The kth iteration of this algorithm is
for and where the sum is over .
The estimate is provided by the object.
The value is a parametric bootstrap
estimate where the bootstrap sample is generated from
and a fixed seed (see ibControl).
The greater the parameter value generally the better bias correction
but the more computation it requires (see ibControl).
If thetastart=NULL, the initial value of the procedure is .
The number of iterations are controlled by maxit parameter of ibControl.
By default, the method correct coefficients only. For
extra parameters, it depends on the model. These extra parameters may have
some constraints (e.g. positivity). If constraint=TRUE (see
ibControl), then a transformation from the constraint space to the
real is used for the update.
For betareg, extra_param is not available
as by default mean and precision parameters are corrected.
Currently the 'identity' link function is not supported for precision
parameters.
For glm, if extra_param=TRUE: the shape parameter for the
Gamma, the variance of the residuals in lm or
the overdispersion parameter of the negative binomial regression in glm.nb,
are also corrected. Note that the quasi families
are not supported for the moment as they have no simulation method
(see simulate). Bias correction for extra parameters
of the inverse.gaussian is not yet implemented.
For glmer, by default, only the fixed effects are corrected.
If extra_param=TRUE: all the random effects
(variances and correlations) are also corrected.
For lm, if extra_param=TRUE: the variance of the residuals is
also corrected. Note that using the ib is not useful as coefficients
are already unbiased, unless one considers different
data generating mechanism such as censoring, missing values
and outliers (see ibControl).
For lmer, by default, only the fixed effects are corrected.
If extra_param=TRUE: all the random effects
(variances and correlations) and the variance
of the residuals are also corrected.
Note that using the ib is
certainly not useful with the argument REML=TRUE in
lmer as the bias of variance components is
already addressed, unless one considers different
data generating mechanism such as censoring, missing values
and outliers (see ibControl).
For nls, if extra_param=TRUE: the variance of the residuals is
also corrected.
For vglm, extra_param is currently not used.
Indeed, the philosophy of a vector generalized linear model is to
potentially model all parameters of a distribution with a linear predictor.
Hence, what would be considered as an extra parameter in glm
for instance, may already be captured by the default coefficients.
However, correcting the bias of a coefficients does not imply
that the bias of the parameter of the distribution is corrected
(by Jensen's inequality),
so we may use this feature in a future version of the package.
Note that we currently only support distributions
with a simslot (see simulate.vlm).
A fitted model object of class Ib.
Samuel Orso
Guerrier S, Dupuis-Lozeron E, Ma Y, Victoria-Feser M (2019).
“Simulation-Based Bias Correction Methods for Complex Models.”
Journal of the American Statistical Association, 114(525), 146-157.
doi:10.1080/01621459.2017.1380031.
https://doi.org/10.1080/01621459.2017.1380031.
Guerrier S, Karemera M, Orso S, Victoria-Feser M, Zhang Y (2020).
“A General Approach for Simulation-based Bias Correction in High Dimensional Settings.”
https://arxiv.org/pdf/2010.13687.pdf.
Version 2: 13 Nov 2020, 2010.13687, https://arxiv.org/pdf/2010.13687.pdf.
Kuk AYC (1995).
“Asymptotically Unbiased Estimation in Generalized Linear Models with Random Effects.”
Journal of the Royal Statistical Society: Series B (Methodological), 57(2), 395-407.
doi:10.1111/j.2517-6161.1995.tb02035.x.
https://rss.onlinelibrary.wiley.com/doi/pdf/10.1111/j.2517-6161.1995.tb02035.x, https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/j.2517-6161.1995.tb02035.x.
## beta regression library(betareg) data("GasolineYield", package = "betareg") ## currently link.phi = "identity" is not supported ## fit_beta <- betareg(yield ~ batch + temp, data = GasolineYield) fit_beta <- betareg(yield ~ batch + temp, link.phi = "log", data = GasolineYield) fit_ib <- ib(fit_beta) # precision parameter can also depend on covariates fit_beta <- betareg(yield ~ batch + temp | temp, data = GasolineYield) fit_ib <- ib(fit_beta) ## poisson regression counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) pois_fit <- glm(counts ~ outcome + treatment, family = poisson()) fit_ib <- ib(pois_fit) summary(fit_ib) ## Set H = 1000 ## Not run: fit_ib <- ib(pois_fit, control=list(H=1000)) summary(fit_ib) ## End(Not run) ## gamma regression clotting <- data.frame( u = c(5,10,15,20,30,40,60,80,100), lot1 = c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12)) fit_gamma <- glm(lot2 ~ log(u), data = clotting, family = Gamma(link = "inverse")) fit_ib <- ib(fit_gamma) ## summary(fit_ib) ## correct for shape parameter and show iterations ## Not run: fit_ib <- ib(fit_gamma, control=list(verbose=TRUE), extra_param = TRUE) summary(fit_ib) ## End(Not run) ## negative binomial regression library(MASS) fit_nb <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine) fit_ib <- ib(fit_nb) ## summary(fit_ib) ## correct for overdispersion with H=100 ## Not run: fit_ib <- ib(fit_nb, control=list(H=100), extra_param = TRUE) summary(fit_ib) ## End(Not run) ## generalized linear mixed-effects regression ## Not run: library(lme4) fit_glmm <- glmer(incidence / size ~ period + (1 | herd), weights = size, family = binomial, data = cbpp) fit_ib <- ib(fit_glmm) summary(fit_ib) ## correct for variances and correlation fit_ib <- ib(fit_glmm, extra_param = TRUE) summary(fit_ib) ## End(Not run) ## linear regression fit_lm <- lm(disp ~ cyl + hp + wt, data = mtcars) fit_ib <- ib(fit_lm) summary(fit_ib) ## correct for variance of residuals fit_ib <- ib(fit_lm, extra_param = TRUE) summary(fit_ib) ## linear mixed-effects regression ## Not run: library(lme4) fit_lmm <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy, REML = FALSE) fit_ib <- ib(fit_lmm) summary(fit_ib) ## correct for variances and correlation fit_ib <- ib(fit_lmm, extra_param = TRUE) summary(fit_ib) ## End(Not run) ## nonlinear regression DNase1 <- subset(DNase, Run == 1) fit_nls <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), data = DNase1) fit_ib <- ib(fit_nls) summary(fit_ib) ## student regression library(VGAM) tdata <- data.frame(x = runif(nn <- 1000)) tdata <- transform(tdata, y = rt(nn, df = exp(exp(0.5 - x)))) fit_vglm <- vglm(y ~ x, studentt3, data = tdata) fit_ib <- ib(fit_vglm) summary(fit_ib)## beta regression library(betareg) data("GasolineYield", package = "betareg") ## currently link.phi = "identity" is not supported ## fit_beta <- betareg(yield ~ batch + temp, data = GasolineYield) fit_beta <- betareg(yield ~ batch + temp, link.phi = "log", data = GasolineYield) fit_ib <- ib(fit_beta) # precision parameter can also depend on covariates fit_beta <- betareg(yield ~ batch + temp | temp, data = GasolineYield) fit_ib <- ib(fit_beta) ## poisson regression counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) pois_fit <- glm(counts ~ outcome + treatment, family = poisson()) fit_ib <- ib(pois_fit) summary(fit_ib) ## Set H = 1000 ## Not run: fit_ib <- ib(pois_fit, control=list(H=1000)) summary(fit_ib) ## End(Not run) ## gamma regression clotting <- data.frame( u = c(5,10,15,20,30,40,60,80,100), lot1 = c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12)) fit_gamma <- glm(lot2 ~ log(u), data = clotting, family = Gamma(link = "inverse")) fit_ib <- ib(fit_gamma) ## summary(fit_ib) ## correct for shape parameter and show iterations ## Not run: fit_ib <- ib(fit_gamma, control=list(verbose=TRUE), extra_param = TRUE) summary(fit_ib) ## End(Not run) ## negative binomial regression library(MASS) fit_nb <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine) fit_ib <- ib(fit_nb) ## summary(fit_ib) ## correct for overdispersion with H=100 ## Not run: fit_ib <- ib(fit_nb, control=list(H=100), extra_param = TRUE) summary(fit_ib) ## End(Not run) ## generalized linear mixed-effects regression ## Not run: library(lme4) fit_glmm <- glmer(incidence / size ~ period + (1 | herd), weights = size, family = binomial, data = cbpp) fit_ib <- ib(fit_glmm) summary(fit_ib) ## correct for variances and correlation fit_ib <- ib(fit_glmm, extra_param = TRUE) summary(fit_ib) ## End(Not run) ## linear regression fit_lm <- lm(disp ~ cyl + hp + wt, data = mtcars) fit_ib <- ib(fit_lm) summary(fit_ib) ## correct for variance of residuals fit_ib <- ib(fit_lm, extra_param = TRUE) summary(fit_ib) ## linear mixed-effects regression ## Not run: library(lme4) fit_lmm <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy, REML = FALSE) fit_ib <- ib(fit_lmm) summary(fit_ib) ## correct for variances and correlation fit_ib <- ib(fit_lmm, extra_param = TRUE) summary(fit_ib) ## End(Not run) ## nonlinear regression DNase1 <- subset(DNase, Run == 1) fit_nls <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), data = DNase1) fit_ib <- ib(fit_nls) summary(fit_ib) ## student regression library(VGAM) tdata <- data.frame(x = runif(nn <- 1000)) tdata <- transform(tdata, y = rt(nn, df = exp(exp(0.5 - x)))) fit_vglm <- vglm(y ~ x, studentt3, data = tdata) fit_ib <- ib(fit_vglm) summary(fit_ib)
ib)S4 classes that wrap fitted model objects and attach extra metadata from the iterative bootstrap procedure.
Members: IbBetareg, IbGlm, IbLm, IbLmer, IbGlmer, IbNegbin, IbNls, IbVglm.
Members include wrappers around models from betareg, stats, lme4, MASS, and VGAM.
These classes are light wrappers: they store the corrected fitted object in
@object (see getObject) and additional information in
@ib_extra (see getExtra).
Objects of the respective S4 classes.
objectThe original fitted model object, corrected by ib.
ib_extraA list of extra metadata from ib.
getObject, getExtra,
Ib, SummaryIb
ib method for negbin object
from glm.nb function of MASS
package.ib method for negbin object
from glm.nb function of MASS
package.
## S4 method for signature 'negbin' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...)## S4 method for signature 'negbin' ib(object, thetastart = NULL, control = list(...), extra_param = FALSE, ...)
object |
an |
thetastart |
an optional starting value for the iterative procedure.
If |
control |
a |
extra_param |
if |
... |
additional optional arguments (see 'Details'). |
Auxiliary function for ib bias correction.
ibControl( tol = 1e-05, maxit = 25, verbose = FALSE, seed = 123L, H = 1L, constraint = TRUE, early_stop = FALSE, cens = FALSE, right = NULL, left = NULL, mis = FALSE, prop = NULL, out = FALSE, eps = NULL, G = NULL, func = function(x) rowMeans(x, na.rm = T), sim = NULL )ibControl( tol = 1e-05, maxit = 25, verbose = FALSE, seed = 123L, H = 1L, constraint = TRUE, early_stop = FALSE, cens = FALSE, right = NULL, left = NULL, mis = FALSE, prop = NULL, out = FALSE, eps = NULL, G = NULL, func = function(x) rowMeans(x, na.rm = T), sim = NULL )
tol |
positive convergence tolerance |
maxit |
|
verbose |
if |
seed |
|
H |
|
constraint |
if |
early_stop |
if |
cens |
if |
right |
|
left |
|
mis |
if |
prop |
|
out |
if |
eps |
|
G |
a |
func |
a |
sim |
a user-defined function for simulating responses (see 'Details') |
sim allows the user to provide its own function for generating
responses. Currently it is only supported for generalized linear models with
the prototype 'fun(object, control, extra_param, ...)' (see ib).
a list with components named as the arguments.
ib, the iterative procedure for bias correction.
Method for plotting an object in class union "Ib"
## S4 method for signature 'Ib,ANY' plot(x, y = NULL, ...)## S4 method for signature 'Ib,ANY' plot(x, y = NULL, ...)
x |
an object of class union "Ib" |
y |
not used |
... |
further arguments to pass to |
Method for making predictions from an object in class union "Ib"
## S4 method for signature 'Ib' predict(object, ...)## S4 method for signature 'Ib' predict(object, ...)
object |
an object of class union "Ib" |
... |
further arguments to pass to |
Method for extracting residuals from an object in class union "Ib"
## S4 method for signature 'Ib' residuals(object, ...)## S4 method for signature 'Ib' residuals(object, ...)
object |
an object of class union "Ib" |
... |
further arguments to pass to |
Method for printing object in class union "Ib"
## S4 method for signature 'Ib' show(object)## S4 method for signature 'Ib' show(object)
object |
an object of class union "Ib" |
Method for printing a summary of
class union SummaryIb.
## S4 method for signature 'SummaryIb' show(object)## S4 method for signature 'SummaryIb' show(object)
object |
a summary object of member of SummaryIb |
Method for simulating responses from an object.
simulation(object, control = list(...), ...) ## S4 method for signature 'Ib' simulation(object, control = list(...), ...)simulation(object, control = list(...), ...) ## S4 method for signature 'Ib' simulation(object, control = list(...), ...)
object |
an object of class union "Ib" |
control |
a control list |
... |
further argument to pass |
simulated responses.
## bootstrap poisson regression counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) pois_fit <- glm(counts ~ outcome + treatment, family = poisson()) ## make 100 paramtric bootstrap replicates boot_dist <- simulate(pois_fit, nsim = 100)## bootstrap poisson regression counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) pois_fit <- glm(counts ~ outcome + treatment, family = poisson()) ## make 100 paramtric bootstrap replicates boot_dist <- simulate(pois_fit, nsim = 100)
simulation method for class IbBetareg, see Ib
## S4 method for signature 'betareg' simulation(object, control = list(...), extra = NULL, ...)## S4 method for signature 'betareg' simulation(object, control = list(...), extra = NULL, ...)
object |
an object of class |
control |
a |
extra |
|
... |
further arguments |
simulation method for class IbGlm, see Ib
## S4 method for signature 'glm' simulation(object, control = list(...), extra = NULL, ...)## S4 method for signature 'glm' simulation(object, control = list(...), extra = NULL, ...)
object |
an object of class |
control |
a |
extra |
|
... |
further arguments |
simulation method for class IbGlmer, see Ib
## S4 method for signature 'glmerMod' simulation(object, control = list(...), ...)## S4 method for signature 'glmerMod' simulation(object, control = list(...), ...)
object |
an object of class |
control |
a |
... |
further arguments. |
simulation method for class IbLm, see Ib
## S4 method for signature 'lm' simulation(object, control = list(...), std = NULL, ...)## S4 method for signature 'lm' simulation(object, control = list(...), std = NULL, ...)
object |
an object of class |
control |
a |
std |
|
... |
further arguments |
simulation method for class Ib, see Ib
## S4 method for signature 'lmerMod' simulation(object, control = list(...), ...)## S4 method for signature 'lmerMod' simulation(object, control = list(...), ...)
object |
an object of class |
control |
a |
... |
further arguments. |
simulation method for class IbNegbin, see Ib
## S4 method for signature 'negbin' simulation(object, control = list(...), extra = NULL, ...)## S4 method for signature 'negbin' simulation(object, control = list(...), extra = NULL, ...)
object |
an object of class |
control |
a |
extra |
|
... |
further arguments |
simulation method for class IbNls, see Ib
## S4 method for signature 'nls' simulation(object, control = list(...), std = NULL, ...)## S4 method for signature 'nls' simulation(object, control = list(...), std = NULL, ...)
object |
an object of class |
control |
a |
std |
|
... |
further arguments |
simulation method for class IbVglm, see Ib
## S4 method for signature 'vglm' simulation(object, control = list(...), extra_param = NULL, ...)## S4 method for signature 'vglm' simulation(object, control = list(...), extra_param = NULL, ...)
object |
an object of class |
control |
a |
extra_param |
|
... |
further arguments |
summary method for class IbBetareg
## S4 method for signature 'IbBetareg' summary(object, ...)## S4 method for signature 'IbBetareg' summary(object, ...)
object |
an object of class IbBetareg |
... |
further arguments passed to |
summary method for class IbGlm
## S4 method for signature 'IbGlm' summary(object, ...)## S4 method for signature 'IbGlm' summary(object, ...)
object |
an object of class IbGlm |
... |
further arguments passed to |
summary method for class IbGlmer
## S4 method for signature 'IbGlmer' summary(object, ...)## S4 method for signature 'IbGlmer' summary(object, ...)
object |
an object of class IbGlmer |
... |
further arguments passed to |
summary method for class IbLm
## S4 method for signature 'IbLm' summary(object, ...)## S4 method for signature 'IbLm' summary(object, ...)
object |
an object of class IbLm |
... |
further arguments passed to |
summary method for class IbLmer
## S4 method for signature 'IbLmer' summary(object, ...)## S4 method for signature 'IbLmer' summary(object, ...)
object |
an object of class IbLmer |
... |
further arguments passed to |
summary method for class IbNegbin
## S4 method for signature 'IbNegbin' summary(object, ...)## S4 method for signature 'IbNegbin' summary(object, ...)
object |
an object of class IbNegbin |
... |
further arguments passed to |
summary method for class IbNls
## S4 method for signature 'IbNls' summary(object, ...)## S4 method for signature 'IbNls' summary(object, ...)
object |
an object of class IbNls |
... |
further arguments passed to |
summary method for class IbVglm
## S4 method for signature 'IbVglm' summary(object, ...)## S4 method for signature 'IbVglm' summary(object, ...)
object |
an object of class IbVglm |
... |
further arguments passed to |
ib wrappersS4 classes that wrap summary objects corresponding to the Ib* classes.
Members: SummaryIbBetareg, SummaryIbGlm, SummaryIbLm, SummaryIbLmer, SummaryIbGlmer, SummaryIbNegbin, SummaryIbNls, SummaryIbVglm.
summThe summary.* object.
ib_extraA list of extra metadata from ib.
Method for calculating covariance matrix from an object in class union "Ib"
## S4 method for signature 'Ib' vcov(object, ...)## S4 method for signature 'Ib' vcov(object, ...)
object |
an object of class union "Ib" |
... |
further arguments to pass to |