kosukeimai / mediation

R package mediation
58 stars 29 forks source link

An issue with the BCa CI implementation? #19

Open Tal-Golan opened 4 years ago

Tal-Golan commented 4 years ago

This is most probably my own misunderstanding, but I'm wondering whether bootstrap CIs are correctly implemented. Two questions:

  1. In line 1584 of mediate.py, z_0 is calculated by compare theta to mean theta.

            z.inv <- length(theta[theta < mean(theta)])/sims

    However, eq. 2.8 in DiCiccio & Efron, 1996 is different: theta is compared to the original, non-bootstrapped statistic. The current implementation assumes that the mean of the bootstrap distribution equals to the original statistic. Is this necessarily true?

  2. In line 1586, U is calculated, in a way that seem to follow eq. 6.7 in the paper:

    U <- (sims - 1) * (mean(theta) - theta)

    However, eq. 6.7 uses jackknife estimator, not the bootstrap estimator. Is the usage of the bootstrap estimator here justified?

stepls commented 2 years ago

Hi there,

Regarding your second question: If I am not mistaken, using theta instead of the jacknife estimator leads, in this specific application, to the acceleration constant a having the wrong sign.

With kind regards, stepls

stepls commented 2 years ago

As it turns out, I was mistaken. In Efron's and Tibshirani's Introduction to the Bootstrap (1993), the acceleration constant is defined in equation (14.14) on page 186.

It is calculated from the jackknife replication of the original dataset and does not depend on what happens during bootstrapping.