全文链接:http://tecdat.cn/?p=31108
原文出处:拓端数据部落公众号
作为掂量通货膨胀的根本指标,消费者价格指数CPI和生产者价格指数PPI的作用关系与传导机制始终是宏观经济钻研的外围问题。
对此问题的钻研显然具备重要的学术价值与现实意义:当PPI后行地疏导着CPI的变动,则意味着上游价格对上游价格具备正向传导效应,物价可能因供应因素的冲击而回升,并由此引发“老本推动型通胀”的危险,此时,通胀治理应以“供应调控”为主;反之,当CPI疏导着PPI的变动,则意味着存在上游价格对上游价格的反向倒逼机制,物价可能因需要因素的冲击而回升,并由此引发“需要拉动型通胀”的危险,此时的通胀治理则应以“需要调控”为主。
咱们围绕因果关系测验技术进行一些征询,帮忙客户解决独特的业务问题。
数据:CPI与PPI 月度同比数据
读取数据
head(data)## 当月同比 CPI PPI ## 1 36556 -0.2 0.03 ## 2 36585 0.7 1.20 ## 3 36616 -0.2 1.87 ## 4 36646 -0.3 2.59 ## 5 36677 0.1 0.67 ## 6 36707 0.5 2.95
CPI数据
## ## Residuals: ## Min 1Q Median 3Q Max ## -4.3232 -1.2663 -0.5472 0.9925 6.3941 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 1.05348 0.30673 3.435 0.000731 *** ## t 0.01278 0.00280 4.564 9.05e-06 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 2.1 on 187 degrees of freedom ## Multiple R-squared: 0.1002, Adjusted R-squared: 0.09543 ## F-statistic: 20.83 on 1 and 187 DF, p-value: 9.055e-06
1、 单位根测验
查看数据后发现须要进行节令调整
给出输入后果:
## Augmented Dickey-Fuller Test ## ## data: x ## Dickey-Fuller = -2.0274, Lag order = 0, p-value = 0.4353 ## alternative hypothesis: explosive
## ############################################### ## # Augmented Dickey-Fuller Test Unit Root Test # ## ############################################### ## ## Test regression trend ## ## ## Call: ## lm(formula = z.diff ~ z.lag.1 + 1 + tt) ## ## Residuals: ## Min 1Q Median 3Q Max ## -2.66698 -0.36462 0.02973 0.39311 1.97552 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 1.063e-01 9.513e-02 1.117 0.2653 ## z.lag.1 -4.463e-02 2.201e-02 -2.027 0.0441 * ## tt 4.876e-05 8.954e-04 0.054 0.9566 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.6307 on 185 degrees of freedom ## Multiple R-squared: 0.0238, Adjusted R-squared: 0.01324 ## F-statistic: 2.255 on 2 and 185 DF, p-value: 0.1077 ## ## ## Value of test-statistic is: -2.0274 1.5177 2.255 ## ## Critical values for test statistics: ## 1pct 5pct 10pct ## tau3 -3.99 -3.43 -3.13 ## phi2 6.22 4.75 4.07 ## phi3 8.43 6.49 5.47
PPI数据
## Augmented Dickey-Fuller Test ## ## data: x ## Dickey-Fuller = -1.3853, Lag order = 0, p-value = 0.1667 ## alternative hypothesis: explosive
(1)若存在单位根,用差分后序列进行2、3、4 步;
(2)若不存在单位根,就用原序列。
因而,对两个数据都进行差分。
data$CPI=c(0,diff(data$CPI))
2、 测验协整关系——EG两步法
给出输入后果
(1)若存在长期协整,用VECM法线性过滤,利用利用过滤后的“残差成分”再进行3,4 步;
(2)若不存在长期协整,就不必过滤,间接进行3、4步。
建设长期平衡模型
## Call: ## lm(formula = PPI ~ CPI, data = data) ## ## Residuals: ## Min 1Q Median 3Q Max ## -3.6930 -0.5071 -0.0322 0.4637 3.2085 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -0.03678 0.06428 -0.572 0.568 ## CPI 0.54389 0.10176 5.345 2.61e-07 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.8836 on 187 degrees of freedom ## Multiple R-squared: 0.1325, Adjusted R-squared: 0.1279 ## F-statistic: 28.57 on 1 and 187 DF, p-value: 2.615e-07
绘制残差
ts.plot( residual
不存在长期协整,就不必过滤,间接进行3、4步
3、 非线性测验——RESET测验办法
给出输入后果
## RESET test ## ## data: data$PPI ~ data$CPI ## RESET = 0.28396, df1 = 1, df2 = 186, p-value = 0.5948
4、 建设VAR模型、格兰杰因果测验
建设VAR模型给出输入后果
## $Granger ## ## Granger causality H0: CPI do not Granger-cause PPI ## ## data: VAR object var.2c ## F-Test = 5.1234, df1 = 2, df2 = 364, p-value = 0.006392 ## ## ## $Instant ## ## H0: No instantaneous causality between: CPI and PPI ## ## data: VAR object var.2c ## Chi-squared = 15.015, df = 1, p-value = 0.0001067
p值小于给定的显著性程度回绝,个别p值小于0.05,非凡状况下能够放宽到0.1。 f统计量大于分位点即可。 个别看p值,F还要查表 自己认为,格兰杰测验次要看P值即可。 例如,若P值小于0.1,则回绝原假如,变量间存在格兰杰因果关系。
最受欢迎的见解
1.在python中应用lstm和pytorch进行工夫序列预测
2.python中利用长短期记忆模型lstm进行工夫序列预测剖析
3.Python用RNN循环神经网络:LSTM长期记忆、GRU门循环单元、回归和ARIMA对COVID-19新冠疫情新增人数工夫序列
4.Python TensorFlow循环神经网络RNN-LSTM神经网络预测股票市场价格工夫序列和MSE评估准确性
5.r语言copulas和金融工夫序列案例
6.R 语言用RNN循环神经网络 、LSTM长短期记忆网络实现工夫序列长期利率预测
7.Matlab创立向量自回归(VAR)模型剖析消费者价格指数 (CPI) 和失业率工夫序列
8.r语言k-shape工夫序列聚类办法对股票价格工夫序列聚类
9.R语言联合新冠疫情COVID-19股票价格预测:ARIMA,KNN和神经网络工夫序列剖析