Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ojami opened this issue May 12, 2023 · 3 comments
Open

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

Ojami opened this issue May 12, 2023 · 3 comments

Comments

@Ojami
Copy link

Ojami commented May 12, 2023

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
Copy link
Owner

doomlab commented May 12, 2023

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
Copy link
Author

Ojami commented May 12, 2023

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
Copy link
Owner

doomlab commented May 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants