Today's lesson

Writing up a regression

Last week you learned to read a regression table. Today you learn to write it up the way a report would — using the same three numbers you already know how to find.

1 Your site

What your portfolio should look like by now

Before any statistics, open your own site and check it. This is the thing most likely to be half-finished.

index.html
Your homepage. Name, who you are, what you care about, and a portfolio section. Lives at your plain Vercel address.
cross-sectional.html
Week 4 piece. What cross-sectional data can and cannot tell you.
regression.html
Week 6 piece. One regression table, your three sentences, and what it means in plain language.
table.png
The screenshot that appears on your regression page.

Check these five things on your own site

  • Your plain Vercel address opens your homepage
  • Your Week 4 piece opens
  • Your regression page opens, and the screenshot actually appears
  • You can get from any page to any other page without typing a URL
  • Nothing still says "Coming soon" for work you have already finished

If a page does not exist yet, that is today's work — build it first, then come back and do the navigation.

Fix the navigation once, properly

Your portfolio is going to keep growing. After today there is a regression write-up, then a t-test page, then chi-square, then your final report. Every page needs to reach every other page, and you should not have to rebuild the whole site each time you add one.

Two ways to do it, your choice: a row of links across the top, or a menu button that opens them — the hamburger. On a phone the menu button is kinder. Pick one, and use the same one on every page.

Prompt · builds your navigation

Paste your whole index.html underneath the prompt — open it in GitHub, click the pencil, select all, copy. The AI cannot check what it cannot see.

If you already have a menu you like, keep it. The prompt is written to leave your work alone and only add what is missing. If you have no menu yet, choose one of the two options inside the prompt and delete the other.

Then paste the block it gives you into every page, right after <body>, and commit each one.

2 Quick recap

Where we got to last week

A regression takes two things measured as numbers — a predictor and an outcome — and draws one straight line through all 168 ZIP codes to show whether the outcome goes up or down as the predictor goes up, and by how much.

You use one when you want to know whether one number predicts another. Ours: do ZIP codes with more short sleep also have more distress?

The row name in the table

Predictor

also called: independent variable

The thing we are using to explain something else.

Listed at the top, next to Dep. Variable

Outcome

also called: dependent variable

Today, still distress_pct. Every time.

The three numbers

All three come from the predictor's row. Never the Intercept row.

rThe correlation. Printed above the table, not inside it. Runs −1 to +1. The sign is direction; distance from zero is strength — 0 to 0.3 weak, 0.3 to 0.7 moderate, 0.7 to 1 strong.
coefThe slope. How far the outcome moves when the predictor goes up by 1. The steepness of the line.
P>|t|The p-value. Below 0.05 is statistically significant. 0.000 in the output means less than .001.

r says which way and how tightly. The coefficient says how far. The p-value says whether to believe there is anything there at all.

3 The new piece

The write-up line

In a report nobody writes three sentences. They write one line, and it carries the same three numbers.

Here is last week's no_insurance_pct result, written the way it would appear in a published paper:

r = .65, b = 0.28, p < .001

r = .65

Your correlation sentence. Positive, and moderate.

b = 0.28

Your slope. In reports the coef number is called b.

p < .001

Your p-value sentence. Significant.

Nothing new has been calculated. The same three numbers, in shorthand.

What b actually says

In a ZIP code, for every 1 percentage point increase in uninsured adults, the distress percentage is a little over a quarter of a percentage point higher.

Concretely: a ZIP code that goes from 10% uninsured to 11% uninsured tends to have a distress percentage about 0.28 points higher.

Still about places

Each ZIP code has one distress percentage. Nobody's personal distress is being measured here, and nobody's sleep or insurance either.

The rules for writing it

  • Lowercase and italic: r, b, p.
  • Always in that order — r, then b, then p — separated by commas.
  • No zero before the decimal for r and p, because neither can ever be bigger than 1. Write .65 and .001.
  • b keeps its zero. Write 0.28, not .28. Only r and p drop it.
  • Round to two decimals. 0.2768 becomes 0.28.
  • If the output says 0.000, write p < .001. Never p = .000 — a p-value is never exactly zero.
  • Three numbers, nothing else. The table has other columns in it. They stay in the table.

One wording point that matters all semester: say percentage point, not percent. Distress is already a percentage, so a change in it is measured in percentage points.

4 Together

poor_health_pct

We do this one together. r = +0.74.

coef — the slopeP>|t| — the p-valuenot today

=============================================================================
Dep. Variable:      distress_pct      No. Observations:   168
Model:              OLS               R-squared:          0.546
-----------------------------------------------------------------------------
                     coef   std err         t     P>|t|     [0.025     0.975]
-----------------------------------------------------------------------------
Intercept         10.8653     0.326    33.358     0.000     10.222     11.508
poor_health_pct    0.2172     0.015    14.119     0.000      0.187      0.248
=============================================================================
The three sentences The correlation is +0.74, which is positive and strong.
For every 1 percentage point increase in poor_health_pct, distress_pct goes up about 0.22 percentage points.
The p-value is less than 0.001, which is less than 0.05, so this relationship is statistically significant.
The same thing, as a write-up line r = .74, b = 0.22, p < .001

5 Your turn

Two tables

For each one: the three sentences, then the write-up line.

Table A · diabetes_pct

r = +0.47
=============================================================================
Dep. Variable:      distress_pct      No. Observations:   168
Model:              OLS               R-squared:          0.217
-----------------------------------------------------------------------------
                     coef   std err         t     P>|t|     [0.025     0.975]
-----------------------------------------------------------------------------
Intercept         12.0700     0.485    24.902     0.000     11.113     13.027
diabetes_pct       0.2678     0.039     6.783     0.000      0.190      0.346
=============================================================================

Table B · depression_pct

r = +0.31
=============================================================================
Dep. Variable:      distress_pct      No. Observations:   168
Model:              OLS               R-squared:          0.095
-----------------------------------------------------------------------------
                     coef   std err         t     P>|t|     [0.025     0.975]
-----------------------------------------------------------------------------
Intercept         10.4498     1.152     9.070     0.000      8.175     12.725
depression_pct     0.2920     0.070     4.179     0.000      0.154      0.430
=============================================================================

Depression and distress are not the same thing. Distress means fourteen or more days of poor mental health in the past thirty days. Depression means a doctor or health professional has at some point told the person they have a depressive disorder. In Table B depression is the predictor, and distress is still the outcome.

Watch what Table B does

Significant does not mean strong. Look at its p-value, then look at its r, and say both out loud.

6 In plain words

The sentence a neighbor would understand

Our file is cross-sectional — one snapshot, measured once. So you can say what goes together. You cannot say what caused what.

A model answer, for no_insurance_pct ZIP codes with more uninsured adults tend to have more mental distress — about a quarter of a point more for each extra point uninsured. That makes insurance worth looking at, though this data cannot prove that covering more people would lower distress.

Notice what that sentence does: it reports the pattern, gives the size in words, says why it matters, and stops short of the claim the data cannot support.

7 Back to your report

What to do with this

  1. Finish regression.html if it is not done

    One table — the one you chose last week. Title, screenshot, your three sentences, and two or three plain-language sentences. Linked from your homepage.

  2. Add the write-up line

    Underneath your three sentences, add the one-line version: r = ___, b = ___, p = ___. That is today's addition, and it is small.

  3. Make the navigation work

    Same menu on every page, so a stranger can move around your site without typing anything.

Optional, if you want the practice: write up any of last week's five tables you did not get to. It is the same three sentences and the same one line, every time.

8 Leaving with this

One line

Three numbers, three sentences, one line. Nothing was added today except the shorthand that every report in your field is written in.