adv-r
adv-r copied to clipboard
Typo in Exercise 1 of 10.4.4?
Exercise 1 of 10.4.4 asks
In
boot_model()
, why don’t I need to force the evaluation ofdf
ormodel
?
However, boot_model()
does not look up model
(except as a default in lm
):
boot_model <- function(df, formula) {
mod <- lm(formula, data = df)
fitted <- unname(fitted(mod))
resid <- unname(resid(mod))
rm(mod)
function() {
fitted + sample(resid)
}
}
Is this a typo with the correct formulation as follows?
In
boot_model()
, why don’t I need to force the evaluation ofdf
orformula
?