The r output I would get is just the summary of a fitted model. For example:

fitmodel = lm(formula = response ~ categorical + predictor)

I'm also given a $t_{0.25}$ value.

The categorical variable has 2 possible values ("yes" and "no"). So, from the output, how do I find (by hand) a 95% confidence interval for the difference between "yes" and "no"? In particular, how would I find the stand error for the difference?

What I know:

  • I know how to find the coefficients from the output
  • I know the general formula for the confidence interval

Let's take a toy example in R:

fEffect <- sample(c(0,1), size = 15, replace = TRUE)
rEffect <- rnorm(15, mean = 3)
y <- 2 * fEffect + 0.4 * rEffect + rnorm(15)

summary(lm(y ~ fEffect + rEffect))

(I set the seed for replicability.) The output from this linear model is:

lm(formula = y ~ fEffect + rEffect)

     Min       1Q   Median       3Q      Max 
-0.98166 -0.83153 -0.08039  0.75780  1.27464 

            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  -0.2176     1.1684  -0.186  0.85540   
fEffect       2.0093     0.4751   4.229  0.00117 **
rEffect       0.5156     0.3496   1.475  0.16605   
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8564 on 12 degrees of freedom
Multiple R-squared:  0.6533,    Adjusted R-squared:  0.5956 
F-statistic: 11.31 on 2 and 12 DF,  p-value: 0.001736

As you can see from this output, the estimate for the fixed effect is 2.0093, and the standard error of the fixed effect is 0.4751, the Student's $t$ statistic for $\alpha = 0.25$ on 12 degrees of freedom is 2.179. Thus, the confidence interval for this estimate is

$$ \beta_1 \in 2.0093 \pm 2.179 \times 0.4751 = (0.9741,3.0445). $$

As we can see, this interval does not contain 0, so we reject the null claim that $\beta_1 = 0$. Furthermore, while we know that the response, $y$, is in fact related to the random effect (because we created it to be so), the confidence interval for that estimate does contain 0:

$$ \beta_2 \in 0.5156 \pm 2.179 \times 0.3496 = (-0.2462,1.2774). $$

We therefore do not have sufficient evidence to reject the claim that $\beta_2 = 0$.

If you are interested in finding out how that standard error value is calculated, that question was answered previously in this Cross Validated question.

  • $\begingroup$ Is fEffect supposed to be the categorical variable? $\endgroup$ – sucksatmath Dec 7 '17 at 21:02
  • $\begingroup$ All right, I'm a little confused. Why do you need to measure the difference between two $\beta$ estimates? $\endgroup$ – Gabriel J. Odom Dec 7 '17 at 22:10
  • $\begingroup$ Yes, fEffect is the fixed effect. It is a 0 - 1 indicator. $\endgroup$ – Gabriel J. Odom Dec 7 '17 at 22:11
  • $\begingroup$ I just need to know how to do it for a written test in school. $\endgroup$ – sucksatmath Dec 7 '17 at 22:49
  • $\begingroup$ A confidence interval for the difference of two regression slopes doesn't make any sense. Here's why: the estimate of a regression coefficient has a Student's $t$ distribution (see this). There is not, to my knowledge, a closed form of the difference of two random variables from a Student's $t$ distribution (see this). $\endgroup$ – Gabriel J. Odom Dec 7 '17 at 23:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.