Econometrics · Week 10
Modelling dynamics動態建模
Week 9 treated the time-series nature of data as a nuisance in the errors. This week puts it to work. Because observations come in order, a regression can include a trend, seasons, a break at a known date, and, most importantly, past values of the variables themselves. Such dynamic models say not only how much y moves when x changes, but when.
第 9 週把時間序列的特性視為誤差中的麻煩。本週則加以利用。由於觀測值有先後次序,回歸可以加入趨勢、季節、在已知日期出現的轉變,以及最重要的:變數本身的過去數值。這樣的動態模型不但說明 x 改變時 y 會變動多少,還說明甚麼時候變動。
- Reading time 閱讀時間
- About 55 minutes
- Data 數據
traffic2,inven- Code 程式碼
- R, Python
Static and dynamic models靜態模型與動態模型
Cross-sectional observations have no natural order and are usually treated as independent. Time-series observations are ordered, and what happens in one period is linked to what happened before. Every tool so far, from dummies and logs to t and F tests, works with time series too. What is new is that the order itself can be modelled.
橫截面觀測值沒有自然次序,通常被視為互相獨立。時間序列觀測值則有先後次序,一個時期發生的事與之前發生的事互相關連。到目前為止的所有工具,由虛擬變數、對數到 t 和 F 檢定,都適用於時間序列。新的地方在於次序本身也可以建模。
A static model relates and in the same period only:
靜態模型只把同一時期的 和 聯繫起來:
A change in in period affects in period and never afterwards. A dynamic model lets effects spread over time, for instance through a lag of :
在第 期的改變只影響第 期的 ,之後便不再有影響。動態模型容許效應在時間上擴散,例如加入 的滯後項:
Now a change in moves by and by . In a model of a city’s murder rate, for example, a rise in the conviction rate might deter crime partly at once and partly the next year, as word spreads. Effects spread out for many reasons: habits change slowly, contracts and institutions fix prices or wages for a time, administrative processes take time, and people who are optimising adjust gradually when adjusting is costly.
現在 的改變令 變動 ,並令 變動 。例如在城市謀殺率的模型中,定罪率上升可能部分即時阻嚇罪案,部分則在消息傳開後的下一年才發揮作用。效應會分散到多個時期的原因有很多:習慣改變得慢;合約和制度在一段時間內固定價格或工資;行政程序需要時間;當調整有成本時,追求最優的人會逐步調整。
Trends趨勢
Many economic series grow over time. A linear trend adds the same amount each period; an exponential trend adds the same percentage:
很多經濟序列隨時間增長。線性趨勢每期增加相同的數量;指數趨勢每期增加相同的百分比:
In the linear trend is the change in from one period to the next. In the exponential trend it is the change in , which from Week 6 is approximately the proportional growth rate, so is roughly the percentage growth per period. Series that grow at a fairly steady rate, such as GDP, prices or visitor numbers, usually follow an exponential trend: their absolute increases get larger as they grow.
在線性趨勢中, 是 由一期到下一期的變化。在指數趨勢中,它是 的變化;由第 6 週可知,這大約就是按比例的增長率,所以 大約是每期的百分比增長。以大致穩定的速度增長的序列,例如國內生產總值、物價或旅客人數,通常服從指數趨勢:它們越大,絕對增幅也越大。
Example. The traffic2 data from Week 9 count traffic accidents in California each month from 1981 to 1989. With 108 months,
例子。第 9 週的 traffic2 數據記錄了 1981 至 1989 年加州每月的交通意外數目。以 108 個月計算,
The linear trend adds about 121 accidents a month, every month. The exponential trend adds 0.285% a month, or a year. Over nine years the two fit about equally well ( for both); they would part company over a longer period.
線性趨勢表示每個月都多約 121 宗意外。指數趨勢表示每月增加 0.285%,即每年增加 。在九年之內,兩者的擬合程度差不多(兩者的 都是 0.676);時間更長的話,兩者便會分道揚鑣。
Seasonality季節性
Monthly and quarterly series often have a seasonal pattern: more tourists in summer, more retail sales in December. Official statistics are often published seasonally adjusted, but the pattern itself matters for forecasting. Week 5’s dummy variables capture it. With monthly data and January as the base month,
月度和季度序列往往有季節性規律:夏季旅客較多,十二月零售額較高。官方統計數字通常經季節調整後才公布,但季節規律本身對預測很重要。第 5 週的虛擬變數可以捕捉它。以月度數據、一月為基準月:
Each is the difference between that month and January, holding the trend fixed. To test whether there is any seasonality at all, use an F test of .
每個 是在趨勢不變時,該月與一月之間的差異。要檢定是否存在任何季節性,可對 做 F 檢定。
Example. Adding eleven month dummies to the exponential trend for accidents lowers the SSR from 0.408 to 0.256:
例子。在交通意外的指數趨勢模型中加入十一個月份虛擬變數,SSR 由 0.408 降至 0.256:
against an 5% critical value of 1.89 (p = 0.000003). Accidents are clearly seasonal: with January as the base, December is 0.096 log points (about 10%) higher and February 0.043 lower.
的 5% 臨界值是 1.89(p = 0.000003)。交通意外明顯有季節性:以一月為基準,十二月高 0.096 個對數點(約 10%),二月則低 0.043。
Changing the base month changes what each dummy compares with, not the model. With December as the base instead, the fitted values, residuals, and the F test for seasonality are identical, and every coefficient is the old one minus the old December coefficient. The individual t tests do change, because they test different contrasts: October is 8.2% above January () but only 1.4% below December ().
改變基準月只會改變每個虛擬變數所比較的對象,不會改變模型。改以十二月為基準,擬合值、殘差、 以及季節性的 F 檢定都完全相同,每個係數就是舊係數減去舊的十二月係數。但個別的 t 檢定會改變,因為它們檢定的是不同的比較:十月比一月高 8.2%(),但只比十二月低 1.4%()。
Structural breaks結構性轉變
Did a known event change the series? Did the global financial crisis slow economic growth? Did a new law change the trend in road accidents? A dummy that is 0 before the event and 1 after it shifts the level of the regression from that date on. Interacting it with the trend lets the slope change too:
已知的事件有沒有改變序列?環球金融危機有沒有拖慢經濟增長?新法例有沒有改變交通意外的趨勢?在事件之前為 0、之後為 1 的虛擬變數,會令回歸由該日期起平移。把它與趨勢相乘,斜率也可以改變:
Before the event the trend is ; after it, . The joint F test of asks whether anything changed at all.
事件之前的趨勢是 ;之後是 。對 的聯合 F 檢定,就是問是否有任何改變。
Example. California’s seat belt law took effect in January 1986. Add beltlaw and its interaction with the trend to the accident model with month dummies:
例子。加州的安全帶法例在 1986 年 1 月生效。在包含月份虛擬變數的交通意外模型中,加入 beltlaw 及其與趨勢的交互項:
Both terms are highly significant ( and ). Before 1986 accidents grew by about 0.2% a month; afterwards the trend is , essentially flat. Because the interaction uses itself, is not the jump at the break date. In January 1986, , the predicted level jumps by , about 13%, and then stops rising.
兩項都非常顯著( 和 )。1986 年之前,交通意外每月增長約 0.2%;之後的趨勢是 ,基本持平。由於交互項使用 本身, 並不是轉變日期的跳躍幅度。在 1986 年 1 月,即 ,預測水平躍升 ,約 13%,之後便不再上升。
Autoregressive models自回歸模型
The simplest dynamic model explains a series by its own past. An autoregressive model of order p, AR(p), is
最簡單的動態模型用序列自身的過去來解釋它。p 階自回歸模型 AR(p) 為
where is white noise, written : mean zero, constant variance and no correlation across periods,
其中 是白噪音,記作 :均值為零、方差不變,而且不同時期之間沒有相關:
Week 9 used the AR(1) model for errors. Now it describes itself: . Depending on , very different series come out:
第 9 週用 AR(1) 模型描述誤差。現在它描述 本身:。視乎 的值,會得出截然不同的序列:
: an uncorrelated sequence, plus white noise.
:不相關的序列,即 加上白噪音。
: a stationary process that keeps returning to its mean.
:平穩過程,不斷回到其均值。
: a random walk, . Shocks never fade.
:隨機漫步,。衝擊永不消退。
: a random walk with drift, which wanders around a linear trend.
:帶漂移的隨機漫步,圍繞一條線性趨勢游走。
: an explosive process. Shocks grow without limit.
:爆炸性過程。衝擊無限放大。
All four panels use the same 120 simulated standard normal shocks; only φ₀ and φ₁ differ. Note the different vertical scales.
四幅圖使用同一組 120 個模擬標準正態衝擊,只有 φ₀ 和 φ₁ 不同。留意縱軸刻度各不相同。
Show every step: why a random walk never settles 顯示完整推導:為甚麼隨機漫步永不穩定
Substitute the random walk into itself back to a starting value :
把隨機漫步代入自身,直至起始值 :
Every past shock enters with weight 1, so none fades, and grows without bound. With there is also the deterministic trend . For , by contrast, the same substitution gives weights that shrink to zero, so old shocks are forgotten.
每個過去的衝擊都以權重 1 進入,所以沒有一個會消退,而 會無限增大。當 時,還有確定性趨勢 。相反,當 時,同樣的代入給出的權重 會縮小至零,所以舊的衝擊會被遺忘。
Stationarity平穩性
A series is (covariance) stationary if its first two moments do not depend on time:
如果序列 的頭兩階矩不隨時間改變,它便是(協方差)平穩的:
, finite and the same for every ;
,有限且對每個 都相同;
, finite and the same for every ;
,有限且對每個 都相同;
, finite and depending only on the gap , not on .
,有限,並只取決於間隔 ,而不取決於 。
Stationarity is what makes the past informative about the future: the relationships seen in the sample hold throughout. A random walk is not stationary, because its variance grows with ; a trending series is not, because its mean does. The AR(1) model with and white-noise is stationary, with
平穩性令過去能夠提供關於將來的資訊:樣本中觀察到的關係在整段時間都成立。隨機漫步並不平穩,因為它的方差隨 增大;有趨勢的序列也不平穩,因為它的均值隨時間改變。當 而且 是白噪音時,AR(1) 模型是平穩的,並且
Show every step 顯示完整推導
Mean. Take expectations of . Stationarity gives , and :
均值。對 取期望。平穩性給出 ,而 :
Variance and correlations. Subtract the mean: . This is exactly Week 9’s AR(1) error model with , so the derivation there gives , and . None depends on , and all are finite when .
方差與相關。減去均值:。這正是第 9 週以 表示的 AR(1) 誤差模型,所以那裏的推導給出 、 和 。全部都不取決於 ,而且在 時都是有限的。
The stationary panel above has and , so it fluctuates around .
上面的平穩序列 、,所以圍繞 波動。
The ARDL model and long-run effectsARDL 模型與長期效應
The autoregressive distributed lag model, ARDL(, ), combines both kinds of dynamics: lags of and lags of ,
自回歸分佈滯後模型 ARDL(, ) 結合了兩種動態: 的 個滯後項和 的 個滯後項:
Choose and with the frequency of the data in mind, with information criteria (Week 6), and so that the residuals show no serial correlation. OLS estimates and the usual t and F tests are then reliable in large samples, provided and are stationary and the errors are white noise.
選擇 和 時,要考慮數據的頻率、資訊準則(第 6 週),並確保殘差沒有序列相關。只要 和 是平穩的而誤差是白噪音,OLS 估計值以及一般的 t 和 F 檢定在大樣本中便是可靠的。
How the effect unfolds. In an ARDL(1,1), raise by one unit in period and keep it there. Then rises by at once: the impact effect. In period , enters again through , and the higher feeds through . And so on, until settles at a new level. The total change is the long-run effect:
效應怎樣展開。在 ARDL(1,1) 中,於第 期把 提高一個單位並維持。 即時上升 :這是即時效應。在第 期, 透過 再次進入,而較高的 透過 傳遞下去。如此類推,直至 穩定在新的水平。總變化就是長期效應:
In words: the sum of the coefficients on and its lags, divided by one minus the sum of the coefficients on the lags of . It exists only if the lags of are stable, which requires .
換句話說: 及其滯後項的係數之和,除以一減去 滯後項的係數之和。只有在 的滯後項穩定時它才存在,這要求 。
Show every step: the long-run effect 顯示完整推導:長期效應
The long-run equilibrium. In the long run, with held at and the errors at their mean of zero, settles at a constant . Every lag then takes the same value, so the ARDL(, ) becomes
長期均衡。在長期,當 維持在 、誤差取其均值零時, 穩定在常數 。此時每個滯後項都取相同的數值,所以 ARDL(, ) 變成
The coefficient on is the long-run effect.
的係數就是長期效應。
Period by period, ARDL(1,1). Let rise by 1 from period on, and track the change in , for periods later:
逐期計算 ARDL(1,1)。設 由第 期起上升 1,記 期後 的變化為 :
If , the sequence converges to the value that satisfies , which is .
如果 ,序列會收斂到滿足 的值 ,即 。
x rises by 1 and stays x 上升 1 並維持x rises by 1 for one period x 只上升一期Long-run effect 長期效應
- Impact 即時效應
- –
- After one period 一期後
- –
- φ₁ + φ₂
- –
- Long run 長期
- –
The model is . The first two presets are the estimated ARDL(2,0) equation of Section 8, for a one-point rise in inflation and in growth. Try pushing up towards 1 and watch the long-run effect grow and take longer to arrive.
模型為 。首兩個預設值是第 8 節估計的 ARDL(2,0) 方程,分別對應通脹和增長上升一個百分點。試把 推近 1,觀察長期效應怎樣變大,並需要更長時間才達到。
Example: an interest-rate reaction function例子:利率反應函數
How does a central bank move interest rates in response to inflation and growth? The lecture asks this of the Reserve Bank of Australia. With public data we can ask it of the United States: the inven data give the annual 3-month Treasury bill rate (i3), CPI inflation (inf) and real GDP growth (), all in percent, for 1959 to 1995.
中央銀行怎樣因應通脹和經濟增長調整利率?課堂以澳洲儲備銀行為例。利用公開數據,我們可以對美國提出同樣的問題:inven 數據提供 1959 至 1995 年的年度三個月國庫券利率(i3)、消費物價通脹(inf)和實質國內生產總值增長(),全部以百分比計。
Static model. Regressing the rate on current inflation and growth gives an inflation coefficient of 0.66 and a growth coefficient of 0.03 that is nowhere near significant (). But the residuals are strongly autocorrelated: their first five autocorrelations are 0.78, 0.55, 0.39, 0.18 and 0.07, against bands of , and the partial autocorrelation cuts off after lag 1. The Breusch–Godfrey statistic for first-order serial correlation is 23.68. The static model’s t statistics cannot be trusted.
靜態模型。把利率對當期通脹和增長回歸,通脹係數為 0.66,增長係數為 0.03,遠未達到顯著()。但殘差有很強的自相關:首五個自相關係數為 0.78、0.55、0.39、0.18 和 0.07,而範圍是 ;偏自相關在滯後 1 期之後截斷。一階序列相關的 Breusch–Godfrey 統計量為 23.68。靜態模型的 t 統計量並不可信。
That is no surprise: central banks move rates in small steps, so this year’s rate depends heavily on last year’s. The serial correlation is a sign of missing dynamics. Add lags:
這並不意外:中央銀行以小步調整利率,所以今年的利率很大程度上取決於去年的利率。序列相關是缺少動態的跡象。加入滯後項:
| Static | ARDL | ARDL | ARDL | |
|---|---|---|---|---|
| Intercept 截距 | 2.918(0.900) | −1.387(0.758) | −1.026(0.744) | −1.206(0.673) |
| i3ₜ₋₁ 利率滯後一期 | — | 0.829(0.101) | 1.214(0.215) | 1.089(0.175) |
| i3ₜ₋₂ 利率滯後兩期 | — | — | −0.358(0.179) | −0.342(0.140) |
| infₜ 通脹 | 0.658(0.110) | 0.531(0.121) | 0.492(0.117) | 0.319(0.074) |
| infₜ₋₁ 通脹滯後一期 | — | −0.232(0.159) | −0.283(0.153) | — |
| gₜ 經濟增長 | 0.031(0.154) | 0.300(0.092) | 0.417(0.105) | 0.412(0.096) |
| gₜ₋₁ 增長滯後一期 | — | 0.039(0.107) | −0.110(0.126) | — |
| n | 36 | 35 | 35 | 35 |
| R² | 0.562 | 0.884 | 0.898 | 0.885 |
| BG (q = 1) | 23.68 | 4.15 | 0.83 | 3.70 |
Standard errors in parentheses. BG is the Breusch–Godfrey statistic for first-order serial correlation; its 5% critical value is 3.84.
括號內為標準誤。BG 是一階序列相關的 Breusch–Godfrey 統計量,5% 臨界值為 3.84。
ARDL(1,1): one lag of everything. The lagged rate is large (0.83) and growth becomes significant, but BG = 4.15 still rejects no serial correlation at 5%.
ARDL(1,1):每個變數加入一個滯後項。滯後利率很大(0.83),增長變得顯著,但 BG = 4.15 仍然在 5% 水平下拒絕沒有序列相關。
ARDL(2,1): a second lag of the rate removes the serial correlation (BG = 0.83). The lags of inflation and growth are not significant at 5%.
ARDL(2,1):加入利率的第二個滯後項後,序列相關消失(BG = 0.83)。通脹和增長的滯後項在 5% 水平下都不顯著。
ARDL(2,0): dropping them leaves BG = 3.70, just under 3.84 (p = 0.054). Every coefficient is significant.
ARDL(2,0):剔除它們後 BG = 3.70,僅低於 3.84(p = 0.054)。所有係數都顯著。
The estimated reaction function is
估計所得的反應函數為
Impact: a one-point rise in inflation raises the T-bill rate by 0.32 points in the same year; a one-point rise in growth raises it by 0.41 points.
即時效應:通脹上升一個百分點,同年國庫券利率上升 0.32 個百分點;增長上升一個百分點,利率上升 0.41 個百分點。
Long run: , so a permanent one-point rise in inflation eventually raises the rate by points, and in growth by points.
長期效應:,所以通脹永久上升一個百分點,最終令利率上升 個百分點;增長則令利率上升 個百分點。
A long-run inflation response above 1 means that, eventually, the real interest rate rises when inflation rises: the pattern central banks aim for. The static model, at 0.66, suggested the opposite. Use the first preset of the demo in Section 7 to watch the rate climb towards 1.26 over about six years.
長期通脹反應大於 1,表示通脹上升時實質利率最終也會上升:這正是中央銀行追求的模式。靜態模型的 0.66 卻暗示相反的結論。用第 7 節示範的第一個預設值,可以看到利率在大約六年內逐步攀升至 1.26。
AR errors are a restricted ARDLAR 誤差是受限制的 ARDL
Week 9 treated serial correlation as a property of the errors. How does that compare with a dynamic model? Take a static regression with AR(1) errors:
第 9 週把序列相關視為誤差的性質。這與動態模型有甚麼分別?考慮一個帶 AR(1) 誤差的靜態回歸:
Subtract times the equation for period to remove :
減去第 期方程的 倍,以消去 :
This is an ARDL(1,1) with , and : a restricted one, with . Its long-run effect is
這是一個 ARDL(1,1),其中 、、:一個受限制的 ARDL,限制為 。它的長期效應是
the same as the impact effect. A regression with AR errors forces the whole effect of to happen at once; all the dynamics sit in the part of that does not explain. The ARDL relaxes that restriction and lets the data say how the effect unfolds. That is why, in the example, adding lags was the better response to serial correlation than keeping the static model and fixing its standard errors.
與即時效應相同。帶 AR 誤差的回歸強制 的全部效應即時發生;所有動態都在 中 解釋不到的部分之內。ARDL 放寬了這個限制,讓數據說明效應怎樣展開。這就是為甚麼在例子中,加入滯後項比保留靜態模型再修正標準誤更能回應序列相關。
Reproduce the results自己重現結果
Both datasets come with the free wooldridge package (in Python, the inf column is copied to infl because formulas read “inf” as infinity). Both snippets reproduce every figure on this page.
兩個數據集都收錄在免費的 wooldridge 套件中(在 Python 中,inf 一欄被複製為 infl,因為公式會把「inf」讀作無限大)。兩段程式碼都會重現本頁的所有數字。
library(wooldridge)
# Trend and seasonality: monthly traffic accidents in California, 1981-1989
lin <- lm(totacc ~ t, data = traffic2) # +121 accidents a month
expo <- lm(ltotacc ~ t, data = traffic2) # +0.285% a month
months <- c("feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec")
f <- reformulate(c("t", months), response = "ltotacc")
seas <- lm(f, data = traffic2)
anova(expo, seas) # seasonality: F = 5.15 on 11, 95
# Structural break: the seat belt law of January 1986
brk <- lm(update(f, . ~ . + beltlaw + beltt), data = traffic2)
coef(summary(brk))[c("t", "beltlaw", "beltt"), ] # level +0.262, slope -0.00228
# Dynamics: US 3-month T-bill rate, inflation and GDP growth, 1959-1995
d <- inven
d$g <- 100 * d$ggdp # GDP growth in percent
lag1 <- function(x, k = 1) c(rep(NA, k), head(x, -k))
d$i3_1 <- lag1(d$i3); d$i3_2 <- lag1(d$i3, 2)
d$inf_1 <- lag1(d$inf); d$g_1 <- lag1(d$g)
bg <- function(m, q = 1) { # Breusch-Godfrey, (n - q) R^2
e <- resid(m); n <- length(e)
lags <- sapply(1:q, function(j) c(rep(NA, j), e[1:(n - j)]))
aux <- lm(e ~ model.matrix(m)[, -1] + lags)
(n - q) * summary(aux)$r.squared
}
static <- lm(i3 ~ inf + g, data = d)
ardl11 <- lm(i3 ~ i3_1 + inf + inf_1 + g + g_1, data = d)
ardl21 <- lm(i3 ~ i3_1 + i3_2 + inf + inf_1 + g + g_1, data = d)
ardl20 <- lm(i3 ~ i3_1 + i3_2 + inf + g, data = d)
sapply(list(static, ardl11, ardl21, ardl20), bg) # 23.68 4.15 0.83 3.70
acf(resid(static), lag.max = 5) # 0.781 0.554 0.393 ...
summary(ardl20)
# Long-run effects: sum of x coefficients / (1 - sum of y-lag coefficients)
b <- coef(ardl20)
den <- 1 - b["i3_1"] - b["i3_2"]
c(inflation = b["inf"] / den, growth = b["g"] / den) # 1.26 and 1.63
# pip install wooldridge statsmodels
import numpy as np
import statsmodels.formula.api as smf
from statsmodels.tsa.stattools import acf
import wooldridge as wd
# Trend and seasonality: monthly traffic accidents in California, 1981-1989
tr = wd.data("traffic2")
lin = smf.ols("totacc ~ t", data=tr).fit() # +121 accidents a month
expo = smf.ols("ltotacc ~ t", data=tr).fit() # +0.285% a month
months = ["feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
seas = smf.ols("ltotacc ~ t + " + " + ".join(months), data=tr).fit()
print(seas.compare_f_test(expo)) # seasonality: F = 5.15, p = 0.000003
# Structural break: the seat belt law of January 1986
brk = smf.ols("ltotacc ~ t + " + " + ".join(months) + " + beltlaw + beltt", data=tr).fit()
print(brk.params[["t", "beltlaw", "beltt"]]) # level +0.262, slope -0.00228
# Dynamics: US 3-month T-bill rate, inflation and GDP growth, 1959-1995
d = wd.data("inven")
d["g"] = 100 * d.ggdp # GDP growth in percent
d["infl"] = d["inf"] # "inf" reads as infinity in formulas
for col, k in [("i3", 1), ("i3", 2), ("infl", 1), ("g", 1)]:
d[f"{col}_{k}"] = d[col].shift(k)
def bg(m, q=1): # Breusch-Godfrey, (n - q) R^2
e = m.resid.to_numpy()
X = m.model.exog
lags = np.column_stack([np.r_[np.full(j, np.nan), e[:-j]] for j in range(1, q + 1)])
keep = ~np.isnan(lags).any(axis=1)
Z = np.column_stack([X, lags])[keep]
fit = np.linalg.lstsq(Z, e[keep], rcond=None)[0]
r = e[keep] - Z @ fit
r2 = 1 - (r @ r) / ((e[keep] - e[keep].mean()) ** 2).sum()
return keep.sum() * r2
static = smf.ols("i3 ~ infl + g", data=d).fit()
ardl11 = smf.ols("i3 ~ i3_1 + infl + infl_1 + g + g_1", data=d).fit()
ardl21 = smf.ols("i3 ~ i3_1 + i3_2 + infl + infl_1 + g + g_1", data=d).fit()
ardl20 = smf.ols("i3 ~ i3_1 + i3_2 + infl + g", data=d).fit()
print([round(bg(m), 2) for m in (static, ardl11, ardl21, ardl20)]) # 23.68 4.15 0.83 3.7
print(acf(static.resid, nlags=5)[1:].round(3)) # 0.781 0.554 0.393 ...
print(ardl20.summary())
# Long-run effects: sum of x coefficients / (1 - sum of y-lag coefficients)
b = ardl20.params
den = 1 - b["i3_1"] - b["i3_2"]
print(b["infl"] / den, b["g"] / den) # 1.26 and 1.63
Check your understanding自我測驗
-
A regression of log quarterly sales on a time trend gives . What is the approximate annual growth rate?
把季度銷售額的對數對時間趨勢回歸,得到 。大約的年增長率是多少?
Answer 答案
About 1.2% a quarter, so a year (roughly ).
每季約 1.2%,所以每年為 (大約 )。
-
Quarterly data, three seasonal dummies plus a trend. The F test of the three dummies has p = 0.40. What do you conclude, and would changing the base quarter change it?
季度數據,有三個季節虛擬變數加上趨勢。三個虛擬變數的 F 檢定 p = 0.40。你的結論是甚麼?改變基準季度會否改變結論?
Answer 答案
No evidence of seasonality once the trend is accounted for. The base quarter does not matter: the joint F test, the fit and the residuals are identical whichever quarter is left out.
在考慮趨勢之後,沒有季節性的證據。基準季度並不重要:無論剔除哪一季,聯合 F 檢定、擬合程度和殘差都完全相同。
-
with white-noise of variance 9. Find the mean, the variance and .
,其中 是方差為 9 的白噪音。求均值、方差和 。
Answer 答案
Mean ; variance ; correlation .
均值 ;方差 ;相關係數 。
-
The lecture’s RBA equation is . Find the impact and long-run effects of a one-point rise in GDP growth and in inflation.
課堂的澳洲儲備銀行方程為 。求國內生產總值增長和通脹各上升一個百分點的即時效應和長期效應。
Answer 答案
Impact: 0.049 and 0.042 points. The denominator is , so the long-run effects are for growth and for inflation. (With the unrounded estimates, 0.78 and 0.69.) Because the denominator is small, the long run is much larger than the impact: the cash rate adjusts slowly.
即時效應:0.049 和 0.042 個百分點。分母為 ,所以長期效應分別為增長 、通脹 。(用未經四捨五入的估計值則為 0.78 和 0.69。)由於分母很小,長期效應遠大於即時效應:現金利率調整得很慢。
-
A regression with AR(1) errors has and . Written as an ARDL(1,1), what are , and , and what is the long-run effect?
一個帶 AR(1) 誤差的回歸有 、。寫成 ARDL(1,1) 時,、 和 是多少?長期效應是多少?
Answer 答案
, , . The long-run effect is , equal to the impact effect, as it must be for AR errors.
、、。長期效應為 ,等於即時效應,這正是 AR 誤差模型的必然結果。
Sources and acknowledgement 資料來源與鳴謝
- Lecture materials for Introductory Econometrics (ETC2410) by Associate Professor Didier Nibbering, Department of Econometrics and Business Statistics, Monash Business School.
- Jeffrey M. Wooldridge, Introductory Econometrics: A Modern Approach, Chapters 10.2, 10.5, 11.1–11.3 and 18.1.
- Data: traffic2 and inven, distributed with the textbook and in the wooldridge R package. All estimates on this page were computed from them. The AR(1) panels are simulated.
Any errors are our own.