0% found this document useful (0 votes)
99 views10 pages

Simultaneous Equations Modelling in Rstudio

This document discusses using simultaneous equations modeling and two-stage least squares (2SLS) to estimate the relationship between inflation and stock returns while accounting for feedback between the two variables. The results show that stock returns positively affect inflation while inflation negatively affects stock returns, though not significantly. A Hausman test suggests stock returns are endogenous while inflation is exogenous. The document also discusses estimating a vector autoregressive (VAR) model to examine lead-lag relationships between exchange rates of the euro, British pound and Japanese yen against the US dollar.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views10 pages

Simultaneous Equations Modelling in Rstudio

This document discusses using simultaneous equations modeling and two-stage least squares (2SLS) to estimate the relationship between inflation and stock returns while accounting for feedback between the two variables. The results show that stock returns positively affect inflation while inflation negatively affects stock returns, though not significantly. A Hausman test suggests stock returns are endogenous while inflation is exogenous. The document also discusses estimating a vector autoregressive (VAR) model to examine lead-lag relationships between exchange rates of the euro, British pound and Japanese yen against the US dollar.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Simultaneous Equations Modelling

Secciones 7.5–7.9 material impreso

What is the relationship between inflation and stock returns? Clearly, they ought to be simultaneously
related given that the rate of inflation will affect the discount rate applied to cashflows and therefore
the value of equities, but the performance of the stock market may also affect consumer demand and
therefore inflation through its impact on householder wealth (perceived or actual).
This simple example uses the same macroeconomic data as used previously (‘macro.RData’) to
estimate this relationship simultaneously. Suppose (without justification) that we wish to estimate the
following model, which does not allow for dynamic effects or partial adjustments and does not distinguish
between expected and unexpected inflation

inflationt = α0 + α1 returnst + α2 dcreditt + α3 dprodt + α4 dmoney + u1t (10)


returnst = β0 + β1 dprodt + β2 dspreadt + β3 inflationt + β4 rtermt + u2t (11)

where ‘returns’ are stock returns .


It is evident that there is feedback between the two equations since the inflation variable appears
in the returns equation and vice versa. Two-stage least squares (2SLS) is therefore the appropriate
technique to use. To do this we need to specify a list of instruments, which would be all of the variables
from the reduced form equation. In this case, the reduced form equations would be:

inflation = f (constant, dprod, dspread, rterm, dcredit, rterm, dmoney) (12)


returns = g(constant, dprod, dspread, rterm, dcredit, rterm, dmoney) (13)

For this example we will be using the ‘macro.RData’ file and the package AER, which provides the
function ivreg() to run instrumental variable regressions. The function works in a similar fashion to the
known lm function with the additional argument instruments. Hence, we put the exogenous variables
on the right hand side of the formula and either define the instruments using the argument directly or
after the exogenous variables separated by |. Also, as with other models, we can call them using the
summary function to see the results in the following way.

1
For the returns regression, we simply alter the formula and obtain the results below.

The results show that the stock index returns are a positive and significant determinant of inflation
(changes in the money supply negatively affect inflation), while inflation has a negative effect on the

2
stock market, albeit not significantly so.
It may also be of relevance to conduct a Hausman test for the endogeneity of the inflation and stock
return variables. To do this, we estimate the reduced form equations and add the fitted values to these
equations. Hence, we run the simple OLS regressions and save the results as follows.
inf_ols = lm ( inflation ~ dprod + dspread + rterm + dcredit + dmoney , data =
macro )
ret_ols = lm ( rsandp ~ dprod + dspread + rterm + dcredit + dmoney , data =
macro )
macro$inffit = c ( NA , inf_ols$fitted . values )
macro$retfit = c ( NA , ret_ols$fitted . values )

Before we add the fitted values to the following two regressions.

3
The conclusion is that the inflation fitted value term is not significant in the stock return equation and
so inflation can be considered exogenous for stock returns. Thus it would be valid to simply estimate
this equation (minus the fitted value term) on its own using OLS. But the fitted stock return term is
significant in the inflation equation, suggesting that stock returns are endogenous.

4
Vector Autoregressive (VAR) Models
Sección 7.10 material impreso

In this section, a VAR model is estimated in order to examine whether there are lead–lag relationships
between the returns to three exchange rates against the US dollar – the euro, the British pound and the
Japanese yen. The data are daily and run from 14 December 1998 to 3 July 2018, giving a total of 7,142
observations. The data are contained in the Excel file ‘currencies.xls’. First, we import the dataset
into R and construct a set of continuously compounded percentage returns called ‘reur’, ‘rgbp’ and
‘rjpy’ using the following set of commands, respectively
currencies$reur = c ( NA , 1 0 0 * diff ( log ( currencies$EUR ) ) )
currencies$rgbp = c ( NA , 1 0 0 * diff ( log ( currencies$GBP ) ) )
currencies$rjpy = c ( NA , 1 0 0 * diff ( log ( currencies$JPY ) ) )
currencies = currencies [ - 1 ,]

