Cross Validated Asked by Arun on November 9, 2020

I have an OLS regression with a binary treatment X and a binary moderating variable M, where the regression equation is:

$$

Y = alpha + beta_1 X + beta_2 M + beta_3(X times M).

$$

The effect of $X$ on $Y$ is $beta_1$ when $M=0$ and $(beta_1 +beta_3)$ when $M=1$. How can I calculate the standard errors/confidence intervals of $(beta_1 +beta_3)$?

In the working example below, the estimated effects of $X$ on $Y$ are $144$ ($M=0$) and $185$ ($M=1$). While the standard error for $X$ if $M=0$ is $22.76$, I am a bit confused about how to calculate the standard error for $X$ on $Y$ given $M=1$.

```
set.seed(1)
X <- sample(0:1, 200, replace = T)
M <- sample(0:1, 200, replace = T)
# effect of X on Y is 150 if M==0 and 200 if M==1
Y <- 450 + 150 * X + 500 * M + 50 * (X * M) + rnorm(200, sd = 100)
summary(lm(Y ~ X + M + X*M))
Call:
lm(formula = Y ~ X + M + X * M)
Residuals:
Min 1Q Median 3Q Max
-285.362 -83.993 -6.954 82.133 267.919
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 441.38 16.01 27.569 < 2e-16 ***
X 144.49 22.76 6.347 1.49e-09 ***
M 508.27 22.52 22.566 < 2e-16 ***
X:M 40.22 31.20 1.289 0.199
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 109.8 on 196 degrees of freedom
Multiple R-squared: 0.8702, Adjusted R-squared: 0.8682
F-statistic: 437.8 on 3 and 196 DF, p-value: < 2.2e-16
```

Using Gaussian error propagation:

```
summary(fit <- lm(Y ~ X + M + X*M))
sigma2mat <- vcov(fit)[-c(1, 3), -c(1, 3)]
sum(coef(fit)[-c(1, 3)]) + c(-1.96, 1.96) * sqrt(sum(sigma2mat))
#[1] 147.3562 226.2858
```

Using bootstrapping:

```
library(boot)
DF <- data.frame(X, M, Y)
set.seed(42)
myboot <- boot(DF, function(DF, i) {
fit <- lm(Y ~ X + M + X*M, data = DF[i,])
sum(coef(fit)[-c(1, 3)])
}, 999)
boot.ci(myboot)
#Intervals :
#Level Normal Basic
#95% (146.4, 226.5 ) (147.6, 226.3 )
#
#Level Percentile BCa
#95% (147.3, 226.1 ) (143.2, 221.9 )
#Calculations and Intervals on Original Scale
```

Correct answer by Roland on November 9, 2020

1 Asked on December 13, 2020 by svexo

1 Asked on December 12, 2020 by aakash-bashyal

0 Asked on December 12, 2020 by samme-galanakis

1 Asked on December 11, 2020 by sue-doh-nimh

0 Asked on December 11, 2020 by luchonacho

1 Asked on December 11, 2020 by rumtscho

assumptions exchangeability permutation test random variable terminology

1 Asked on December 10, 2020 by quant_dev

1 Asked on December 10, 2020

asymptotics convergence estimation expected value normality assumption

1 Asked on December 10, 2020 by st4co4

2 Asked on December 10, 2020 by yaynikkiprograms

0 Asked on December 10, 2020 by statboy_41

data transformation generalized linear model interpretation link function sas

0 Asked on December 9, 2020 by aite97

0 Asked on December 9, 2020 by pinocchio

machine learning mean non independent standard deviation standard error

1 Asked on December 9, 2020 by andrew-kirk

0 Asked on December 9, 2020 by s-ramagokula-krishnan

0 Asked on December 9, 2020 by johanna

backpropagation gradient descent neural networks regression sgd

0 Asked on December 9, 2020 by ayberk-yavuz

1 Asked on December 9, 2020 by roromario

Get help from others!

Recent Answers

- Lex on Does Google Analytics track 404 page responses as valid page views?
- Jon Church on Why fry rice before boiling?
- Peter Machado on Why fry rice before boiling?
- haakon.io on Why fry rice before boiling?
- Joshua Engel on Why fry rice before boiling?

Recent Questions

- How Do I Get The Ifruit App Off Of Gta 5 / Grand Theft Auto 5
- Iv’e designed a space elevator using a series of lasers. do you know anybody i could submit the designs too that could manufacture the concept and put it to use
- Need help finding a book. Female OP protagonist, magic
- Why is the WWF pending games (“Your turn”) area replaced w/ a column of “Bonus & Reward”gift boxes?
- Does Google Analytics track 404 page responses as valid page views?

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir