x <- c(0.75,2.55,1.40,0.80,2.60)
y <- c(0.8249,0.797,0.7762,0.7797,0.7483)
da <- data.frame(x,y)
corr(da)
mean(boot(da,corr,10000)$t)
#Esta função eu fiz para evitar NAs, já que algumas amostragens são todas iguais, gerando um desvio padrão zero.
sa <- function(x){
y <- sample(x,replace=T)
if(y[1:1] == y[2:2] && y[1:1] == y[3:3] && y[1:1] == y[4:4] && y[1:1] == y[5:5]){
z <- sample(x,replace=T)}else{
y}
}
boot_da <- numeric(10000)
n <- 10000)
for(i in 1:n){
boot_da[[i]] <- corr(matrix(c(sa(da[,1]),sa(da[,2])),ncol=2))
}
boot_da
mean(boot_da)
Se alguém puder ajudar de novo, agradeço.
Abraços!
Allaman
(S,f,P)