1 Viewing dataset

## # A tibble: 6 Ă— 82
##   Date                m1_en_mg m2_en_mg m3_en…¹  ...5 m1_usd m2_usd m3_usd  ...9
##   <dttm>                 <dbl>    <dbl>   <dbl> <dbl>  <dbl>  <dbl>  <dbl> <dbl>
## 1 1958-09-01 00:00:00     90.0     122.      NA    NA   18.0   24.4     NA    NA
## 2 1959-09-01 00:00:00     85.7     119.      NA    NA   17.1   23.9     NA    NA
## 3 1960-09-01 00:00:00     93.4     130.      NA    NA   18.7   25.9     NA    NA
## 4 1961-09-01 00:00:00     93.5     132.      NA    NA   18.7   26.4     NA    NA
## 5 1962-09-01 00:00:00     90.6     132.      NA    NA   18.1   26.3     NA    NA
## 6 1963-09-01 00:00:00     97.6     138.      NA    NA   19.5   27.5     NA    NA
## # … with 73 more variables: tdc_brh <dbl>, ...11 <dbl>, base_mon_mg_usd <dbl>,
## #   base_mon <dbl>, monnaie_circ_mg <dbl>, ...15 <dbl>,
## #   credit_sec_pub_mon_mg <dbl>, multiplicateur_m3_b <dbl>,
## #   multiplicateur_m2_b <dbl>, multiplicateur_m1_b <dbl>, ...20 <dbl>,
## #   reserves_nettes_de_change_brh_mg <dbl>,
## #   reserves_nettes_de_change_sb_mg <dbl>, ...23 <dbl>,
## #   infl_glisse_annuel_en_poucent <dbl>, ...25 <dbl>, …

There are lots of variables so we can select 3 variables as required by question.

Firstly we check the time series of the data and it’s relation with m1_usd using plot command.

We analyse that relation between these variables is non–linear. We can do the same procedure for other variable as well.

The above plots show that the relationship between these variables is non–linear and both are increasing in recent years..

2 Applying the Statistic functions

2.1 stationary Test

Detecting if data is time statinary or not. We can use the function time.series. In order to check if time series is stationary, we use adf.test function of tseries package. Before performing the test we define our two hypothesis as

H0: Variables have Unit Root
Ha: Variable is stationary

We assume significance level of 0.05.

## Augmented Dickey-Fuller Test 
## alternative: stationary 
##  
## Type 1: no drift no trend 
##      lag  ADF p.value
## [1,]   0 7.49    0.99
## [2,]   1 8.09    0.99
## [3,]   2 7.79    0.99
## [4,]   3 6.61    0.99
## [5,]   4 7.30    0.99
## [6,]   5 7.53    0.99
## [7,]   6 8.00    0.99
## Type 2: with drift no trend 
##      lag  ADF p.value
## [1,]   0 6.34    0.99
## [2,]   1 6.94    0.99
## [3,]   2 6.75    0.99
## [4,]   3 5.75    0.99
## [5,]   4 6.43    0.99
## [6,]   5 6.70    0.99
## [7,]   6 7.21    0.99
## Type 3: with drift and trend 
##      lag  ADF p.value
## [1,]   0 3.60    0.99
## [2,]   1 4.09    0.99
## [3,]   2 4.08    0.99
## [4,]   3 3.46    0.99
## [5,]   4 4.06    0.99
## [6,]   5 4.37    0.99
## [7,]   6 4.87    0.99
## ---- 
## Note: in fact, p.value = 0.01 means p.value <= 0.01

The result of stationary test shows that p-value is less than 0.05 hence we reject our null hypotheses and accept the alternative hypothesis Ha.

2.2 Verifying sense de la causalite

Granger causalite test is used to test the causal relationship between two time series. Just like to stationary test, we define our two hypothesis as

H0: Time series data US dollar m1_usd is not causally related to variable cred_sect_priv_mg.

HA: Time series data US dollar m1_usd is causally related to variable cred_sect_priv_mg

It will help us to analyze of the first time series data predicts the future of the second time series data.

## Granger causality test
## 
## Model 1: m1_usd ~ Lags(m1_usd, 1:3) + Lags(cred_sect_priv_mg, 1:3)
## Model 2: m1_usd ~ Lags(m1_usd, 1:3)
##   Res.Df Df      F   Pr(>F)    
## 1    496                       
## 2    499 -3 23.824 2.03e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The result from the granger causalite test shows two models.

Model 1 predicts the future of the price in usd based on its values of 2 variables in previous 3 years since we have used order=3 in equation.

Model 2 uses only the value of in previous 3 years for price in usd.

F-test value comes out to be 23.82. p-value is less than 0.05 which is our significance level at 95% confidence interval. Hence we reject our null hypothesis and accept the alternative hypothesis. We conclude that knowing the value of variable cred_sect_priv_mg is predictive of the variable m1_usd.

We can do the reverse causation test to check if the reverse is true for our hypothesis. It means we can check if the usd is predictive of cred_sect_priv_mg. For that purpose we use following command.

## Granger causality test
## 
## Model 1: cred_sect_priv_mg ~ Lags(cred_sect_priv_mg, 1:3) + Lags(m1_usd, 1:3)
## Model 2: cred_sect_priv_mg ~ Lags(cred_sect_priv_mg, 1:3)
##   Res.Df Df      F   Pr(>F)   
## 1    496                      
## 2    499 -3 4.1981 0.005991 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The result for reverse test indicates that p-value is less than 0.05. Hence we reject our null hypothesis and accept the alternative hypothesis. This reverse test shows that values of variable m1_usd are helpful to predict future values of variable cred_sect_priv_mg.

So in short both values can predict each other.

2.3 Regression test

Now we will do the linear test using one variable as independent and other as dependent. Since it is required to use same variables as casuality test so we use dataset brh here as well. Note that there is no control variable for the dependent variable hence the result should be straight forward to analyze and the test should be only linear regression instead of multiple linear regression. We can define our hypothesis in this test

H0: Variable m1_usdis not linear related to variablecred_sect_priv_mg`

HA: Variable m1_usd has a linear relation to variable cred_sect_priv_mg

Our significance level is again 5%.

## 
## Call:
## lm(formula = m1_usd ~ cred_sect_priv_mg, data = brh)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -576.94  -79.84  -12.32   87.63  504.92 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       2.717e+02  8.605e+00   31.57   <2e-16 ***
## cred_sect_priv_mg 1.464e-02  2.550e-04   57.40   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 155.4 on 504 degrees of freedom
## Multiple R-squared:  0.8673, Adjusted R-squared:  0.8671 
## F-statistic:  3294 on 1 and 504 DF,  p-value: < 2.2e-16

The above result show that p-value is <0.05 hence we reject our null hypothesis and accept the alternative hypothesis which means the two variables are not linearly linked to each other. The other parameters shown in the result are F-stats, Intercept, Adjusted R2, and standard error. We will explain thme one by one below

  • Intercept: The intercept of the linear regression model indicates the value of the independent variable at which the dependent variable is equal to zero.

  • F-stats: F-stats is the ratio of the variance of the residuals to the variance of the our model. Higher the F-stats, the better our model is.

  • Adjusted R2: R2 is the coefficient of determination. It is a measure of how well the model fits the data. Our R2 is 0.85 which is good an it means 85% of time our model does not overfit the data.

  • standard error: Standard error is the standard deviation of the residuals. It is the standard deviation of the error of our model.

  • 3 asterics are used to indicate that the variables are highly significant to each other which does relate to the casuality test where both variables were related to each value as indicated by casuality and reverse casuality test.