Commit 2758dee5 authored by Thomas Brand's avatar Thomas Brand

Add fig and tab.

parent 55b631e7
......@@ -65,7 +65,7 @@ itrqnew <-
tauwh=last(itrq$tauwh))
itrqupdate <- bind_rows(itrq,itrqnew)
df <- rdb(ids = "OECD/EO/OTO.WPBRENT.Q",api_base_url = "https://api.next.nomics.world/series?")
df <- rdb(ids = "OECD/EO/OTO.WPBRENT.Q")
oil_prices <-
df %>%
select(period, value) %>%
......@@ -79,6 +79,8 @@ networth <-
filter(period<="2018-04-01",
period >= "1995-01-01")
tauls_df <- read_csv("tauls.csv")
FR_data <-
FR_rawdata %>%
transmute(period=period,
......@@ -92,7 +94,6 @@ FR_data <-
networth_rpc=networth$value/defgdp,
re=shortrate$value/100,
creditspread=lendingrate/100-re,
#pubexp_rpc=100*1e+6*(totexp-intpay)/(defgdp*pop),
pubcons_rpc=100*1e+6*pubcons/(defgdp*pop),
pubinves_rpc=100*1e+6*pubinves/(defgdp*pop),
tfs_rpc=100*1e+6*tfs/(defgdp*pop),
......@@ -101,7 +102,8 @@ FR_data <-
gdp_rpc=1e+6*gdp/pop,
world_demand,
oil_prices=oil_prices$value) %>%
left_join(itrqupdate)
left_join(itrqupdate) %>%
left_join(tauls_df)
```
```{r}
......@@ -113,6 +115,7 @@ FR_data2017 <-
write_csv(FR_data2017,"dataFR.csv")
```
```{r}
dataFR <- FR_data
hypo <-
......@@ -171,7 +174,7 @@ for (var in vars){
```
```{r}
vars <- c(quo(pubcons_rpc),quo(tfs_rpc),quo(pubinves_rpc),quo(othgov_rpc))
vars <- c(quo(pubcons_rpc),quo(tfs_rpc),quo(pubinves_rpc),quo(othgov_rpc),quo(tauls))
finaltib1bis <- tibble()
for (var in vars){
......@@ -266,7 +269,7 @@ for (var in vars){
```
```{r}
vars <- c(quo(re))
vars <- c(quo(re),quo(tauc),quo(taun),quo(tauwf),quo(tauwh))
finaltib3 <- tibble()
for (var in vars){
......@@ -361,24 +364,12 @@ for (var in vars){
}
```
```{r}
itrq_forecast <-
tibble(period=seq(as.Date("2018-07-01"),
as.Date("2022-10-01"),
by = "quarter"),
tauc=last(itrq$tauc),
taun=last(itrq$taun),
tauwf=last(itrq$tauwf),
tauwh=last(itrq$tauwh)) %>%
gather(var,value,-period)
```
```{r}
dataFR_forecast <-
dataFR %>%
gather(var,value,-period) %>%
na.omit() %>%
bind_rows(finaltib1,finaltib1bis,finaltib2,finaltib3,finaltib4,itrq_forecast) %>%
bind_rows(finaltib1,finaltib1bis,finaltib2,finaltib3,finaltib4) %>%
spread(var,value) %>%
arrange(period)
......@@ -399,6 +390,5 @@ dataFR_forecast_plot <-
ggplot(dataFR_forecast_plot,aes(period,value))+
geom_line()+
facet_wrap(~var,scales = "free_y")
```
No preview for this file type
period,tauls
1995-04-01,0.265765420905782
1995-07-01,0.280274312578691
1995-10-01,0.292400031325431
1996-01-01,0.290764092847355
1996-04-01,0.289569682955046
1996-07-01,0.288080346434518
1996-10-01,0.290538101867435
1997-01-01,0.287302703301406
1997-04-01,0.291572083099746
1997-07-01,0.289502458768674
1997-10-01,0.298566096832013
1998-01-01,0.300817831289655
1998-04-01,0.302221656225587
1998-07-01,0.299289852442195
1998-10-01,0.303921195137952
1999-01-01,0.293380876214424
1999-04-01,0.281873377923989
1999-07-01,0.269117098469608
1999-10-01,0.264392622985225
2000-01-01,0.293339523594545
2000-04-01,0.293904044258294
2000-07-01,0.28324502778588
2000-10-01,0.249023746423666
2001-01-01,0.348457412725856
2001-04-01,0.285701696759403
2001-07-01,0.24164097775783
2001-10-01,0.309318027191933
2002-01-01,0.260553549342954
2002-04-01,0.273330339027939
2002-07-01,0.268424672639161
2002-10-01,0.215130979472147
2003-01-01,0.20664881036175
2003-04-01,0.138880831788731
2003-07-01,0.225589301623054
2003-10-01,0.255034937999202
2004-01-01,0.230723449438582
2004-04-01,0.230492261830234
2004-07-01,0.243574081198988
2004-10-01,0.231568309220886
2005-01-01,0.244352966567298
2005-04-01,0.275332622223539
2005-07-01,0.251167044950289
2005-10-01,0.198913684134589
2006-01-01,0.360907379483575
2006-04-01,0.319761338230913
2006-07-01,0.254857244552722
2006-10-01,0.340506770181038
2007-01-01,0.240116603392196
2007-04-01,0.264786999205122
2007-07-01,0.270038890880026
2007-10-01,0.346903855660041
2008-01-01,0.276252699389197
2008-04-01,0.261444298954339
2008-07-01,0.234043047235165
2008-10-01,0.151151021812751
2009-01-01,0.118696446248401
2009-04-01,-0.022869621577747
2009-07-01,0.143205584307762
2009-10-01,0.244290181713819
2010-01-01,0.274548856842644
2010-04-01,0.22264541738342
2010-07-01,0.350654426215665
2010-10-01,0.287319167863691
2011-01-01,0.302655933113761
2011-04-01,0.176181230001684
2011-07-01,0.275546768383736
2011-10-01,0.225615454708171
2012-01-01,0.199631865238927
2012-04-01,0.271057145162236
2012-07-01,0.289726615372661
2012-10-01,0.24641934470674
2013-01-01,0.267945631920408
2013-04-01,0.246879058741341
2013-07-01,0.247651044946238
2013-10-01,0.214840558263122
2014-01-01,0.277609582625646
2014-04-01,0.257273158915023
2014-07-01,0.23503093339283
2014-10-01,0.282626384927472
2015-01-01,0.238597568771935
2015-04-01,0.29816051067495
2015-07-01,0.231967437146136
2015-10-01,0.248938689110274
2016-01-01,0.268033254916475
2016-04-01,0.199286373602455
2016-07-01,0.242315540759792
2016-10-01,0.274671192408768
2017-01-01,0.236283588887024
2017-04-01,0.232646001517278
2017-07-01,0.265735610077941
2017-10-01,0.266450569849744
2018-01-01,0.264368847799559
......@@ -42,6 +42,7 @@ data_mean.name = [data_mean.name; 'TAUC_OBS'];
data_mean.name = [data_mean.name; 'TAUN_OBS'];
data_mean.name = [data_mean.name; 'TAUWF_OBS'];
data_mean.name = [data_mean.name; 'TAUWH_OBS'];
data_mean.name = [data_mean.name; 'TAULS'];
data_mean.values = dataFR{'[^(?!.*B_OBS|HOURS_OBS).*$]'}(range).mean(true)';
data_mean.values = [data_mean.values; dataFR{'B_OBS'}(range).mean(false)];
data_mean.values = [data_mean.values; dataFR{'HOURS_OBS'}(range).mean(false)];
......@@ -49,6 +50,7 @@ data_mean.values = [data_mean.values; dataFRlevels{'tauc'}(range).mean(false)];
data_mean.values = [data_mean.values; dataFRlevels{'taun'}(range).mean(false)];
data_mean.values = [data_mean.values; dataFRlevels{'tauwf'}(range).mean(false)];
data_mean.values = [data_mean.values; dataFRlevels{'tauwh'}(range).mean(false)];
data_mean.values = [data_mean.values; dataFRlevels{'tauls'}(range).mean(false)];
save('mean.mat', 'data_mean');
// Center the dataFR (with geometric mean for all variables except B_OBS and HOURS_OBS)
......@@ -61,6 +63,7 @@ dataFR{'TAUC_OBS'} = dataFRlevels{'tauc'};
dataFR{'TAUN_OBS'} = dataFRlevels{'taun'};
dataFR{'TAUWF_OBS'} = dataFRlevels{'tauwf'};
dataFR{'TAUWH_OBS'} = dataFRlevels{'tauwh'};
dataFR{'TAULS'} = dataFRlevels{'tauls'};
// Declare dataFR dseries as the sample for estimation
data(series=dataFR, first_obs=1995Q2, last_obs=2018Q1);
......@@ -35,8 +35,8 @@ end;
estimation(presample=12, lyapunov=doubling, mode_compute=0, mh_replic=0, kalman_algo=2, consider_only_observed,mode_file=mars_mode,plot_priors = 0,nograph);
rawdataset = struct(dataset_);
rawdatatime = struct(rawdataset.dates);
rawdataset = struct(dataFR);
rawdatatime = struct(dataFR.dates);
save rawdataset.mat rawdataset;
save rawdatatime.mat rawdatatime;
......@@ -45,24 +45,26 @@ dataForecast = dataFR(2018Q2:2022Q4);
//constrained_vars = {'CONSUMPTION_OBS'; 'B_OBS'; 'INFLATION_OBS'; 'GDP_OBS'; 'INVESTMENT_OBS'; 'POIL_OBS'; ...
// 'OTHGOV_OBS'; 'PINVEST_OBS'; 'GC_OBS'; 'GI_OBS'; 'RE_OBS'; 'TAUC_OBS'; 'TAUN_OBS'; 'TAUWF_OBS'; 'TAUWH_OBS'; 'T_OBS'; 'WAGE_OBS'; 'YWORLD_OBS'};
constrained_vars = {'TAUC_OBS'; 'TAUN_OBS'; 'TAUWF_OBS'; 'TAUWH_OBS'; 'YWORLD_OBS'; 'POIL_OBS'; 'RE_OBS'};
constrained_vars = {'OTHGOV_OBS'; 'GC_OBS'; 'GI_OBS'; 'T_OBS'; 'TAULS'; 'TAUC_OBS'; 'TAUN_OBS'; 'TAUWF_OBS'; 'TAUWH_OBS'; 'YWORLD_OBS'; 'POIL_OBS'; 'RE_OBS'};
//constrained_vars = {'TAUC_OBS'; 'TAUN_OBS'; 'TAUWF_OBS'; 'TAUWH_OBS'; 'YWORLD_OBS'; 'POIL_OBS'; 'RE_OBS'};
[~, constrained_vars_id] = ismember(constrained_vars, M_.endo_names);
dataForecast = dataForecast{constrained_vars{:}};
//conditional_forecast.controlled_varexo = {'OTHGOV_EXO'; 'T_EXO'; 'GC_EXO'; 'GI_EXO'; 'TAULS_EXO'; 'TAUC_EXO'; 'TAUN_EXO'; 'TAUWF_EXO'; 'TAUWH_EXO'; 'YW_EXO'; 'POIL_EXO'; 'R_EXO'};
verbatim;
conditional_forecast.replic = 20000;
conditional_forecast.replic = 10000;
conditional_forecast.parameter_set = 'posterior_mode';
conditional_forecast.conf_sig = .9;
conditional_forecast.controlled_varexo = {'TAUC_EXO'; 'TAUN_EXO'; 'TAUWF_EXO'; 'TAUWH_EXO'; 'YW_EXO'; 'POIL_EXO'; 'R_EXO'};
conditional_forecast.conf_sig = .6;
conditional_forecast.controlled_varexo = {'OTHGOV_EXO'; 'T_EXO'; 'GC_EXO'; 'GI_EXO'; 'TAULS_EXO'; 'TAUC_EXO'; 'TAUN_EXO'; 'TAUWF_EXO'; 'TAUWH_EXO'; 'YW_EXO'; 'POIL_EXO'; 'R_EXO'};
options_.conditional_forecast = conditional_forecast;
end;
imcforecast(dataForecast.data', constrained_vars_id, conditional_forecast);
plot_icforecast(constrained_vars, 40, options_);
%plot_icforecast(constrained_vars, 40, options_);
plot_icforecast({'GDP_OBS'}, 40, options_);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment