p_mediation | R Documentation |
Simple 3-variable mediation analysis simulation to test the hypothesis that X -> Y is mediated by the relationship X -> M -> Y. Currently, M and Y are assumed to be continuous variables with Gaussian errors, while X may be continuous or dichotomous.
p_mediation(
n,
a,
b,
cprime,
dichotomous.X = FALSE,
two.tailed = TRUE,
method = "wald",
sd.X = 1,
sd.Y = 1,
sd.M = 1,
gen_fun = gen_mediation,
...
)
gen_mediation(
n,
a,
b,
cprime,
dichotomous.X = FALSE,
sd.X = 1,
sd.Y = 1,
sd.M = 1,
...
)
n |
total sample size unless |
a |
regression coefficient for the path X -> M |
b |
regression coefficient for the path M -> Y |
cprime |
partial regression coefficient for the path X -> Y |
dichotomous.X |
logical; should the X variable be generated as though it
were dichotomous? If TRUE then |
two.tailed |
logical; should a two-tailed or one-tailed test be used? |
method |
type of inferential method to use. Default uses the Wald (a.k.a., Sobel) test |
sd.X |
standard deviation for X |
sd.Y |
standard deviation for Y |
sd.M |
standard deviation for M |
gen_fun |
function used to generate the required two-sample data.
Object returned must be a |
... |
additional arguments to be passed to |
a single p-value
Phil Chalmers rphilip.chalmers@gmail.com
gen_mediation
# joint test H0: a*b = 0
p_mediation(50, a=sqrt(.35), b=sqrt(.35), cprime=.39)
p_mediation(50, a=sqrt(.35), b=sqrt(.35), cprime=.39, dichotomous.X=TRUE)
# power to detect mediation
p_mediation(n=50, a=sqrt(.35), b=sqrt(.35), cprime=.39) |>
Spower(parallel=TRUE, replications=1000)
# sample size estimate for .95 power
p_mediation(n=NA, a=sqrt(.35), b=sqrt(.35), cprime=.39) |>
Spower(power=.95, interval=c(50, 200), parallel=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.