I used next program code to estimate the standard error using bootstrap for Libras Data movement set:
mydata<-read.table('C:/Users/Desktop/libra.txt', sep=',', header=TRUE)
head(data)
custom.boot <- function(times, data=mydata) {
boots <- rep(NA, times)
for (i in 1:times) {
boots[i] <- sd(sample(data, length(data), replace=TRUE))/sqrt(length(data))
}
boots
}
# Mean standard error
mean(custom.boot(times=1000))
But I got next error:
Error in is.data.frame(x) :
(list) object cannot be coerced to type 'double'
Could you help me to figure out the problem and give advice how it can be solved? Thanks in advance!
The
mydata
object is being read in as a 395 x 91data.frame
whichcustom.boot
is struggling with. When I added changed todata = mydata[, 1]
the function ran without an error. If you want to leave your function as is, I would either loop through every column or stack all the columns into one long column.EDIT:
If you want to loop through all the columns of this
data.frame
, I would write a loop similar to what you have but one that slices by each column: