R language EG (Engle-Granger) two-step cointegration test, RESET, Granger causality test, VAR model to analyze the time series relationship between CPI and PPI…

Full text link: http://tecdat.cn/?p=31108

As basic indicators for measuring inflation, the relationship and transmission mechanism of consumer price index CPI and producer price index PPI have always been core issues in macroeconomic research. (Click “Read the original text” at the end of the article to get the completecode data) .

Research on this issue obviously has important academic value and practical significance: when PPI leads changes in CPI, it means that upstream prices have a positive conduction effect on downstream prices, and prices may rise due to the impact of supply factors, and This leads to the risk of “cost-push inflation”. At this time, inflation management should focus on “supply control”; conversely, when CPI guides changes in PPI, it means that there is reverse pressure from downstream prices on upstream prices. Mechanism, prices may rise due to the impact of demand factors, which may lead to the risk of “demand-pull inflation”. At this time, inflation management should focus on “demand control”.

Related videos

We do some consulting around causality testing techniques to help clients solve unique business problems.

Data: CPI and PPI monthly year-on-year data

outside_default.png

Read data

head(data)

## Year-on-year CPI PPI for the month
## 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 data

outside_default.png

##
## 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. Unit root test

After reviewing the data, I found that seasonal adjustments are needed.

gives the output:

outside_default.png

Click on the title to view previous issues

outside_default.png

R language ECM error correction model, equilibrium correction model, restricted VECM, cointegration test, unit root test spot interest rate market data

outside_default.png

Swipe left or right to see more

outside_default.png

01

outside_default.png

02

outside_default.png

03

outside_default.png

04

outside_default.png

## 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 data

outside_default.png

outside_default.png

## Augmented Dickey-Fuller Test
##
## data: x
## Dickey-Fuller = -1.3853, Lag order = 0, p-value = 0.1667
## alternative hypothesis: explosive

(1) If there is a unit root, use the differential sequence to perform steps 2, 3, and 4;

(2) If there is no unit root, use the original sequence.

Therefore, both data are differentiated.

data$CPI=c(0,diff(data$CPI))

2. Testing the cointegration relationship – EG two-step method

Give the output

(1) If there is long-term cointegration, use the VECM method to linearly filter, and use the filtered “residual component” to proceed to steps 3 and 4;

(2) If there is no long-term cointegration, there is no need to filter and proceed directly to steps 3 and 4.

Establish a long-term equilibrium model

## 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

Plot residuals

ts.plot(residual

outside_default.png

If there is no long-term cointegration, there is no need to filter and proceed directly to steps 3 and 4.

3. Nonlinear test – RESET test method

Give the output

## RESET test
##
## data: data$PPI ~ data$CPI
## RESET = 0.28396, df1 = 1, df2 = 186, p-value = 0.5948

4. Establish VAR model and Granger causality test

Establish VAR model to give output results

## $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

The p value is rejected if it is less than the given significance level. Generally, the p value is less than 0.05, and can be relaxed to 0.1 in special cases. The f-statistic is greater than the quantile point. Generally look at the p value.

The Granger test mainly looks at the P value. For example, if the P value is less than 0.1, the null hypothesis is rejected and there is Granger causality between variables.

outside_default.png

The data analyzed in this article is shared to the membership group. Scan the QR code below to join the group!

outside_default.png

outside_default.png

Click “Read original text” at the end of the article

Get the full text and complete code data.

This article is selected from “R language EG (Engle-Granger) two-step cointegration test, RESET, Granger causality test, VAR model analysis of the relationship between CPI and PPI”.

outside_default.png

outside_default.png

Click on the title to view previous issues

Matlab uses the vector error correction VECM model Monte Carlo to predict bond interest rate time series and MMSE prediction

R language vector error correction models (VECMs) analyze the relationship between long-term interest rates and inflation rates

Vector Autoregressive (VAR) Model Analysis of Consumer Price Index (CPI) and Unemployment Rate Time Series

Matlab creates a vector autoregressive (VAR) model to analyze consumer price index (CPI) and unemployment rate time series

Stata generalized method of moments GMM panel vector autoregression VAR model selection, estimation, Granger causality test analysis of investment, income and consumption data

Time-varying vector autoregressive (TV-VAR) model analysis and visualization of time series in R language

R language uses vector autoregression (VAR) to conduct impulse response research and analysis of economic data

R language arima, vector autoregressive (VAR), periodic autoregressive (PAR) model to analyze temperature time series

Different types of impulse response analysis of VAR models in R language

R language stochastic search variable selection SSVS estimates Bayesian vector autoregressive (BVAR) models

R language time-varying parameter VAR stochastic model

Empirical research and analysis case of estimating time-varying VAR model time series using R language

R language vector autoregressive model (VAR) and its implementation

R language to implement vector autoregressive VAR model

Empirical research and analysis case of estimating time-varying VAR model time series using R language

Python and R use EWMA, ARIMA models to predict time series

R language uses LASSO, adaptive LASSO to predict inflation time series

ARIMA model, SARIMA model and SARIMAX model in Python for time series forecasting

R language arima, vector autoregressive (VAR), periodic autoregressive (PAR) model to analyze temperature time series

[Video] Python and R language use exponential weighted average (EWMA), ARIMA autoregressive moving average model to predict time series

outside_default.png

outside_default.png

outside_default.png