# Import libaries
library(boot)
# Create sample dataframe
set.seed(1)
x <- rnorm(1000, sd=10)
y <- rnorm(1000, sd=1)
df <- data.frame(x,y)
# Create function to pass to boot()
calc_mean = function(data, index){
mean_x <- mean(df$x[index])
return(mean_x)
}
boot(df$x, calc_mean, R=1000)
library(boot)
boot_returns <- function(data, indices){
d <- data[indices]
Return.calculate(d, method="log")
}
bret <- boot(end_eq, boot_returns, R=1000)
dim(bret$t)
bretMeans <- colMeans(bret$t, na.rm = TRUE)