Learn R Programming

mboost (version 2.9-11)

confint.mboost: Pointwise Bootstrap Confidence Intervals

Description

Compute and display pointwise confidence intervals

Usage

# S3 method for mboost
confint(object, parm = NULL, level = 0.95, B = 1000,
        B.mstop = 25, newdata = NULL, which = parm,
        papply = ifelse(B.mstop == 0, mclapply, lapply),
        cvrisk_options = list(), ...)
# S3 method for mboost.ci
plot(x, which, level = x$level, ylim = NULL, type = "l", col = "black",
     ci.col = rgb(170, 170, 170, alpha = 85, maxColorValue = 255),
     raw = FALSE, print_levelplot = TRUE,...)
# S3 method for mboost.ci
lines(x, which, level = x$level,
     col = rgb(170, 170, 170, alpha = 85, maxColorValue = 255),
     raw = FALSE, ...)

# S3 method for glmboost confint(object, parm = NULL, level = 0.95, B = 1000, B.mstop = 25, which = parm, ...) # S3 method for glmboost.ci print(x, which = NULL, level = x$level, pe = FALSE, ...)

Value

An object of class glmboost.ci or mboost.ci with special

print and/or plot functions.

Arguments

object

a fitted model object of class glmboost, gamboost or mboost for which the confidence intervals should be computed.

parm, which

a subset of base-learners to take into account for computing confidence intervals. See mboost_methods for details. parm is just a synonyme for which to be in line with the generic confint function. Preferably use which.

level

the confidence level required.

B

number of outer bootstrap replicates used to compute the empirical bootstrap confidence intervals.

B.mstop

number of inner bootstrap replicates used to determine the optimal mstop on each of the B bootstrap samples.

newdata

optionally, a data frame on which to compute the predictions for the confidence intervals.

papply

(parallel) apply function for the outer bootstrap, defaults to mclapply if no inner bootstrap is used to determine the optimal stopping iteration. For details see argument papply in cvrisk. Be careful with your computing resources if you use parallel computing for both, the inner and the outer bootstrap.

cvrisk_options

(optionally) specify a named list with arguments to the inner bootstrap. For example use cvrisk_options = list(mc.cores = 2) to specify that the mclapply function within cvrisk uses 2 cores to compute the optimal mstop.

x

a confidence interval object.

ylim

limits of the y scale. Per default computed from the data to plot.

type

type of graphic for the point estimate, i.e., for the predicted function. Per default a line is plotted.

col

color of the point estimate, i.e., for the predicted function.

ci.col

color of the confidence interval.

raw

logical, should the raw function estimates or the derived confidence estimates be plotted?

print_levelplot

logical, should the lattice levelplot be printed or simply returned for further modifications. This argument is only considered if bivariate effect estimates are plotted. If print_levelplot is set to FALSE, a list with objects mean, lowerPI and upperPI is returned containing the three levelplot objects.

pe

logical, should the point estimtate (PE) be also returned?

...

additional arguments to the outer bootstrap such as mc.cores.

Author

Benjamin Hofner <benjamin.hofner@pei.de>

Details

Use a nested boostrap approach to compute pointwise confidence intervals for the predicted partial functions or regression parameters. The approach is further described in Hofner et al. (2016).

References

Benjamin Hofner, Thomas Kneib and Torsten Hothorn (2016), A Unified Framework of Constrained Regression. Statistics & Computing, 26, 1--14.

See Also

cvrisk for crossvalidation approaches and mboost_methods for other methods.

Examples

Run this code
if (FALSE) {
############################################################
## Do not run these examples automatically as they take
## some time (~ 30 seconds depending on the system)

### a simple linear example
set.seed(1907)
data <- data.frame(x1 = rnorm(100), x2 = rnorm(100),
                   z = factor(sample(1:3, 100, replace = TRUE)))
data$y <- rnorm(100, mean = data$x1 - data$x2 - 1 * (data$z == 2) +
                            1 * (data$z == 3), sd = 0.1)
linmod <- glmboost(y ~ x1 + x2 + z, data = data,
                   control = boost_control(mstop = 200))

## compute confidence interval from 10 samples. Usually one should use
## at least 1000 samples.
CI <- confint(linmod, B = 10, level = 0.9)
CI

## to compute a confidence interval for another level simply change the
## level in the print function:
print(CI, level = 0.8)
## or print a subset (with point estimates):
print(CI, level = 0.8, pe = TRUE, which = "z")

### a simple smooth example
set.seed(1907)
data <- data.frame(x1 = rnorm(100), x2 = rnorm(100))
data$y <- rnorm(100, mean = data$x1^2 - sin(data$x2), sd = 0.1)
gam <- gamboost(y ~ x1 + x2, data = data,
                control = boost_control(mstop = 200))

## compute confidence interval from 10 samples. Usually one should use
## at least 1000 samples.
CI_gam <- confint(gam, B = 10, level = 0.9)

par(mfrow = c(1, 2))
plot(CI_gam, which = 1)
plot(CI_gam, which = 2)
## to compute a confidence interval for another level simply change the
## level in the plot or lines function:
lines(CI_gam, which = 2, level = 0.8)
}

Run the code above in your browser using DataLab