Tech PostsTech Posts
기초와 계량경제학Basics & Econometrics · 07 / 24
07 기초와 계량경제학Basics & Econometrics

자신 있게, 정확하게 틀린 회귀A Regression That Is Confidently, Precisely Wrong

R²는 0.76, t값은 11을 넘고, 잔차 진단도 깨끗합니다. 추정치는 참값에서 27% 벗어나 있습니다.R-squared of 0.76, t-statistics above 11, clean residual diagnostics. The estimate is 27% away from the truth.

완전히 평범해 보이는데 완전히 틀린 회귀가 있습니다.

Here is a regression that looks completely ordinary and is completely wrong.

시계열이 있습니다. 오늘 값이 어제 값에 의존한다고 봅니다. Y를 자기 시차에 회귀해서 t값 11짜리 계수와 좁은 신뢰구간을 얻고 보고합니다. 출력의 모든 진단이 건강해 보입니다.

You have a time series. You believe today value depends on yesterday. You regress Y on its own lag, get a coefficient with a t-statistic of 11 and a tight confidence interval, and report it. Every diagnostic in the output looks healthy.

추정치는 27% 벗어나 있고 그 회귀표의 무엇도 그것을 알려 주지 않습니다.

The estimate is off by 27%, and nothing in that regression table tells you so.

설정The setup

참 과정에 두 부분이 있다고 합시다. 계열 자체가 자기회귀이고,

Suppose the true process has two parts. The series itself is autoregressive,

y_t = β y_(t−1) + u_t

오차도 자기회귀입니다.

and the error is autoregressive too.

u_t = ρ u_(t−1) + v_t
v는 백색잡음입니다. 아래에서는 β = 0.7, ρ = 0.5를 씁니다.v is white noise. We use β = 0.7 and ρ = 0.5 below.

이제 y_t를 y_(t−1)에 OLS로 회귀하면 무엇이 나오는지 묻습니다.

Now regress y_t on y_(t−1) by OLS and ask what you get.

왜 깨지는가Why it breaks

OLS는 회귀변수가 오차와 무관할 때 일치추정량입니다. 여기서 확인해 봅시다.

OLS is consistent when the regressor is uncorrelated with the error. Check that here.

회귀변수는 y_(t−1)입니다. 첫 식에 따라 y_(t−1)은 u_(t−1)을 담고 있습니다. 오차는 u_t이고 둘째 식에 따라 u_t는 ρ u_(t−1)을 담고 있습니다. 그러니 회귀변수와 오차가 같은 항을 공유합니다. 구성상 상관되어 있고 ρ가 양수면 상관도 양수입니다.

The regressor is y_(t−1). By the first equation, y_(t−1) contains u_(t−1). The error is u_t, and by the second equation u_t contains ρ u_(t−1). So the regressor and the error share a term. They are correlated by construction, and the correlation is positive whenever ρ is.

이 설계의 확률극한은 표준 결과로 이렇게 나옵니다.

The standard result for this design gives the probability limit as

plim β̂ = β + ρ(1 − β²) / (1 + βρ)

β = 0.7, ρ = 0.5면 0.889가 됩니다. 200만 관측치로 시뮬레이션하면 확인됩니다. 추정치가 0.8890에 자리 잡고 거기 머뭅니다. 0.7을 잡음과 함께 추정하고 있는 게 아니라 0.889를 추정하고 있는 것입니다.

For β = 0.7 and ρ = 0.5 that works out to 0.889. Simulating two million observations confirms it: the estimate settles at 0.8890 and stays there. You are not estimating 0.7 with noise around it. You are estimating 0.889.

python
import numpy as np
import statsmodels.api as sm

rng = np.random.default_rng(7)
beta, rho = 0.7, 0.5

def simulate(T):
    u = np.zeros(T); y = np.zeros(T)
    u[0] = rng.normal(); y[0] = u[0]
    for t in range(1, T):
        u[t] = rho * u[t-1] + rng.normal()
        y[t] = beta * y[t-1] + u[t]
    return y

y = simulate(2_000_000)

naive = sm.OLS(y[1:], y[:-1]).fit()
print(f"naive AR(1) beta_hat = {naive.params[0]:.4f}   (true beta = {beta})")
print(f"plim formula         = {beta + rho*(1-beta**2)/(1+beta*rho):.4f}")
naive AR(1) beta_hat = 0.8890   (true beta = 0.7)
plim formula         = 0.8889

일반화해서 말할 값어치가 있습니다. 시차 종속변수와 계열상관 오차는 OLS 회귀에서 공존할 수 없습니다. 각각 혼자는 괜찮습니다. 함께면 치명적입니다. 같은 문제가 패널 데이터에서는 Nickell 편의로 다시 나타나고 Arellano–Bond 같은 동적 패널 추정량이 존재하는 이유입니다.

The general lesson is worth stating separately: a lagged dependent variable and serially correlated errors cannot coexist in an OLS regression. Either is fine alone. Together they are fatal. The same problem reappears in panel data as Nickell bias, and it is why dynamic panel estimators such as Arellano-Bond exist.

평소 쓰던 진단이 놓치는 이유Why the usual diagnostic misses it

해법: 재모수화The fix: reparameterise

편향된 추정치를 보정하려 애쓰는 대신, 둘째 식을 첫째 식에 대입해 계열상관 오차를 아예 없앱니다. 정리하면 이렇게 됩니다.

