Open AmeliaMN opened 7 years ago
(I'd take fixing PRs or suggestions on tibble debugging)
The issue has to do with the multinested lists that modelr::bootstrap()
returns. (Why this does not create problems for lm()
is beyond me.) Most likely there's a better way, but I believe this works:
fn_alpha = function(strap){
data <- strap$data
idx <- strap$idx
X <- data$X[idx]
Y <- data$Y[idx]
(var(Y) - cov(X,Y)) / (var(X) + var(Y) - 2 * cov(X,Y))
}
I just did a pass through lab 7, and referenced @ijlyttle's bootstrap example page to tidy the bootstrap model areas.
However, the text of the book introduces the bootstrap as something that can be used to estimate any parameter. It is calculating
alpha=var(Y)-cov(X,Y))/(var(X)+var(Y)-2*cov(X,Y)
for the example. I tried to usemodelr::bootstrap()
to do this example and keep getting into impenetrable errors (probably because I am not used to debugging with tibbles). I've tried a variety of ways of defining the function, fromto
and many things in between. These work on a single case, like
but when I try to extend using
bootstrap()
they breakSome error messages:
Error: 'x' is NULL
andError: no applicable method for 'summarise_' applied to an object of class "resample"
(for the two function definitions, respectively).Can anyone help? Look here for this example in context.