01 / 22

Trend Lines &
Regression

Learn to add trend lines in Tableau, interpret regression outputs, and use \( R^2 \) to evaluate model fit.

Tableau

What Is a Trend Line?

A trend line is a straight or curved line fitted through a scatter plot that summarizes the overall direction and strength of the relationship between two continuous variables.

Why Trend Lines Matter

★ Reveal Patterns
Spot upward, downward, or flat trends that raw dots alone cannot clearly communicate.
★ Predict Values
Use the fitted equation to estimate \( y \) for a given \( x \), enabling data-driven forecasting.
★ Quantify Fit
Metrics like \( R^2 \) and \( p \)-value tell you how reliable the relationship really is.

Key Vocabulary

1
Regression Equation: The formula of the line: \( y = mx + b \), where \( m \) is the slope and \( b \) is the y-intercept.
2
\( R^2 \) (Coefficient of Determination): The proportion of variance in \( y \) explained by \( x \). Ranges from 0 to 1.
3
\( p \)-value: Tests whether the relationship is statistically significant. A \( p \)-value \( < 0.05 \) suggests strong evidence.
4
Residual: The difference between an observed value and the predicted value: \( e_i = y_i - \hat{y}_i \).

The Linear Regression Model

Tableau fits a line that minimizes the sum of squared residuals:

x y residual trend line

Understanding \( R^2 \)

\( R^2 \) tells you what fraction of the variation in your dependent variable is captured by the model. The formula is:

\( R^2 \approx 0.0 \)
The model explains almost none of the variance. The trend line is essentially flat or random.
\( R^2 \approx 0.5 \)
The model explains about half the variance. There is a moderate relationship.
\( R^2 \approx 1.0 \)
Nearly perfect fit. Almost all variation is explained by the model.

Linear vs. Polynomial vs. Exponential

Tableau offers multiple trend line models. Choosing the right one depends on the shape of your scatter plot.

Linear Polynomial Exponential
Equation \( y = mx + b \) \( y = a_n x^n + \ldots + a_0 \) \( y = ae^{bx} \)
Best For Constant rate of change Curves, peaks, or valleys Growth or decay patterns
Risk Misses curvature Overfitting with high degree Sensitive to outliers

Correlation vs. Causation

A trend line shows that two variables move together: it does not prove one causes the other. Always consider lurking variables and confounders.

Correlation
Ice cream sales and drownings both increase in summer. They are correlated, but ice cream does not cause drowning.
Causation
A randomized controlled trial shows that a drug reduces symptoms. There is evidence of a causal mechanism.

How to Add a Trend Line in Tableau

1
Build a scatter plot: Drag a continuous measure to Columns and another to Rows.
2
Add the trend line: Go to the Analytics pane and drag Trend Line onto the view.
3
Choose the model: Right-click the trend line and select Edit Trend Lines. Pick Linear, Polynomial, Exponential, or Logarithmic.
4
Inspect the output: Hover over the trend line to see the equation, \( R^2 \), and \( p \)-value.
5
Show confidence bands: Check "Show Confidence Bands" to visualize uncertainty around the line.

Reading the Tooltip

When you hover over a Tableau trend line, a tooltip displays the full regression model. Here is how to interpret each part:

Equation
e.g. \( y = 1.24x + 15.6 \): For every 1-unit increase in \( x \), \( y \) increases by 1.24.
\( R^2 \)
e.g. \( R^2 = 0.87 \): The model explains 87% of the variation in \( y \).
\( p \)-value
e.g. \( p \lt 0.0001 \): The relationship is statistically significant, unlikely due to chance.

Example 1: Sales vs. Ad Spend

Ad Spend ($K) Sales ($K) 10 20 30 40 50 50 100 150 200 R² = 0.96

Example 2: Temperature vs. Defects

Temperature (°F) Defect Rate (%)
\( \text{Linear: } R^2=0.02 \)
\( \text{Poly(2): } R^2=0.97 \)

Example 3: Interpreting Output

A Tableau tooltip for a sales-vs-discount scatter shows:

1
Slope \( = -4.2 \): For each additional percentage point of discount, profit drops by $4.20.
2
\( R^2 = 0.61 \): Discount explains 61% of the profit variation: moderate-to-strong.
3
\( p = 0.0003 \): This is well below 0.05, so the negative relationship is statistically significant.

Trend Lines by Category

When you add a dimension to Color, Tableau automatically fits separate trend lines for each category. This lets you compare slopes and strengths across groups.

x y Group A Group B

Confidence Bands

Confidence bands display the range of uncertainty around the trend line. A 95% band means: if we repeated the study many times, 95% of the true regression lines would fall within the shaded region.

95% Confidence Band

Common Mistakes

✕ Forcing a Linear Fit
Applying a linear trend to clearly curved data. Always check the scatter plot shape first.
✕ Ignoring the \( p \)-value
A high \( R^2 \) means nothing if \( p > 0.05 \). Both metrics must be checked together.
✕ Extrapolating Too Far
Predicting values far beyond your data range. The relationship may not hold outside observed bounds.
✕ Claiming Causation
Saying "X causes Y" from a trend line alone. Correlation is not causation without controlled experiments.

Summary Table

Metric What It Tells You Good Value
Slope (\(m\)) Rate of change per unit of \( x \) Direction and steepness of trend Context-dependent
Intercept (\(b\)) Predicted \( y \) when \( x = 0 \) Starting point of the model Context-dependent
\( R^2 \) Proportion of variance explained Strength of model fit Closer to 1.0
\( p \)-value Statistical significance Whether the relationship is real \( < 0.05 \)

Question 1 of 5

A Tableau trend line shows \( R^2 = 0.92 \). What does this mean?

Question 2 of 5

You see a U-shaped scatter plot in Tableau. Which trend line model is most appropriate?

Question 3 of 5

A trend line has \( R^2 = 0.85 \) but \( p = 0.12 \). How should you interpret this?

Question 4 of 5

In the equation \( \hat{y} = -2.5x + 100 \), what does the slope of \( -2.5 \) mean?

Question 5 of 5

In Tableau, how do you add a trend line to a scatter plot?