bootReg | R Documentation |
Perform bootstrap computation for a regression model. Handle one grouping variable.
bootReg(object, type, FUN.estimate, FUN.stdError, data, load.library, ...)
## S3 method for class 'lm'
bootReg(
object,
type = "coef",
FUN.estimate = NULL,
FUN.stdError = NULL,
data = NULL,
load.library = NULL,
...
)
## S3 method for class 'gls'
bootReg(
object,
type = "coef",
FUN.estimate = NULL,
FUN.stdError = NULL,
data = NULL,
load.library = "nlme",
cluster,
...
)
## S3 method for class 'lme'
bootReg(
object,
type = "coef",
FUN.estimate = NULL,
FUN.stdError = NULL,
data = NULL,
load.library = "nlme",
cluster,
...
)
## S3 method for class 'lvmfit'
bootReg(
object,
type = "coef",
FUN.estimate = NULL,
FUN.stdError = NULL,
data = NULL,
load.library = "lava",
...
)
.bootReg(
object,
data,
strata = NULL,
name.cluster,
FUN.estimate,
FUN.stdError,
FUN.resample = NULL,
FUN.iid = NULL,
n.boot = 1000,
n.cpus = 1,
load.library,
seed = 1,
rejectIfWarning = TRUE,
trace = TRUE
)
object |
the fitted model. |
type |
the type of test for which the bootstrap should be performed. Can be |
FUN.estimate |
the function used to extract the punctual estimates from the model. |
FUN.stdError |
the function used to extract the standard error associated with the punctual estimate (i.e. standard error of the empirical estimator). |
data |
the data that have been used to fit the model. |
load.library |
additional library to load on each CPU. Useful when performing parallel computation. |
... |
ignored |
cluster |
the variable indicating the level where the sample is i.i.d. Only required for gls with no correlation argument. |
strata |
if not |
name.cluster |
internal argument. |
FUN.resample |
the function used simulate new data under the model. Default is |
FUN.iid |
the function used to extract the influence function from the model. |
n.boot |
the number of replications. Should be a large number. |
n.cpus |
the number of cpu to use. |
seed |
set the random number generator |
rejectIfWarning |
Should the estimate be ignored if a warning is returned by the estimation routine? |
trace |
should the execution of the bootstrap be displayed using a progress bar? |
Bootstrap: randomly select observations (or individuals according to argument var.id) to form a new dataset. If the same individual appear several times, a different group value is given for each apparition.
When using multiple cores, even though a seed is set to each core, the result may change depending on how many samples each core is performing.
#### data ####
n <- 1e2
set.seed(10)
df.data <- data.frame(Y = rnorm(n),
group = gl(3, 5, n, labels = c("Ctl","Trt","Neu")),
gender = gl(2, 5, n, labels = c("Female","Male"))[sample.int(n)]
)
#### lm ####
m.lm <- lm(Y ~ group*gender, data = df.data)
## Not run:
resBoot <- bootReg(m.lm, n.boot = 1e4)
## End(Not run)
resBoot
summary(resBoot, type = "norm")
summary(resBoot, type = "basic")
summary(resBoot, type = "stud")
summary(resBoot, type = "perc")
summary(resBoot, type = "bca")
resBoot <- bootReg(m.lm, FUN.resample = "simulate", n.boot = 1e1)
resBoot
#### gls ####
library(nlme)
e.gls <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time),
data = Ovary, correlation = corAR1(form = ~ 1 | Mare))
resBoot <- bootReg(e.gls, n.boot = 1e1)
#### lme ####
e.lme <- lme(follicles ~ sin(2*pi*Time) + cos(2*pi*Time),
data = Ovary, random =~ 1 | Mare)
resBoot <- bootReg(e.lme, n.boot = 1e1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.