2
$\begingroup$

To test one of my hypotheses, I want to show that the effect size A -> B is significanlty larger than C -> D using R.

So far, I've been using the mes() function from the compute.es package to calculate the effect sizes.

Let's say we have the following values:

Function: mes(mean1, mean2, sd1, sd2, n1, n2)
# Effect size 1: A -> B
mes(4.53, 5.57, 1.04, 0.70, 45, 47)
# Effect size 2: C -> D
mes(5.69, 6.12, 0.85, 0.57, 48, 48)

How can I show, that the effect size 1 is significantly larger than 2 using R?

$\endgroup$

1 Answer 1

4
$\begingroup$

Fit two linear models to compute each effect, e.g.

m1 <- lm(B ~ A) #Here I am assuming the effect A -> B means A is influencing B
m2 <- lm(D ~ C)

Get the estimated effect sizes and their standard errors:

b1 <- coef(summary(m1))[2, 1]
b2 <- coef(summary(m2))[2, 1]
SEb1 <- coef(summary(m1))[2, 2]
SEb2 <- coef(summary(m2))[2, 2]

Calculate the $Z$-score for the difference:

Z <- (b1-b2)/sqrt(SEb1^2+SEb2^2)

And calculate the corresponding P-value:

2*pnorm(-abs(Z))

Reference: Marloes (https://stats.stackexchange.com/users/18334/marloes), Test a significant difference between two slope values, URL (version: 2013-04-09): https://stats.stackexchange.com/q/55505

$\endgroup$
3
  • $\begingroup$ For bonus points, can you rewrite as a function taking mod1, mod2 as arguments? $\endgroup$
    – smci
    Commented Jun 26, 2018 at 0:49
  • $\begingroup$ @smci something like this. $\endgroup$
    – Mihail
    Commented Jun 26, 2018 at 9:55
  • $\begingroup$ Totally. I was suggesting posting the function as your answer. If the return-value is p-value, I'd call the function ptest.lm.es or somesuch $\endgroup$
    – smci
    Commented Jun 29, 2018 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.