Rather than trying to correct the biased estimate, substitute the second equation into the first and eliminate the serially correlated error entirely.

y_t = (β + ρ) y_(t−1) − ρβ y_(t−2) + v_t

이제 오차는 v_t이고 백색잡음이며 두 회귀변수 모두와 무관합니다. 식에 대한 OLS는 일치추정량입니다.

The error is now v_t, which is white noise and uncorrelated with both regressors. OLS on this equation is consistent.

거래를 짚어 두십시오. 더 이상 β를 직접 추정하지 않습니다. 합성 계수 두 개를 추정하고 구조 모수를 나중에 복원합니다.

Note the trade: you are no longer estimating β directly. You estimate two composite coefficients and recover the structural parameters afterwards.

python
X = np.column_stack([y[1:-1], y[:-2]])        # y_{t-1}, y_{t-2}
ar2 = sm.OLS(y[2:], X).fit()
a, b = ar2.params

print(f"y_(t-1) coef = {a:.4f}   (theory beta+rho  = {beta+rho:.2f})")
print(f"y_(t-2) coef = {b:.4f}   (theory -rho*beta = {-rho*beta:.2f})")

# beta and rho are the two roots of z^2 - a z + (-b) = 0
roots = np.roots([1, -a, -b])
print(f"recovered    : {roots[0]:.4f}, {roots[1]:.4f}   (true 0.7 / 0.5)")
합에 해당하는 계수와 곱에 해당하는 계수를 알면 β와 ρ는 이차방정식의 두 근입니다.Knowing the sum and the product, β and ρ are the two roots of a quadratic.
y_(t-1) coef = 1.2000   (theory beta+rho  = 1.20)
y_(t-2) coef = -0.3498   (theory -rho*beta = -0.35)
recovered    : 0.7007, 0.4993   (true 0.7 / 0.5)

두 방법을 β에 대해 비교하면 이렇습니다. 순진한 AR(1) 회귀는 0.889로 가고 데이터를 아무리 더해도 0.889입니다. AR(2) 재모수화는 0.700으로 갑니다.

Compare the two on β: the naive AR(1) regression converges to 0.889 and stays there no matter how much data you add. The AR(2) reparameterisation converges to 0.700.

한 가지 모호함이 남습니다. 대수적으로 β와 ρ가 대칭이라 어느 근이 어느 것인지는 알려 주지 않습니다. 이걸 풀려면 지속성에 대한 경제학적 판단이나 추가 제약이 필요합니다. 식별은 데이터가 건네주는 것이 아니라 당신이 공급하는 가정이라는 작은 상기입니다.

One ambiguity remains: the algebra is symmetric in β and ρ, so it gives you the pair but not which root is which. Resolving it needs either economic reasoning about plausible persistence or an additional restriction — a small reminder that identification is an assumption you supply, not something the data hands you.

실무에서In practice

  • 잔차를 자기 시차에 대해 산점도로 그리십시오. 어떤 시계열 회귀든 믿기 전에 이 그림 하나가 계열상관 대부분을 잡습니다. 우상향 기울기가 보이면 ρ가 0이 아니고 시차 종속변수가 있는 OLS는 비일치입니다.
  • 자기상관이 일으키는 두 문제를 구분하십시오. 시차 종속변수가 없으면 계열상관 오차는 계수를 불편으로 두고 표준오차만 틀리게 만듭니다. Newey–West나 HAC 표준오차로 고쳐집니다. 시차 종속변수가 있으면 계수 자체가 비일치이고 로버스트 표준오차는 전혀 도움이 안 됩니다. 틀린 숫자 주위의 불확실성을 정확하게 재 줄 뿐입니다. 여기서 HAC로 손이 가는 것은 아주 흔하고 완전히 무의미한 대응입니다.
  • 잔차가 백색이 될 때까지 시차를 더하십시오. AR(2) 해법은 일반화됩니다. 잔차에 여전히 자기상관이 남으면 시차를 하나 더 넣습니다. 위의 이유로 Durbin–Watson 대신 잔차에 Ljung–Box 검정을 쓰고 시차 길이는 AIC나 BIC로 고르면 됩니다.
  • 패널 데이터에서는 Nickell 편의를 예상하십시오. 고정효과와 함께 시차 종속변수를 쓰면 1/T 차수의 편의가 생기고 응용 작업에서 흔한 5~10년짜리 짧은 패널에서는 그 크기가 상당합니다.
  • Plot the residuals against their own lag. Before trusting any time series regression, this one scatter plot catches most serial correlation. A visible upward slope means ρ is not zero and OLS on a lagged dependent variable is inconsistent.
  • Distinguish the two problems autocorrelation causes. Without a lagged dependent variable, serially correlated errors leave coefficients unbiased and only make standard errors wrong — Newey-West or HAC fixes it. With a lagged dependent variable, the coefficients themselves are inconsistent and robust standard errors do not help at all; they give an accurate measure of uncertainty around the wrong number. Reaching for HAC here is very common and entirely ineffective.
  • Add lags until the residuals are white. The AR(2) fix generalises: if residuals remain autocorrelated, add another lag. Use the Ljung-Box test on residuals rather than Durbin-Watson, for the reason above, and select lag length by AIC or BIC.
  • In panel data, expect Nickell bias. A lagged dependent variable with fixed effects is biased of order 1/T, which for the short panels common in applied work — five or ten years — is substantial.