# How do I obtain the slope and intercept for each regression with a 2-level factor?

Suppose I have a data frame that include a factor with two levels. The response is proportional to the predictor, but the slope depends on the factor:

foo <- data.frame(x = rep(0:10, 2),
y = c(5 * 0:10 + rnorm(11),
10 * 0:10 + rnorm(11)),
z = factor(rep(c("Low", "High"), each = 11)))
> foo
x       y    z
1   0   1.504  Low
2   1   5.294  Low
3   2   8.433  Low
4   3  16.006  Low
5   4  21.094  Low
6   5  27.099  Low
7   6  30.864  Low
8   7  34.439  Low
9   8  39.623  Low
10  9  45.097  Low
11 10  50.719  Low
12  0  -0.777 High
13  1   9.821 High
14  2  18.902 High
15  3  29.413 High
16  4  40.563 High
17  5  48.560 High
18  6  58.661 High
19  7  69.551 High
20  8  79.504 High
21  9  90.469 High
22 10 100.259 High


When I fit a linear model, I obtain estimates for an intercept and for the difference with the second intercept. Same for the slopes:

> summary(lm(y ~ x * z, foo))

Call:
lm(formula = y ~ x * z, data = foo)

Residuals:
Min      1Q  Median      3Q     Max
-2.1597 -0.3999  0.0324  0.5420  1.6287

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  -0.8229     0.5101   -1.61    0.124
x            10.0723     0.0862  116.83   <2e-16 ***
zLow          1.4977     0.7213    2.08    0.052 .
x:zLow       -5.1133     0.1219  -41.94   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.904 on 18 degrees of freedom
Multiple R-squared:  0.999, Adjusted R-squared:  0.999
F-statistic: 6.95e+03 on 3 and 18 DF,  p-value: <2e-16


But if I want the slopes for each group of values (grouped on z), I need to compute x + x:zLow and then also need to compute manually the standard error of that estimate.

Is there a way to obtain directly the two different slopes, with the standard error?