协整理论及其R语言实现.ppt

上传人:本田雅阁 文档编号:2648192 上传时间:2019-04-29 格式:PPT 页数:26 大小:529.51KB
返回 下载 相关 举报
协整理论及其R语言实现.ppt_第1页
第1页 / 共26页
协整理论及其R语言实现.ppt_第2页
第2页 / 共26页
协整理论及其R语言实现.ppt_第3页
第3页 / 共26页
亲,该文档总共26页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《协整理论及其R语言实现.ppt》由会员分享,可在线阅读,更多相关《协整理论及其R语言实现.ppt(26页珍藏版)》请在三一文库上搜索。

1、协整理论及其R语言的实现,邵晨 上海财经大学 统计与管理学院,为什么要协整?,提纲,1,什么是协整?,2,如何进行协整检验?,3,R语言中相关函数,4,案例:中国进出口之间关系检验,5,伪回归(虚假回归),回归分析: 一个重要的前提假设:平稳性 但是,实际上大部分的宏观经济时间序列和金融时间序列都是非平稳的。,伪回归(虚假回归),案例,结果,以1990年至2008年美国城镇居民家庭人均可支配收入和中国人均消费性支出为例: data Usincome Chinacoms reg summary(reg) library(zoo) library(lmtest) dwtest(reg),Call:

2、 lm(formula = Chinacoms USincome) Residuals: Min 1Q Median 3Q Max -640.11 -350.44 -55.96 346.49 1139.42 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -6.886e+03 4.896e+02 -14.06 8.56e-11 * USincome 4.788e-01 1.898e-02 25.23 6.54e-15 * - Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1

3、Residual standard error: 477.7 on 17 degrees of freedom Multiple R-squared: 0.974, Adjusted R-squared: 0.9724 F-statistic: 636.3 on 1 and 17 DF, p-value: 6.544e-15 Durbin-Watson test data: reg DW = 0.4992, p-value = 4.485e-06 alternative hypothesis: true autocorrelation is greater than 0,显著的R2,较大的t值

4、,DW统计量很小,存在严重的自相关,线性回归模型,lm()函数: 用法: fitted.model - lm(formula, data, subset, weights) 参数: formula response terms data 数据框。 subset 取出数据集的一个子集。 weights 权重向量,用于加权最小二乘估计。,例如: reg - lm(y x1 + x2, data=output),提取回归模型中所需信息的函数: coef(reg) resid(reg) plot(reg) summary(reg),伪回归(虚假回归),Diagram 2,Diagram 2,含义:指两

5、个没有因果关系的时间序列之间,基于一些其他的外在因素,推断出因果关系。例如:事件C导致事件A和事件B,如果在A和B之间进行回归分析,则容易推断出A和B之间存在因果关系的错误结论。 特征: 1、对参数的检验(t检验)和对回归方程的检验(F检验)容易得到显著的结果,接近于1的R2。 2、残差存在严重的正自相关。 结果: 许多非平稳经济变量之间显著的相关性可能并不存在,是虚假的。,传统的解决方法,传统方法,一阶差分后进行回归,缺点,1.经济理论往往研究的是变量的水平值而不是差分值,差分后的模型不好解释 2.丢失一些有用的长期信息,移除线性趋势,1.假设序列存在独立的确定性趋势 2.只能解释变量之间的

6、短期关系,协整,协整,定义:对于两个非平稳时间序列Xt和Yt如果 Xt和Yt为I(1)序列; 存在线性组合Xt+bYt使得Xt+bYt是平稳序列; 则称Xt与Yt之间具有协整关系。 描述了时间序列之间的长期均衡关系。,误差修正模型,定义:时间序列Xt和Yt的误差修正模型表示为: 其中t是平稳随机序列,zt-1是误差修正项。 描述了时间序列之间的短期波动关系。,为什么要协整?,提纲,1,什么是协整?,2,如何进行协整检验?,3,R语言中相关函数,4,案例:中国进出口之间关系检验,5,协整检验步骤,单位根检验,目的:检验时间序列是否存在单位根,即检验时间序列是否平稳。,原假设:序列存在一个单位根。

7、,检验过程:原假设=0,协整检验,协整检验前提条件:多个时间序列必须是同阶单整的。 协整检验方法: 1.Engle-Granger两步检验法 2.Johansen检验法 Engle-Granger两步检验法: 1.用OLS估计法对X,Y进行回归估计,得到残差序列zt,检验残差的平稳性。 2.根据格兰杰表述定理建立误差修正模型。,为什么要协整?,提纲,1,什么是协整?,2,如何进行协整检验?,3,R语言中相关函数,4,案例:中国进出口之间关系检验,5,生成时间序列,stat包中的ts函数: 用法: ts(data = NA, start = 1, end = numeric(0), freque

8、ncy = 1, deltat = 1, ts.eps = getOption(“ts.eps“), class = , names = ) 参数: data 一个数值向量。 start 时间序列的起始时刻。可以是一个整数,也可以是两个整数组成的向量。 end 时间序列的最后时刻。 frequency 频率,一个单位时间内的观测次数。 names 字符型向量。,时间序列举例,年度数据: ts(1:30,start=1980,end=2009, frequency=1),季度数据: ts(1:30,start=c(2003,3),end= c(2010,4),frequency=4),时间序列举

