Collin Nolte
12/07/2020
[This slide intentionally left blank]
GLMs.
\[ \begin{aligned} f(y \ | \theta) &= a(\theta) b(y)\exp(y \ Q(\theta)) \\ E(Y) &= \mu \\ g(\mu) &= \eta = X \beta \end{aligned} \] and we typically go so far as to have a loss function \(L\) to choose between competing models.
fit <- glm(y ~ ., family = binomial(link = "logit"))
Here, we can give a simple illustration of what this looks like in R. We have a simple bootstrap process, and a statistic that we would like to bootstrap
bootstrap <- function(x, statistic, n = 1000L) {
replicate(n, expr = {
samp <- sample(x, replace = TRUE)
statistic(samp)
})
}
x <- rnorm(100L)
bs_mean <- bootstrap(x, mean)
bs_median <- bootstrap(x, median)
Suppose that in addition to the functions above, I also wanted to consider a trimmed mean, to account for potential outliers. We’ll decide to remove the largest and smallest 10%
bootstrap <- function(x, statistic, n = 1000L) {
replicate(n, expr = {
samp <- sample(x, replace = TRUE)
statistic(samp)
})
}
bs_trim <- bootstrap(x, mean(trim = 0.1))
## Error in mean.default(trim = 0.1): argument "x" is missing, with no default
mean(trim = .1)("Doesn't matter what I put here")
## Error in mean.default(trim = 0.1): argument "x" is missing, with no default
bootstrap <- function(x, statistic, n = 1000L) {
statistic <- not_magic(statistic)
replicate(n, expr = {
samp <- sample(x, replace = TRUE)
statistic(samp)
})
}
bs_trim <- bootstrap(x, mean(trim = 0.1))
R Core Team (2020). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
Wickham, H. (2014) Advanced R . Boca Raton, FL. CRC Press
Michael Seedorff, Jacob Oleson, Grant Brown, Joseph Cavanaugh and Bob McMurray (2020). bdots: Bootstrapped Differences of Time Series. R package version 0.1.30.