Reputation: 43
I am running an impulse response function in R, using the package vars.
My data has 3 variables, the inflation (Brazilian CPI, or IPCA), the exchange rate and the output gap.
My goal is to calculate the exchange rate pass-through (both the maximum impact and the lag), and I am following and academic recommendation to add the output gap (as the monthly industrial production with HP filter).
The pass-through I am interested in is exchange rate -> CPI. The output gap is of my interest only in the way it impacts this pass-through relation. So I wrote the code as:
model_irf <- vars::irf(model_var,
impulse = "Exchange Rate",
response = "CPI",
n.ahead = 12,
cumulative = TRUE)
This gives me the expected response of variable “CPI” t+12 to a unit change in variable “Exchange Rate”.
I imagine (from macroeconomic theory) the output gap impacts the magnitude of the pass through, so in periods of larger output gap companies have less space to increase prices; relation that is not visible in this model I wrote.
My question is: How is the output gap related to the IRF I calculated? (Or if the model is wrong and I should write it differently to test this assumption)
Thank you very much for your time!
Upvotes: 1
Views: 251
Reputation: 597
you do not need cumulative
here (by default it is False), but for modelling you need
runs = 1000, seed = 12345
to repeat sampling and calculate its statistical properties,ortho=TRUE
, previously decomposing VaR-covar matrix of residals of the model to capture interactions in covariance from out-of-diagonal elements of that matrix together with its variation (on main diagonal)example code can see here
# Download data
## quarterly, seasonally adjusted time series for West German fixed investment, disposable income, and consumption expenditures in billions of DM from 1960Q1 to 1982Q4.
#d <- read.table("http://www.jmulti.de/download/datasets/e1.dat", skip = 6, header = TRUE)
#write.table(d, file = "foo.csv", sep = ",", col.names = NA)
d<-read.table("foo.csv", header = TRUE, sep = ",", row.names = 1)
# Only use the first 76 observations so that there are 73 observations
# left for the estimated VAR(2) model after taking first differences.
data(d[1:76, ])
print(d)
# Convert to time series object
data <- ts(d, start = c(1960, 1), frequency = 4)
# Take logs and differences
data <- diff(log(data))
# Plot data
plot(data, main = "Dataset E1 from Lutkepohl (2007)")
# MODEL
# Load package
#install.packages("vars")
library(vars)
# Estimate model
model <- VAR(data, p = 2, type = "const")
# Calculate summary statistics
model_summary <- summary(model)
# Obtain variance-covariance matrix
model_summary$covres
# A common approach to identify the shocks of a VAR model is to use orthogonal impulse respones (OIR). The basic idea is to decompose the variance-covariance matrix
t(chol(model_summary$covres))
# In R the irf function of the vars package can be used to optain OIRs by setting the argument ortho = TRUE:
oir <- irf(model, impulse = "income", response = "cons",
n.ahead = 8, ortho = TRUE, runs = 1000, seed = 12345)
plot(oir)
My question is: How is the output gap related to the IRF I calculated?
example of interpretation can see here
Upvotes: 1