Modules 3: a small neo-keynesian model - Open Economy

Scenario: g

ThreeME team

OFCE, NEO

22 septembre 2023

startyear <- params$startyear
endyear <- params$endyear
scenario_to_analyse <- params$scenario_to_analyse
project_name <- params$project_name
classification <- params$classification
template_default <- params$template_default
githubrepo <- params$githubrepo

## SHOULD BE DELETED WHEN OPTION DE SIMPLEPLOT ERMEETH CHANGES:
# scenario = scenario_to_analyse (and not scenario_name)
scenario_name <- scenario_to_analyse
# Load functions
source("src/functions.R")
data_full<-readRDS(file = file.path("data","output", paste0(project_name,".rds")))

1 Changes compared to close economy

Changes compared to close economy

Macroeconomic results (Open economy)

PLots « Neo-Keynesian » closure open (overleaf)

1.1 New equations for open economy

  • Production

\[\begin{equation} Y + M = CH + I + G + X \end{equation}\]

  • Average user price

\[\begin{equation} p . \left( Y + M \right) = py . Y + pm . M \end{equation}\]

  • Notional production price

\[\begin{equation} py^{n} . Y = c^{Y} . Y . \left( 1 + m^{up} + dm^{up} \right) \end{equation}\]

  • International trade

Imports

\[\begin{equation} M = \left( Y + M \right) . \varphi^{M} . \left( \frac{pm}{p} \right) ^ {\left( -\rho^{M} \right)} \end{equation}\]

Exports

\[\begin{equation} X = WD . \left( \frac{py}{pw} \right) ^ {\left( -\rho^{X} \right)} \end{equation}\]

Saving of the Rest of the World

\[\begin{equation} SAV^{ROW} = pm . M - py . X \end{equation}\]

2 Macroeconomic results (Open economy)

Changes compared to close economy

Macroeconomic results (Open economy)

PLots « Neo-Keynesian » closure open (overleaf)

2.1 Considered shocks

  • Shock of 1% GDP point on G (public spending)
  • Shock of 1% GDP point on wd (world demand)

2.2 Contributions to GDP (Import and Export separately)

2.3 Contributions to GDP (with trade balance)

2.4 GDP and its components

2.5 Ratio between exports and imports

2.6 Production, capital and investment

variable_macro <- c( "K","K_N","I")
label_macro <- c("Capital",  "Notional Capital", "Investment")

A <- simpleplot(data_full,variable_macro, label_macro, startyear, endyear,  transformation = "reldiff", titleplot = " GDP, Capital and Investment (in relative difference from baseline) " )

B <- simpleplot(data_full,variable_macro, label_macro, startyear, endyear,  transformation = "gr", titleplot = " GDP, Capital and Investment (in growth rate)",
           unit = "percent", decimal = 0.1 )

macro <- ggarrange(A,B,
labels = c("(a)", "(b)"),
hjust = -0.5, vjust = 1.5,
ncol = 2, nrow = 1,
widths = 2,  heights = 1)

## Save image on disk for further use (ready to be activated)
# ggsave("macro.svg", device = svg, width = 32,  height = 16, units = c("cm"))

## See the graph in Mark-down
macro

2.7 Labor and Unemployment

variable_macro <- c( "L","L_N")
label_macro <- c("Labor",  "Notional labor")

A <- simpleplot(data_full,variable_macro, label_macro, startyear, endyear,  transformation = "reldiff", titleplot = " Effective and notional labor (in relative difference from baseline)" )

B <- simpleplot(data_full,"U", "Unemployment rate", startyear, endyear,  transformation = "level", titleplot = " Unemployment rate (in level)",
           unit = "percent", decimal = 0.1 )

macro <- ggarrange(A,B,
labels = c("(a)", "(b)"),
hjust = -0.5, vjust = 1.5,
ncol = 2, nrow = 1,
widths = 2,  heights = 1)

## Save image on disk for further use (ready to be activated)
# ggsave("macro.svg", device = svg, width = 32,  height = 16, units = c("cm"))

## See the graph in Mark-down
macro

2.8 Prices and wages

A <- simpleplot(data_full,c("P", "W"), c("Price", "Wages"), startyear, endyear, "reldiff", titleplot = " Prices and wages (in relative difference from baseline)")

B <- simpleplot(data_full,c("P", "W"), c("Price", "Wages"), startyear, endyear,  transformation = "gr", decimal= 0.1, unit="percent",  titleplot =  "  Prices and wages (in growth rates)" )

ggarrange(A,B,
labels = c("(a)", "(b)"),
hjust = -0.5, vjust = 1.5,
ncol = 2, nrow = 1,
widths = 2,  heights = 1)

