11 Further Issues in Using OLS with Time Series Data
Also covered using Python and Stata
11.1 Example 11.4. Efficient Markets Hypothesis
##
## ===============================================
## Dependent variable:
## ---------------------------
## return
## -----------------------------------------------
## return_1 0.059
## (0.038)
## Constant 0.180**
## (0.081)
## -----------------------------------------------
## Observations 689
## R2 0.003
## Adjusted R2 0.002
## Residual Std. Error 2.110 (df = 687)
## F Statistic 2.399 (df = 1; 687)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
11.2 Equation [11.18]
nyse_tsset <- ts(nyse)
mrk_lag2 <- dynlm(return ~ return_1 + L(return, 2), data =nyse_tsset)
stargazer(mrk_lag2, no.space=TRUE, type="text")
##
## ===============================================
## Dependent variable:
## ---------------------------
## return
## -----------------------------------------------
## return_1 0.060
## (0.038)
## L(return, 2) -0.038
## (0.038)
## Constant 0.186**
## (0.081)
## -----------------------------------------------
## Observations 688
## R2 0.005
## Adjusted R2 0.002
## Residual Std. Error 2.112 (df = 685)
## F Statistic 1.659 (df = 2; 685)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
## Linear hypothesis test
##
## Hypothesis:
## return_1 = 0
## L(return, 2) = 0
##
## Model 1: restricted model
## Model 2: return ~ return_1 + L(return, 2)
##
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 687 3069.4
## 2 685 3054.6 2 14.792 1.6586 0.1912
11.3 Example 11.5. Expectations Augmented Phillips Curve
data(phillips, package='wooldridge')
phillips_old <-subset(phillips, phillips$year<1997)
phill_new<-lm(cinf ~ unem + 1, data=phillips) #Slightly longer dataset (1948-2003)
phill_old<-lm(cinf ~ unem + 1, data=phillips_old) #Dataset as in the textbook (1948-1996)
stargazer(phill_new, phill_old, column.labels=c("LongerData", "OriginalData"),no.space=TRUE, type="text")
##
## =============================================================
## Dependent variable:
## -----------------------------------------
## cinf
## LongerData OriginalData
## (1) (2)
## -------------------------------------------------------------
## unem -0.518** -0.543**
## (0.209) (0.230)
## Constant 2.828** 3.031**
## (1.225) (1.377)
## -------------------------------------------------------------
## Observations 55 48
## R2 0.104 0.108
## Adjusted R2 0.087 0.088
## Residual Std. Error 2.307 (df = 53) 2.451 (df = 46)
## F Statistic 6.132** (df = 1; 53) 5.558** (df = 1; 46)
## =============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
## (Intercept)
## 5.585429
11.4 Example 11.6. Fertility Equation
fertil3_tsset <- ts(fertil3)
fert_lag2 <- dynlm(cgfr ~ cpe + L(cpe, 1) + L(cpe, 2), data =fertil3_tsset)
stargazer(fert_lag2, no.space=TRUE, type="text")
##
## ===============================================
## Dependent variable:
## ---------------------------
## cgfr
## -----------------------------------------------
## cpe -0.036
## (0.027)
## L(cpe, 1) -0.014
## (0.028)
## L(cpe, 2) 0.110***
## (0.027)
## Constant -0.964**
## (0.468)
## -----------------------------------------------
## Observations 69
## R2 0.232
## Adjusted R2 0.197
## Residual Std. Error 3.859 (df = 65)
## F Statistic 6.563*** (df = 3; 65)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
## Linear hypothesis test
##
## Hypothesis:
## cpe = 0
## L(cpe,0
##
## Model 1: restricted model
## Model 2: cgfr ~ cpe + L(cpe, 1) + L(cpe, 2)
##
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 67 1006.6
## 2 65 968.2 2 38.413 1.2894 0.2824
11.5 Example 11.7. Wages and Productivity
##
## ===============================================
## Dependent variable:
## ---------------------------
## lhrwage
## -----------------------------------------------
## loutphr 1.640***
## (0.093)
## t -0.018***
## (0.002)
## Constant -5.328***
## (0.374)
## -----------------------------------------------
## Observations 41
## R2 0.971
## Adjusted R2 0.970
## Residual Std. Error 0.029 (df = 38)
## F Statistic 641.224*** (df = 2; 38)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
## ===============================================
## Dependent variable:
## ---------------------------
## ghrwage
## -----------------------------------------------
## goutphr 0.809***
## (0.173)
## Constant -0.004
## (0.004)
## -----------------------------------------------
## Observations 40
## R2 0.364
## Adjusted R2 0.348
## Residual Std. Error 0.017 (df = 38)
## F Statistic 21.771*** (df = 1; 38)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
11.6 Example 11.8. Fertility Equation
fertil3_tsset <- ts(fertil3)
fert_lags <- dynlm(cgfr ~ L(cgfr, 1) + cpe + L(cpe, 1) + L(cpe, 2), data =fertil3_tsset)
stargazer(fert_lags, no.space=TRUE, type="text")
##
## ===============================================
## Dependent variable:
## ---------------------------
## cgfr
## -----------------------------------------------
## L(cgfr, 1) 0.300***
## (0.106)
## cpe -0.045*
## (0.026)
## L(cpe, 1) 0.002
## (0.027)
## L(cpe, 2) 0.105***
## (0.026)
## Constant -0.702
## (0.454)
## -----------------------------------------------
## Observations 69
## R2 0.318
## Adjusted R2 0.275
## Residual Std. Error 3.666 (df = 64)
## F Statistic 7.464*** (df = 4; 64)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
## Linear hypothesis test
##
## Hypothesis:
## cpe = 0
## L(cpe,0
##
## Model 1: restricted model
## Model 2: cgfr ~ L(cgfr, 1) + cpe + L(cpe, 1) + L(cpe, 2)
##
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 66 904.68
## 2 64 860.17 2 44.508 1.6558 0.199