Note that we also remove the first observations to avoid problems with ‘NA’ values.
VAR estimation, diagnostic testing, forecasting and causality analysis in R is implemented in the
package vars. To estimate a VAR(2) model for the currency returns, use the function VAR with input
data and lag length.
VAR ( currencies [ c ( " reur " ," rgbp " ," rjpy " ) ] , p = 2 )

The regression output from running the above code is shown on the next page. It is sectioned into the
three dimensions of the vector.

5
We will shortly discuss the interpretation of the output, but the example so far has assumed that we
know the appropriate lag length for the VAR. However, in practice, the first step in the construction of
any VAR model, once the variables that will enter the VAR have been decided, will be to determine the
appropriate lag length. For this purpose, vars provides the function VARselect, which again only needs
the dataset and the maximal lag length to compute four information criteria. Applying the function to
the dataset with a maximal lag length (lag.max) of 10 produces the following output.

6
The results present the values of four information criteria: the Akaike (AIC), Hannan–Quinn (HQ),
Schwarz (SC) and the Final Prediction Error (FPE) criteria. Under the variable selection, you can
find the optimal lag length according to the four criteria. The AIC and FPE criteria select a lag length of
four, while HQ suggests only two and SC chooses a VAR(1). Let us estimate a VAR(1) and examine
the results. Does the model look as if it fits the data well? Why or why not?
We run the same command as before using a lag length of 1 and save the model into a new variable
var.
var = VAR ( currencies [ c ( " reur " ," rgbp " ," rjpy " ) ] , p = 1 )

Next, we run a Granger causality test which is implemented in the function causality. The input will
be the estimated VAR model var and a string vector cause specifying from which variables the causality
originates. This can be a single variable or a couple of variables. However, the function does not allow
the user to specify the other side of the causality. Hence, it automatically performs a joint causality test
on all remaining variables. This implies six possible tests with the summarised output below.

7
The null hypothesis of no Granger-causality is only rejected for the third case of GBP and JPY Granger-
causing EUR. However, as mentioned above, these results are always based on the joint assumption of
either two variables affecting one or one affecting two others.
To obtain the impulse responses for the estimated model, we use the function irf with input var
and set the argument n.ahead to 20 to obtain a response for 20 steps ahead.
ir = irf ( var , n . ahead = 2 0 )
plot ( ir )

Executing the above commands will produce the three plots in Figure 17.

Figure 17: Graphs of Impulse Response Functions (IRFs) for the VAR(1) Model

As one would expect given the parameter estimates, only a few linkages between the series are established
here. The responses to the shocks are very small, except for the response of a variable to its own shock,
and they die down to almost nothing after the first lag.
To have a look at the forecast error variance decomposition, we can use the function fevd, with the
same input, so we type
vd = fevd ( var , n . ahead = 2 0 )
plot ( vd )

and receive the plot displayed in in Figure 18.

8
Figure 18: Graphs of FEVDs for the VAR(1) Model

There is again little that can be seen from these variance decomposition graphs apart from the fact that
the behaviour is observed to settle down to a steady state very quickly. To illustrate how to interpret
the FEVDs, let us have a look at the effect that a shock to the euro rate has on the other two rates
and itself, which are shown in the first row of the FEVD plot. Interestingly, while the percentage of
the errors that is attributable to own shocks is 100% in the case of the euro rate (top graph), for the
pound, the euro series explains around 43% of the variation in returns (middle graph), and for the yen,
the euro series explains around 7% of the variation.
We should remember that the ordering of the variables has an effect on the impulse responses and
variance decompositions and when, as in this case, theory does not suggest an obvious ordering of the
series, some sensitivity analysis should be undertaken. Let us assume we would like to test how sensitive
the FEVDs are to a different way of ordering.

9
var_reverse = VAR ( currencies [ c ( " rjpy " ," rgbp " ," reur " ) ] , p = 1 )
vd_reverse = fevd ( var_reverse , n . ahead = 2 0 )
plot ( vd_reverse )

The above code is analogous to the steps we undertook before, with the small difference of arranging
the vector of currencies in the reverse order ‘rjpy’, ‘rgbp’ and ‘reur’. The output is presented in
Figure 19. We can now compare the FEVDs of the reverse order with those of the previous ordering
(Figure 18).

Figure 19: Graphs for FEVDs with Reverse Ordering

10

You might also like