Description Usage Arguments Details Value Author(s) References See Also Examples
Generate bootstrap samples using the wild bootstrap method introduced by Wu (1986). One of the advantages for the wild bootstrap method is that it allows for a heterogeneous variance in the residuals in regression analysis.
1 | wild.boot(x, nboot = 1)
|
x |
a vector of regression residuals. |
nboot |
the number of bootstrap replicates. Usually this will be a single positive integer. |
This function is to generate bootstrap residuals using the wild bootstrap method.
a vector or a matrix.
X.F. Wang wangx6@ccf.org
Wu, C. (1986) Jackknife, bootstrap and other resampling methods in regression analysis (with discussion). Annals of Statistics. 14, 1261–1350.
Mammen, E. (1991). Bootstrap, wild bootstrap, and asymptotic normality. Probability Theory and Related Fields. 93, 439–455.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | n <- 1000
x <- runif(n, min=0, max=1)
## generate heteroscedastic error variances
sig.x <- sqrt(exp(x)/2.5-0.4)
err <- sapply(sig.x, function(x) rnorm(1, sd=x))
x2 <- x^2
y <- 10+3*x+2*x2 +err
plot(x,y)
fit <- lm(y ~ x + x2)
## obtain 12 samples of the wild bootstrap residuals
res.boot <- wild.boot(fit$res, nboot=12)
## obtain 12 samples of the wild bootstrap responses
y.boot <- matrix(rep(fit$fit,time=12), ncol=12) + res.boot
## plot the 12 wild bootstrap samples
## The wild bootstrap method keeps the patterns of variance heterogeneity
## in the orginal sample.
par(mfrow=c(4,3))
for (i in 1:12) plot(x, y.boot[,i])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.