DBA · DATA ANALYSIS · 01
0%
DATA ANALYSIS FOR THE DBA · PART 1 OF 6

Explain or Predict?

Before any method, one fork decides everything — and underneath both lies a single idea: a line that makes its mistakes as small as possible.

1 · THE FORK THAT FRAMES EVERYTHING
THE PROBLEM

"I'll collect the data, then figure out the analysis"

This is the single most common methodological error in a DBA. Deciding how you will analyse data is not a technical afterthought — it is a methodological choice that must be justified before you collect a single response, exactly like your epistemological stance or your sampling strategy.

And almost every quantitative analysis you will ever run answers one of two fundamentally different questions. Confusing them is what makes a viva go badly.

THE TWO QUESTIONS

Explaining is not the same as predicting

Switch between the two goals below. Notice that the question, the output you report, the success metric, and even the methods all change. They are different intellectual projects.

Interactive 1 of 3 — pick a goal; the whole panel rewrites.

A DBA almost always explains. You want to understand and influence a business reality — not just forecast it.

2 · WHAT "FITTING A LINE" ACTUALLY MEANS
THE IDEA

A model is a guess that we tune to fit reality

Suppose you have data on marketing spend (x) and sales (y) for 8 months. Plot them and the dots roughly trend upward. A linear model proposes the simplest possible story:

ŷ = b₀ + b₁·x
ŷ("y-hat") the sales our line predicts for a given spend x.
b₀the intercept — predicted sales when spend = 0 (where the line crosses the vertical axis).
b₁the slope — how much sales rise for each extra unit of spend. This is the number a manager cares about.

The whole game is choosing b₀ and b₁ so the line sits as close as possible to the real dots. Try it: drag the two sliders and hunt for the best line by eye.

Interactive 2 of 3 — tune the line. The grey sticks are the errors (residuals): the gap between each real dot and your line.
Sum of sq. errors
R² (fit quality)
vs best possible
THE MATHS — WHY WE SQUARE THE ERRORS

"Least squares": the line that minimises squared mistakes

For each month, the residual is what the line got wrong:

eᵢ = yᵢ − ŷᵢ  =  (actual) − (predicted)

We can't just add the residuals up — positive and negative errors would cancel, and a terrible line could score zero. Two fixes exist: take absolute values, or square them. We square. Squaring does two things: it makes every error positive, and it punishes big misses far more than small ones (an error of 4 counts as 16). The line that makes this total as small as possible is the Ordinary Least Squares (OLS) line:

minimise   SSE = Σ (yᵢ − ŷᵢ)²
Σ"sum over all data points." SSE = Sum of Squared Errors. There is exactly one line that minimises it, and calculus gives it to us directly — no guessing needed.

The interactive below makes the squaring literal: each residual becomes an actual square. Watch the total grey area — that area is the SSE. The best line is the one with the least total area. That is not a metaphor; it is the definition.

Interactive 3 of 3 — tilt the line and watch the squares grow and shrink. Minimise the total shaded area.
Total square area = SSE
Status
R² in one line. Once you have the best line, R² = 1 − SSE / TSS, where TSS is the squared error of the dumbest possible model: always guessing the mean of y. So R² answers: "how much better is my line than just guessing the average?" R² = 0.62 means the line removes 62% of that baseline error.
FIRST STEPS — HOW YOU'D ACTUALLY DO THIS

From idea to a real regression

  1. Put your data in two columns: the outcome y (what you explain) and the predictor x.
  2. In your tool of choice, the command is almost a sentence. In R: lm(sales ~ spend, data=df). In Python (statsmodels): smf.ols("sales ~ spend", df).fit(). In Excel: Data → Data Analysis → Regression.
  3. The tool returns b₀, b₁, their p-values, and R² — exactly the numbers you tuned by hand above. Part 4 teaches you to read that table.

You now know the engine under the hood: a model is a line, and "fitting" means choosing the line whose squared mistakes are smallest.

Scroll progress saves on this device. Part of the DBA Data-Analysis series by Jan Erik Meidell.
JMJan Erik Meidell