2

I am attempting to derive the impulse response function(IRF) on the spillover effect of the US interest rate on Australia and Turkey's output and unemployment rate. Below are the codes I used:

library(readxl)
library(forecast)#timeseries
library(tidyverse)#plots
library(ggplot2)#plot
library(tseries)#adf
library(vars)
library(lmtest)
library(pracma)
library(stats)

And the data:

data<-structure(list(Date = c("Q1 2001", "Q2 2001", "Q3 2001", "Q4 2001", 
                        "Q1 2002", "Q2 2002", "Q3 2002", "Q4 2002", "Q1 2003", "Q2 2003", 
                        "Q3 2003", "Q4 2003", "Q1 2004", "Q2 2004", "Q3 2004", "Q4 2004", 
                        "Q1 2005", "Q2 2005", "Q3 2005", "Q4 2005"), Australia.output = c(1.87, 
                                                                                          1.75, 2.71, 4.33, 4.04, 4.97, 4.04, 3.64, 3.06, 1.75, 3.2, 4.04, 
                                                                                          4.65, 4.91, 3.91, 3.01, 2.98, 2.76, 3.12, 3.13), Australia.employment = c(6.9, 
                                                                                                                                                                    3.6, 2.3, -2.9, -7, -3.9, -3, -1.1, -0.2, -1.1, -2.9, -1.4, -1.5, 
                                                                                                                                                                    -0.8, 0.1, 0.3, 1.6, 3.6, 5.4, 6.2), USA.output = c(2.2, 0.99, 
                                                                                                                                                                                                                        0.49, 0.17, 1.33, 1.32, 2.14, 1.99, 1.68, 1.96, 3.24, 4.3, 4.35, 
                                                                                                                                                                                                                        4.23, 3.49, 3.36, 3.91, 3.61, 3.45, 2.98), USA.employment = c(0.5, 
                                                                                                                                                                                                                                                                                      0.5, 0.9, 0.8, 0.9, 0.1, -0.5, -0.7, -1.1, -1.3, -1.4, -2.1, 
                                                                                                                                                                                                                                                                                      -1.6, -1.7, -1.2, -0.4, -0.5, 0.2, 0.2, 0.7), Turkey.output = c(1.47, 
                                                                                                                                                                                                                                                                                                                                                      -7.06, -7.28, -10.13, -1.7, 7.77, 7.89, 12.08, 8.09, 3.96, 5.49, 
                                                                                                                                                                                                                                                                                                                                                      6.41, 9.25, 11.41, 9.55, 8.06, 10.01, 7.96, 8.26, 10.06), Turkey.employment = c(3.6, 
                                                                                                                                                                                                                                                                                                                                                                                                                                      4.6, 7.1, 4.1, -3.8, -5.3, -8.4, -5.7, -2, -4.3, -4, -3.1, -3.2, 
                                                                                                                                                                                                                                                                                                                                                                                                                                      2.2, 1.6, 0.1, -0.2, -1.9, -1.2, 4.6), USA.rate = c(-1.22, -2.97, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          -3.76, -5.23, -3.59, -2.42, -1.3, 0.11, -0.03, 0.11, -0.54, -0.42, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          -0.27, -0.04, 0.82, 1.51, 2.02, 2.09, 2.12, 1.97)), class = "data.frame", row.names = c(NA, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  -20L))


Australia.output<-ts(data$Australia.output,start=c(2001,1), end=c(2005,4),frequency = 4)
Australia.employment<-ts(data$Australia.employment,start=c(2001,1), end=c(2005,4),frequency = 4)
USA.output<-ts(data$USA.output,start=c(2001,1), end=c(2005,4),frequency = 4)
USA.employment<-ts(data$USA.employment,start=c(2001,1), end=c(2005,4),frequency = 4)
USA.rate<-ts(data$USA.rate,start=c(2001,1), end=c(2005,4),frequency = 4)
Turkey.output<-ts(data$Turkey.output,start=c(2001,1), end=c(2005,4),frequency = 4)
Turkey.employment<-ts(data$Turkey.employment,start=c(2001,1), end=c(2005,4),frequency = 4)

Australia<-cbind(USA.rate,Australia.output, Australia.employment)

Australia1<- VARselect(Australia, lag.max = 4, type = "const") 
Australia1$select

Australia2<-VAR(Australia,p=4,type="const", season=NULL, exogen = NULL)
summary(Australia2)

irf1<-irf(Australia2, impulse="USA.rate",response="USA.rate", cumulative=TRUE, n.ahead = 20, boot = TRUE,ci=0.95)
plot(irf1, ylab = "", main = "")

irf2<-irf(Australia2, impulse="USA.rate",response="Australia.output", cumulative=TRUE, n.ahead = 20, boot = TRUE,ci=0.95)
plot(irf2, ylab = "", main = "")

irf3<-irf(Australia2, impulse="USA.rate",response="Australia.employment", cumulative=TRUE, n.ahead = 20, boot = TRUE,ci=0.95)
plot(irf3, ylab = "", main = "")


I did the same for Turkey.

But I observed that the IRF of the USA rate on the USA rate when I worked in Australia was different from that of Turkey. Hence I am unable to describe the response of Australia and Turkey's output as a result of a USA rate shock at the same time. 

Is this the right way to use my dataset? and is my approach correct? Or do I have to use my dataset in this form?