2.9 Mark-up

A <- simpleplot(data_full,c("M_UP"), c("Mark-up"), startyear, endyear, "level", titleplot = " Mark-up (in level)")

B <- simpleplot(data_full,c("M_UP"), c("Mark-up"), startyear, endyear, "diff", unit = "percent", decimal = 0.1,  titleplot = " Mark-up (in difference from baseline)")

ggarrange(A,B,
labels = c("(a)", "(b)"),
hjust = -0.5, vjust = 1.5,
ncol = 2, nrow = 1,
widths = 2,  heights = 1)

2.10 Interest rate

A <- simpleplot(data_full,c("R"), c("Interest rate"), startyear, endyear, "level", titleplot = " Interest rate (Level) ")

B <- simpleplot(data_full,c("R"), c("Interest rate"), startyear, endyear, "diff", titleplot = " Interest rate (in difference from baseline)")

ggarrange(A,B,
labels = c("(a)", "(b)"),
hjust = -0.5, vjust = 1.5,
ncol = 2, nrow = 1,
widths = 2,  heights = 1)

2.11 Propensity to save

A <- simpleplot(data_full,c("SIGMA"), c("Propensity to save"), startyear, endyear, "level", unit = "percent", decimal = 0.1,  titleplot = " Propensity to save (in level)")

B <- simpleplot(data_full,c("SIGMA"), c("Propensity to save"), startyear, endyear, "diff", titleplot = " Propensity to save (in difference from baseline)")

ggarrange(A,B,
labels = c("(a)", "(b)"),
hjust = -0.5, vjust = 1.5,
ncol = 2, nrow = 1,
widths = 2,  heights = 1)

2.12 Debt to GDP ratio

variables_selection <- c("Y", "DEBT_G", "P")
new_indicators <- data_full%>%
wide_data(variables = variables_selection, out_format = "list")%>%
map(~.x %>% mutate (Ratio_debt_gdp = DEBT_G/(P*Y)))%>%
long_data(sector_names_table = NULL, commodity_names_table = NULL)%>%
select(-sector,-commodity)

A <- simpleplot (new_indicators, c("Ratio_debt_gdp"), c("DEBT_G/(P*Y)"), startyear, endyear,"level", unit = "percent", decimal = 0.1, titleplot = "Debt to GDP ratio (in level)")


B <- simpleplot(new_indicators, c("Ratio_debt_gdp"), c("DEBT_G/(P*Y)"), startyear, endyear, "diff", titleplot = "Debt to GDP ratio (in difference from baseline)")

macro <- ggarrange(A, B,
labels= c("(a)", "(b)"), 
hjust = -0.5, vjust = 1.5,
ncol= 2, nrow=1, 
widths =2 , heights = 2)

macro

2.13 Mains impacts of a shock on G

  • The third model (Open economy):

    • Same effects in a close economy with an increase of exports contribution to GDP
    • Positive effect on GDP on the long run
knit_exit()

3 PLots « Neo-Keynesian » closure open (overleaf)

Changes compared to close economy

Macroeconomic results (Open economy)

PLots « Neo-Keynesian » closure open (overleaf)

3.1 Contribution to GDP open economy (overleaf)

variables_selection = c("Y","X", "M", "I", "CH","G")
new_indicators <- data_full %>% 
  # 1. Put in Wide format
  wide_data(variables = variables_selection , out_format = "list") %>%  ## 1. passe en wide
  # 2. Calculate indicators
  map(~.x %>%          
        mutate(
          BAL_TRADE = X - M)) %>% long_data(sector_names_table=NULL,commodity_names_table=NULL) %>% select(-sector,-commodity)

contrib_comp <- c( "I", "CH", "G", "BAL_TRADE")
contrib_comp_label <- c( "Investment", "Households consumption", "Public spending", "Trade balance")

data_plot <-  contrib(new_indicators,"Y", contrib_comp, scenar = c("baseline",scenario_to_analyse))

Contrib_GDP_NeoKey_op <- contrib.plot(data_plot, series = contrib_comp,label_series = contrib_comp_label,
             startyear = startyear, line_tot = TRUE, custom_x_breaks = 5) + theme(axis.text.y = element_text(size = 28)) +
theme(axis.text.x = element_text(size = 28)) +
theme(text = element_text(size = 28)) +
theme(legend.text= element_text(size = 28))

## Save image on disk for further use (ready to be activated)
ggsave("Contrib_GDP_NeoKey_op.png",width = 48,  height = 28, units = c("cm"))


## See the graph in Mark-down
Contrib_GDP_NeoKey_op