how to implement the jaccknife method in the case where two terms are removed (in R)

2

I created the following code to calculate the variance using the jackknife method.  However, instead of removing one term at a time, I now need to remove it by 2 in 2.  I know it's something basic, but I could not think how to do it, could anyone give me some idea?

A<- numeric(1000)


var1<- numeric(1000)

x<- data.frame(numeric(9))

amostra<- rnorm(10,100,10) #gerando amostra

for(i in 1:10){

x[i]<-c(amostra[-i]) #tirando um termo da amostra

}

var2<- numeric(10) #calculando as variancias dos vetores n-1

for(i in 1:10){

  var2[i]<- var(x[,i])
}

Tn<- sum(var2) #soma das variancias de 3 termos

var1[j] <- var(amostra)# variancia da amstra de tamanho n


A[j]<-10*var1[j]-((9/10)*Tn) #  variancia Jackknife
    
asked by anonymous 08.04.2018 / 21:43

2 answers

0

I'll help you find var2 and Tn . From there I did not understand what you did.

#Todas as combinações de índices de 10 elementos tomados 8 a 8.
idx <- t(combn(10, 8))
#Todas as sub-amostras de 8 elementos
x <- apply(idx, 2, function(x){amostra[x]})
#Variancia de cada sub-amostra
var2 <- apply(x, 1, var)
# soma das variancias
Tn <- sum(var2)

Check everything, because it was not clear to me what the content of x should be.

    
09.04.2018 / 02:30
0

I've tried the following:

As you want to remove two by two, the dataframe should have 8 lines, otherwise the data relocation will be incompatible, since two values are being taken at a time:

x<- data.frame(numeric(8))

amostra<- rnorm(10,100,10) #gerando amostra

amostra

[1] 108.27618  99.33371 122.50547 105.59071  89.95836 108.99908 101.51803  96.98692 100.51190 102.91556

for(i in 1:8){
  x[i]<- c(amostra[-c(i,i+1)]) # retira dois termos por iteração
}

x

numeric.8.        V2        V3        V4        V5        V6        V7        V8
1  122.50547 108.27618 108.27618 108.27618 108.27618 108.27618 108.27618 108.27618
2  105.59071 105.59071  99.33371  99.33371  99.33371  99.33371  99.33371  99.33371
3   89.95836  89.95836  89.95836 122.50547 122.50547 122.50547 122.50547 122.50547
4  108.99908 108.99908 108.99908 108.99908 105.59071 105.59071 105.59071 105.59071
5  101.51803 101.51803 101.51803 101.51803 101.51803  89.95836  89.95836  89.95836
6   96.98692  96.98692  96.98692  96.98692  96.98692  96.98692 108.99908 108.99908
7  100.51190 100.51190 100.51190 100.51190 100.51190 100.51190 100.51190 101.51803
8  102.91556 102.91556 102.91556 102.91556 102.91556 102.91556 102.91556 102.91556
    
08.04.2018 / 23:06