Distinguish population covariance and correlation parameters from their sample estimators.
Derive the closed-form partial correlation \(\rho_{XY \cdot Z}\) using linear projection residuals.
Diagnose why raw contemporaneous correlation on trending time series is confounded by shared time trends, and contrast this with stationary growth rates.
1. Population vs. Sample Covariance and Correlation
To measure linear co-movement between two random variables \(X\) and \(Y\) with finite variances \(\sigma_X^2 = \operatorname{Var}(X) > 0\) and \(\sigma_Y^2 = \operatorname{Var}(Y) > 0\), we distinguish population parameters from sample estimators computed from \(n\) paired observations \(\{(x_i, y_i)\}_{i=1}^n\).
The population covariance and population Pearson correlation are:
where \(s_X = \sqrt{\frac{1}{n-1}\sum_{i=1}^n (x_i - \bar{x})^2}\) and \(s_Y\) is defined analogously. By the Cauchy-Schwarz inequality, \(|\rho_{XY}| \le 1\) and \(|r_{XY}| \le 1\), with equality if and only if \(Y\) is an exact affine function of \(X\).
Two cautions are essential in time series work:
Linearity only:\(\rho_{XY} = 0\) rules out linear association, not nonlinear dependence (for example, \(Y = X^2\) when \(X \sim \mathcal{N}(0, 1)\) has \(\rho_{XY} = 0\)).
Stationarity requirement: sample correlation treats each pair \((x_t, y_t)\) as sharing a common mean \((\mu_X, \mu_Y)\). When both series drift over time, deviations \((x_t - \bar{x})\) and \((y_t - \bar{y})\) mostly reflect whether \(t\) is early or late in the sample rather than genuine co-movement.
2. Exact Derivation of Partial Correlation
Suppose a third variable \(Z\) influences both \(X\) and \(Y\). The partial correlation\(\rho_{XY \cdot Z}\) measures the linear association between \(X\) and \(Y\) after removing the linear effect of \(Z\) from both variables.
Form the best linear predictors of \(X\) and \(Y\) given \(Z\), and define their projection residuals:
Dividing \(\operatorname{Cov}(e_X, e_Y)\) by \(\sqrt{\operatorname{Var}(e_X)\operatorname{Var}(e_Y)}\) cancels \(\sigma_X \sigma_Y\) and yields the exact partial correlation formula:
Replacing population correlations with sample correlations \(r_{XY}, r_{XZ}, r_{YZ}\) gives the sample partial correlation \(r_{XY \cdot Z}\), which equals the exact sample correlation between the ordinary least squares (OLS) residuals of lm(X ~ Z) and lm(Y ~ Z).
3. Trending Levels vs. Stationary Growth Rates
To see how shared trends distort raw correlation, examine annual Australian macroeconomic series from global_economy (GDP, Imports, and Exports, where trade variables are measured as percentages of GDP). All three series drift upward across 1960 to 2017.
Raw vs. trend-adjusted partial correlations for Australian macro levels (1960–2017).
Pair
Raw r
Partial r (given Year)
GDP vs. Imports
0.786
-0.120
GDP vs. Exports
0.816
0.045
Imports vs. Exports
0.925
0.512
Raw correlations between GDP and trade shares exceed 0.78 purely because all three variables correlate strongly with Year. Removing the shared linear time trend collapses the GDP-trade partial correlations near zero, while Imports and Exports retain a moderate co-movement around open trade cycles.
By contrast, us_change records quarterly percentage changes (already transformed to stationary growth rates) for U.S. macroeconomic aggregates. Here sample correlations reflect genuine quarterly co-movement rather than shared calendar drift.
Figure 1: Confounded linear relationship in trending Australian levels (left) versus genuine short-run co-movement in stationary U.S. quarterly growth rates (middle and right).
Notice how the color gradient by Year in the left panel reveals the confounder directly: observations march monotonically from bottom-left (1960s) to top-right (2010s). In the stationary us_change panels, points scatter cleanly around the regression line without chronological drift.
Practice Exercises
Exercise 1: Partial Correlation in us_change
Compute the raw correlation between quarterly Consumption and Savings in us_change, then compute the partial correlation controlling for Income both via the closed-form formula and by correlating residuals from two lm() regressions. Explain the dramatic change in magnitude.
Solution
Holding Income growth fixed, any additional dollar spent on Consumption reduces Savings directly, so the partial correlation becomes strongly negative (much stronger than the raw correlation, which is diluted by shared positive income shocks).
R_us <-cor(us_change |>as_tibble() |>select(Consumption, Savings, Income))r_raw <- R_us["Consumption", "Savings"]r_formula <-pcor_formula(r_raw, R_us["Consumption", "Income"], R_us["Savings", "Income"])e_cons <-residuals(lm(Consumption ~ Income, data = us_change))e_sav <-residuals(lm(Savings ~ Income, data = us_change))r_resid <-cor(e_cons, e_sav)tibble(Method =c("Raw r(Consumption, Savings)", "Formula r(Cons, Sav | Income)", "Residual lm() verification"),Value =c(r_raw, r_formula, r_resid)) |>fmt_tbl(digits =4, caption ="Raw vs. income-adjusted partial correlation between Consumption and Savings.")
Raw vs. income-adjusted partial correlation between Consumption and Savings.
Method
Value
Raw r(Consumption, Savings)
-0.2566
Formula r(Cons, Sav | Income)
-0.8318
Residual lm() verification
-0.8318
Exercise 2: Partialling Out Time on Trending Levels
For Australia in global_economy, compute the raw correlation between GDP and Population, and verify the partial correlation controlling for Year using both the algebraic formula and lm() residuals. Does linear detrending alone remove all nonlinear trend confounding?
Solution
Even after removing a linear time trend, GDP grows exponentially while Population grows nearly linearly, leaving curvature that keeps the linear partial correlation nonzero. Differencing or log-growth transformations (Module 2) are needed when series follow nonlinear or stochastic trends.
aus_pop <- global_economy |>filter(Country =="Australia") |>as_tibble() |>select(Year, GDP, Population) |>drop_na()R_pop <-cor(aus_pop)r_raw_pop <- R_pop["GDP", "Population"]r_part_pop <-pcor_formula(r_raw_pop, R_pop["GDP", "Year"], R_pop["Population", "Year"])r_lm_pop <-cor(residuals(lm(GDP ~ Year, data = aus_pop)),residuals(lm(Population ~ Year, data = aus_pop)))tibble(Measure =c("Raw r(GDP, Population)", "Partial r (formula | Year)", "Partial r (lm residuals)"),Value =c(r_raw_pop, r_part_pop, r_lm_pop)) |>fmt_tbl(digits =4, caption ="Raw vs. linearly detrended correlation between Australian GDP and Population.")
Raw vs. linearly detrended correlation between Australian GDP and Population.
Measure
Value
Raw r(GDP, Population)
0.905
Partial r (formula | Year)
0.774
Partial r (lm residuals)
0.774
Key Takeaways
Always separate population parameters (\(\operatorname{Cov}, \rho_{XY}\)) from sample estimators (\(s_{XY}, r_{XY}\)).
The exact partial correlation \(\rho_{XY \cdot Z} = (\rho_{XY} - \rho_{XZ}\rho_{YZ})/\sqrt{(1-\rho_{XZ}^2)(1-\rho_{YZ}^2)}\) equals the correlation of linear projection residuals after removing \(Z\).
Raw contemporaneous correlations on trending time series are heavily confounded by shared drift; evaluate relationships on stationary growth rates or after accounting for temporal structure.
Linear partial correlation controlling for calendar time improves over raw correlation, but exponential or stochastic trends require proper transformations and differencing.