9、例,月度数据: ts(1:30,start=c(2008,5), frequency=12),每日数据: a print(a,calendar=TRUE),单位根检验,urca包中的ur.df()函数: 用法: ur.df(y, type = c(“none“, “drift“, “trend“), lags = 1, selectlags = c(“Fixed“, “AIC“, “BIC“) 参数: y 被检验的时间序列 type 检验类型: “none”, “drift” 或者 “trend“. lags 内生变量的滞后阶数 selectlags 滞后阶数确定方法:the Akaike “

10、AIC” 或者 the Bayes “BIC” 信息 准则,默认值是fixed,由lags确定滞后阶数。,案例分析:中国进出口贸易之间关系,数据来源:国家统计数据库( http:/ library(urca) urt.ex summary(urt.ex),# # Augmented Dickey-Fuller Test Unit Root Test # # Test regression trend Call: lm(formula = z.diff z.lag.1 + 1 + tt + z.diff.lag) Residuals: Min 1Q Median 3Q Max -0.17362

11、-0.05933 0.02236 0.05216 0.12439 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.77701 0.53253 1.459 0.158 z.lag.1 -0.15325 0.11600 -1.321 0.199 tt 0.02699 0.01723 1.566 0.130 z.diff.lag 0.20945 0.20765 1.009 0.323 Residual standard error: 0.08564 on 24 degrees of freedom Multiple R-

12、squared: 0.2354, Adjusted R-squared: 0.1398 F-statistic: 2.462 on 3 and 24 DF, p-value: 0.08697 Value of test-statistic is: -1.3211 7.0028 3.0289 Critical values for test statistics: 1pct 5pct 10pct tau3 -4.15 -3.50 -3.18 phi2 7.02 5.13 4.31 phi3 9.31 6.73 5.61, urt.im summary(urt.im),Value of test-

13、statistic is: -2.2266 6.0966 3.3771 Critical values for test statistics: 1pct 5pct 10pct tau3 -4.15 -3.50 -3.18 phi2 7.02 5.13 4.31 phi3 9.31 6.73 5.61,单位根检验,对dlnex单位根检验结果: Value of test-statistic is: -3.2348 5.2379 Critical values for test statistics: 1pct 5pct 10pct tau2 -3.58 -2.93 -2.60 phi1 7.0

14、6 4.86 3.94,对dlnim单位根检验结果: Value of test-statistic is: -4.8372 11.7049 Critical values for test statistics: 1pct 5pct 10pct tau2 -3.58 -2.93 -2.60 phi1 7.06 4.86 3.94,结论:中国进口和出口的对数时间序列不平稳,但一阶差分后平稳,说明是一阶单整序列,即lnex,lnim I(1),满足协整检验条件。,dlnex - diff(lnex),dlnim- diff(lnim),EG两步协整检验:第一步(回归方程估计), exim ex

15、im lnim lnex reg summary(reg) library(lmtest) dw - dwtest(reg),Call: lm(formula = lnex lnim) Residuals: Min 1Q Median 3Q Max -0.40306 -0.05373 0.01223 0.07645 0.23619 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -0.48270 0.14717 -3.28 0.00278 * lnim 1.07457 0.02077 51.74 2e-16 * - S

16、ignif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 0.1401 on 28 degrees of freedom Multiple R-squared: 0.9897, Adjusted R-squared: 0.9893 F-statistic: 2677 on 1 and 28 DF, p-value: 2.2e-16,Durbin-Watson test data: reg DW = 0.9589, p-value = 0.0004282 alternative hypothesis: true

17、autocorrelation is greater than 0,协整回归方程:lnex=-0.4827+1.0746lnim+t,EG两步协整检验:第一步(残差单位根检验), error urt.resid summary(urt.resid) Value of test-statistic is: -3.6185 Critical values for test statistics: 1pct 5pct 10pct tau1 -2.62 -1.95 -1.61,结论:残差平稳,说明两个时间序列之间存在协整关系。 意味着我国的进口和出口之间具有长期均衡关系,增长或者减少具有协同效应。,E

18、G两步协整检验:第二步(误差修正模型的建立), error error.lagged ecm.reg1 summary(ecm.reg1) dwtest(ecm.reg1),Call: lm(formula = dlnex error.lagged + dlnim, data = diff.dat) Residuals: Min 1Q Median 3Q Max -0.17214 -0.05198 0.01546 0.05053 0.14514 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.10648 0.023

19、58 4.516 0.000131 * error.lagged -0.29647 0.11430 -2.594 0.015645 * dlnim 0.33929 0.12470 2.721 0.011681 * - Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 0.08024 on 25 degrees of freedom Multiple R-squared: 0.3008, Adjusted R-squared: 0.2448 F-statistic: 5.377 on 2 and 25

20、DF, p-value: 0.01142,Durbin-Watson test data: ecm.reg1 DW = 2.408, p-value = 0.827 alternative hypothesis: true autocorrelation is greater than 0,EG两步协整检验:第二步(误差修正模型的建立),误差修正模型: lnext=0.1065-0.2965ecmt-1+0.3393lnimt+t,结论: 误差修正项的系数为负,符合误差修正机制,反映了上一期偏离长期均衡的数量将在下一期得到30%的反向修正,这也符合之前证明的协整关系。,总结,中国进出口之间的长期均衡关系: lnext=-0.4827+1.0745lnimt 短期波动关系: lnext=0.1065-0.2965ecmt-1+0.3393lnimt+t,Thank you,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1