dataoption<-structure(list(Date = c("Q1 2001", "Q2 2001", "Q3 2001", "Q4 2001", 
"Q1 2002", "Q2 2002", "Q3 2002", "Q4 2002", "Q1 2003", "Q2 2003", 
"Q3 2003", "Q4 2003", "Q1 2004", "Q2 2004", "Q3 2004", "Q4 2004", 
"Q1 2005", "Q2 2005", "Q3 2005", "Q4 2005", "Q1 2001", "Q2 2001", 
"Q3 2001", "Q4 2001", "Q1 2002", "Q2 2002", "Q3 2002", "Q4 2002", 
"Q1 2003", "Q2 2003", "Q3 2003", "Q4 2003", "Q1 2004", "Q2 2004", 
"Q3 2004", "Q4 2004", "Q1 2005", "Q2 2005", "Q3 2005", "Q4 2005", 
"Q1 2001", "Q2 2001", "Q3 2001", "Q4 2001", "Q1 2002", "Q2 2002", 
"Q3 2002", "Q4 2002", "Q1 2003", "Q2 2003", "Q3 2003", "Q4 2003", 
"Q1 2004", "Q2 2004", "Q3 2004", "Q4 2004", "Q1 2005", "Q2 2005", 
"Q3 2005", "Q4 2005"), ID = c("Australia", "Australia", "Australia", 
"Australia", "Australia", "Australia", "Australia", "Australia", 
"Australia", "Australia", "Australia", "Australia", "Australia", 
"Australia", "Australia", "Australia", "Australia", "Australia", 
"Australia", "Australia", "USA", "USA", "USA", "USA", "USA", 
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", 
"USA", "USA", "USA", "USA", "USA", "USA", "Turkey", "Turkey", 
"Turkey", "Turkey", "Turkey", "Turkey", "Turkey", "Turkey", "Turkey", 
"Turkey", "Turkey", "Turkey", "Turkey", "Turkey", "Turkey", "Turkey", 
"Turkey", "Turkey", "Turkey", "Turkey"), output = c(1.87, 1.75, 
2.71, 4.33, 4.04, 4.97, 4.04, 3.64, 3.06, 1.75, 3.2, 4.04, 4.65, 
4.91, 3.91, 3.01, 2.98, 2.76, 3.12, 3.13, 2.2, 0.99, 0.49, 0.17, 
1.33, 1.32, 2.14, 1.99, 1.68, 1.96, 3.24, 4.3, 4.35, 4.23, 3.49, 
3.36, 3.91, 3.61, 3.45, 2.98, 1.47, -7.06, -7.28, -10.13, -1.7, 
7.77, 7.89, 12.08, 8.09, 3.96, 5.49, 6.41, 9.25, 11.41, 9.55, 
8.06, 10.01, 7.96, 8.26, 10.06), employment = c(6.9, 3.6, 2.3, 
-2.9, -7, -3.9, -3, -1.1, -0.2, -1.1, -2.9, -1.4, -1.5, -0.8, 
0.1, 0.3, 1.6, 3.6, 5.4, 6.2, 0.5, 0.5, 0.9, 0.8, 0.9, 0.1, -0.5, 
-0.7, -1.1, -1.3, -1.4, -2.1, -1.6, -1.7, -1.2, -0.4, -0.5, 0.2, 
0.2, 0.7, 3.6, 4.6, 7.1, 4.1, -3.8, -5.3, -8.4, -5.7, -2, -4.3, 
-4, -3.1, -3.2, 2.2, 1.6, 0.1, -0.2, -1.9, -1.2, 4.6), rate = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, -1.22, -2.97, -3.76, -5.23, -3.59, -2.42, -1.3, 0.11, 
-0.03, 0.11, -0.54, -0.42, -0.27, -0.04, 0.82, 1.51, 2.02, 2.09, 
2.12, 1.97, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA)), class = "data.frame", row.names = c(NA, 
-60L))

If yes how do work with the N/A present in the data?

Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
Es003
  • 21
  • 3
  • For a better explanation make a [minimal reproducible example (MRE)](https://stackoverflow.com/a/5963610/11570343) of your data using `dput`. – cdcarrion Sep 25 '22 at 16:29
  • Greetings! Usually it is helpful to provide a minimally reproducible dataset for questions here. Your data as it stands is otherwise unusable for people here. One way of doing this is by using the `dput` function. You can find out how to use it here: https://youtu.be/3EID3P1oisg – Shawn Hemelstrand Sep 26 '22 at 00:29
  • Thank you very much. I have corrected it. Would you be able to work with it now? – Es003 Sep 26 '22 at 01:59
  • The data looks visible now but what is your question exactly? You just want to remove the NA values? – Shawn Hemelstrand Sep 26 '22 at 02:07
  • So I want to generate the Impulse response function of the effect of the USA rates on Australia's output and employment. As well as on Turkey's output and employment. and wasn't sure which of the two data arrangements I have to use. Also I wanted to confirm if working on the spillover effect of one country's interest rate on another country's output and employment should be done this way. – Es003 Sep 26 '22 at 02:46
  • Sorry I don't know what the impulse response function is. Perhaps somebody else can help with that. – Shawn Hemelstrand Sep 26 '22 at 02:49
  • Alright, Shawn. thank you very much. – Es003 Sep 26 '22 at 02:50

0 Answers0