1

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

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

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
sucksatmath
  • 253
  • 1
  • 9

1 Answers1

1

Let's take a toy example in R:

set.seed(135)
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:

Call:
lm(formula = y ~ fEffect + rEffect)

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

Coefficients:
            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.

Gabriel J. Odom
  • 300
  • 1
  • 7
  • Is fEffect supposed to be the categorical variable? – sucksatmath Dec 07 '17 at 21:02
  • All right, I'm a little confused. Why do you need to measure the difference between two $\beta$ estimates? – Gabriel J. Odom Dec 07 '17 at 22:10
  • Yes, fEffect is the fixed effect. It is a 0 - 1 indicator. – Gabriel J. Odom Dec 07 '17 at 22:11
  • I just need to know how to do it for a written test in school. – sucksatmath Dec 07 '17 at 22:49
  • 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](https://stats.stackexchange.com/questions/117406/proof-that-the-coefficients-in-an-ols-model-follow-a-t-distribution-with-n-k-d)). There is not, to my knowledge, a closed form of the difference of two random variables from a Student's $t$ distribution ([see this](https://stats.stackexchange.com/questions/10856/what-is-the-distribution-of-the-difference-of-two-t-distributions)). – Gabriel J. Odom Dec 07 '17 at 23:24
  • I'll rephrase my question with an example. Let's say I have a categorical independent variable called Drugs and there are only two types of drugs (Drug1 and Drug2). I want to find the confidence interval for the difference in the effect Drug1 and Drug2 has on a person (the response dependent variable). So that means the difference between the coefficients (estimates) of Drug1 and Drug2 is part of the formula for the confidence interval. – sucksatmath Dec 07 '17 at 23:37
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/69935/discussion-between-gabriel-j-odom-and-sucksatmath). – Gabriel J. Odom Dec 08 '17 at 19:00