I am using coeftest to run z- and t- tests on a few different pieces of data. The output comes in this form:

fit <- lm(dest_flood ~ type_flag, data = runsample) coeftest(fit)

t test of coefficients:

              Estimate Std. Error t value Pr(>|t|)  
(Intercept)     0.0412     0.0162    2.54    0.011 *
type_flagprox   0.0448     0.0184    2.44    0.015 *
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

However, I am used to t- tests and z-tests resulting in data that looks more like this:

    prop.test(x=c(11, 81), n = c(267 , 942), p = NULL, alternative = "two.sided",
              correct = TRUE)
data:  c(11, 81) out of c(267, 942)
X-squared = 5, df = 1, p-value = 0.02
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.0770 -0.0126
sample estimates:
prop 1 prop 2 
0.0412 0.0860 

Where the information you get is that the t-test/z-test basically tell you if differences are significant or not. Do I interpret the first bit of come with the estimated coefficients the same way I would interpret output from a OLS - where a 1 unit increase in type_flagprox is a 0.0448 unit increase in the outcome? If that were output from a binary model, would I interpret it like a logistic regression?


1 Answer 1


This question is about how to interpret the t test as a linear model. I've recreated your data below and will use it in my explanation:


runsample = tribble(~type, ~y, ~n,
        '_flagprox', 1, 11,
        '_flagprox', 0, 267-11,
        'a', 1, 81,
        'a', 0, 942-81) %>% 

The data you've used to fit it consist of two types: $x$ is a binary indicator variable (where $x=1$ when type == _flagprox else 0). $y$ is also a binary variable (i.e. 1 or 0).

As you've mentioned, you can do a test of proportions with this data. When you do this, the estimated difference comes out to be 0.0448

runsample %>% 
  group_by(type) %>% 
  summarise(meany = mean(y)) %>% 
  arrange(meany) %>% 
  pull(meany) %>% 
  diff %>% 
  round(., 4)

[1] 0.0448

The associated p values and confidence intervals are shown in the output of prop.test. Now, let's turn our attention to the linear model. The model you've fit is

$$ y = \hat{\beta}_0 + \hat{\beta}_1 x $$

When $x=0$, then $y_0$ is the mean of the reference group (whatever it is). When $x=1$ then $y_1$ is the mean of the _flagprox group. So the difference $\Delta$ in those is...

$$ \begin{align} \Delta &= y_1 - y_0\\ &= (\hat{\beta}_0 + \hat{\beta}_1) - \hat{\beta}_0\\ &= \hat{\beta}_1 \end{align}$$

So the coefficient of type_flagprox, or the slope, is the estimated difference, and that is exactly what we see in the output

lm(y~type, data=runsample) %>% 

lm(formula = y ~ type, data = runsample)

     Min       1Q   Median       3Q      Max 
-0.08599 -0.08599 -0.08599 -0.04120  0.95880 

            Estimate Std. Error t value Pr(>|t|)  
(Intercept)  0.04120    0.01620   2.543   0.0111 *
typea        0.04479    0.01835   2.440   0.0148 *
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.2647 on 1207 degrees of freedom
Multiple R-squared:  0.00491,   Adjusted R-squared:  0.004085 
F-statistic: 5.955 on 1 and 1207 DF,  p-value: 0.01482

Because the data are binary (and only coded as continuous) the "one unit increase" interpretation is right but for the wrong reasons. Clearly you can't have a two unit increase in type since it is only a variable with 2 categories. A better interpretation for the data you've used is...

$\hat{\beta}_1$ is the estimated difference between the group represented by $x=1$ and the group estimated by $x=0$.

The associated confidence intervals can be obtained by using the confint function, but be aware that they may differ slightly between the confidence intervals shown in prop.test in general due to the use of a z statistic in the latter and t statistic in the former.

  • $\begingroup$ Thanks so much, just to confirm I am understanding this correctly. Let's say the outcome was a continuous variable, then the estimated coefficient (0.04479) is still the difference in the outcome variable for x = 1 compared to the group of x=0, it's just that the outcome group has a larger range (like if it went from 0-100 instead of 0 or 1). Is that correct? $\endgroup$
    – tchoup
    Commented Jun 22, 2022 at 13:19
  • 1
    $\begingroup$ @tchoup Correct. $\endgroup$ Commented Jun 22, 2022 at 14:17

Your Answer

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

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