Learn R Programming

polywog (version 0.4-1)

bootPolywog: Bootstrap a fitted polywog model

Description

Nonparametric bootstrap of the polywog regression procedure. Can be run on a fitted model of class "polywog", or within the original procedure via the boot argument. The function control.bp can be used to pass options to bootPolywog when bootstrapping within polywog.

Usage

bootPolywog(model, nboot = 100, .parallel = FALSE, reuse.lambda = FALSE,
  reuse.penwt = FALSE, nlambda = 100, lambda.min.ratio = 1e-04,
  nfolds = 10, thresh = NULL, maxit = NULL, maxtries = 1000,
  min.prop = 0, report = FALSE, .matrixOnly = FALSE)

control.bp(.parallel = FALSE, reuse.lambda = FALSE, reuse.penwt = FALSE, nlambda = 100, lambda.min.ratio = 1e-04, nfolds = 10, thresh = NULL, maxit = NULL, maxtries = 1000, min.prop = 0, report = FALSE)

Arguments

model

a fitted model of class "polywog", typically the output of polywog or the "polywog.fit" element of the output of cv.polywog.

nboot

number of bootstrap iterations.

.parallel

logical: whether to perform computations in parallel using a backend registered with foreach.

reuse.lambda

logical: whether to use the penalization parameter from the original fit (TRUE), or to cross-validate within each iteration (FALSE, default).

reuse.penwt

logical: whether to use the penalty weights from the original fit (TRUE), or to re-calculate them within each iteration (FALSE, default).

nlambda

number of values of the penalty factor to examine in cross-validation, as in polywog.

lambda.min.ratio

ratio of the smallest value of the penalty factor to the largest, as in polywog.

nfolds

number of cross-validation folds to use.

thresh

convergence threshold, as in polywog. If NULL, use the same value as in the original model.

maxit

iteration limit for fitting, as in polywog. If NULL, use the same value as in the original model.

maxtries

maximum number of attempts to generate a bootstrap sample with a non-collinear model matrix (often problematic with lopsided binary regressors) before stopping and issuing an error message.

min.prop

for models with a binary response variable, minimum proportion of non-modal outcome to ensure is included in each bootstrap iteration (for example, set min.prop = 0.1 to throw out any bootstrap iteration where less than 10 percent or more than 90 percent of the observations are 1's).

report

logical: whether to print a status bar. Not available if .parallel = TRUE.

.matrixOnly

logical: whether to return just the matrix of bootstrap coefficients (TRUE), or the originally supplied model with the bootstrap matrix as the boot.matrix element (FALSE, default).

Value

If .matrixOnly = FALSE, the returned object is model with the bootstrap matrix included as its boot.matrix element. If .matrixOnly = TRUE, just the matrix is returned. In either case, the bootstrap matrix is a sparse matrix of class "'>dgCMatrix".

Details

Parallel computation via the .parallel argument requires registation of a backend for %dopar%, as in polywog. In the case of bootPolywog, bootstrap fitting is carried out in parallel, while cross-validation to choose the penalization factor (assuming reuse.lambda = FALSE) is carried out sequentially within each iteration.

Examples

Run this code
# NOT RUN {
## Using occupational prestige data
data(Prestige, package = "carData")
Prestige <- transform(Prestige, income = income / 1000)

## Fit a polywog model without bootstrapping
## (note: using low convergence threshold to shorten computation time of the
## example, *not* recommended in practice!)
fit1 <- polywog(prestige ~ education + income + type,
                data = Prestige,
                degree = 2,
                thresh = 1e-4)
summary(fit1)

## Bootstrap the fitted model
fit2 <- bootPolywog(fit1, nboot = 5)
summary(fit2)

## Example of parallel processing on Mac/Unix via 'doMC'
# }
# NOT RUN {
library(doMC)
registerDoMC()

fit2 <- bootPolywog(fit1, nboot = 100, .parallel = TRUE)
# }
# NOT RUN {
## Example of parallel processing on Windows via 'doSMP'
# }
# NOT RUN {
library(doSMP)
w <- startWorkers()
registerDoSMP(w)

fit2 <- bootPolywog(fit1, nboot = 100, .parallel = TRUE)

stopWorkers(w)
# }

Run the code above in your browser using DataLab