I am doing a "Statistical learning in R" online course which requires me to do exercises in R and right now, i'm stuck at a part that requires me to use the bootstrap.
I'm not sure whether it is allowed to ask about homework problems on here, but i have been looking around different forums and tutorials for a while and i can't really put my head around this.
So the original question is
Now, use the (standard) bootstrap to estimate s.e.($ \hat{\beta_1} $) . To within 10%, what do you get?
A dataset is given and in previous questions i was required to estimate the standard error of $\beta_1$ from a linear model on the data. The set Xy consists of three variables with 1000 entries each (X1, X2 and Y).
In my attempt of a solution, i have tried to stay close to the original code used in the Video lesson.
library(ISLR)
library(boot)
alpha.fn=function(data,index){
X=data$X[index]
Y=data$Y[index]
return((var(Y)-cov(X,Y))/(var(X)+var(Y)-2*cov(X,Y)))}
#"renaming my variables to fit the alpha function"
Xy$X=Xy$X1;
Xy$Y=Xy$y;
set.seed(1)
alpha.fn(Xy,sample(100,100,replace=T))
boot(Xy,alpha.fn,R=1000)
Now i don't know whether this is the "standard" bootstrap i intend to use or how to pass the function that i want to estimate the std. error to within 10%. does it mean i just want it to 0.1 accuracy?
lm
and then focus on bootstrap without usingboot
. It is not difficult, just afor
loop. No idea what is meant by "within 10%", it is strange. $\endgroup$