doomlab / MeMoBootR

A package for mediation, moderation, and bootstrapped indirect effects
MIT License
21 stars 7 forks source link

How to get Z and P-value for mediation2? #10

Open Ojami opened 1 year ago

Ojami commented 1 year ago

Hi and thanks for this great package,

I was wondering how one can calculate P for the indirect effect in the mediation2 func?

Best/Oveis

doomlab commented 1 year ago

Hi @Ojami

I don't know that I've seen the p-values since there are three indirect effects. Most people use the confidence interval from the bootstrap to determine if it includes zero or not. I suppose you could calculate sobel separately for each indirect effect, but I'm not sure how you'd do it for the two part mediation. Do you have a reference I could look at?

erin

Ojami commented 1 year ago

Hi Erin,

Thanks for your response. Yes, I've seen mostly bootstrapped CIs only. However, lavaan::sem() outputs z and p (an example).

Also, if I'm not wrong mediation1 uses Sobel for z, while mediation::mediate() uses bootstrapped P directly (boot$t):

pval <- function(x, xhat){
  ## Compute p-values
  if (xhat == 0) out <- 1
  else {
    out <- 2 * min(sum(x > 0), sum(x < 0)) / length(x)
  }
  return(min(out, 1))
}

So, I was wondering why one cannot use the same approach for serial mediation analysis? Given a large sample size, I suppose (?) bootstrap Z (boot.results$t0/sd(boot.results$t)) should converge to Sobel's Z. Am I mistaken?

Best/Oveis

doomlab commented 1 year ago

Good points. I'll check that out. And I would think so ... the t-values for all of them are in there saved under indirect, so then you could calculate p with pt(T_VALUE, df = DF_VALUE, lower.tail = FALSE).

erin