-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_default.jl
87 lines (73 loc) · 3.34 KB
/
run_default.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using DSGE, ModelConstructors, Distributed
using Nullables, DataFrames, OrderedCollections, Dates
#############################
# To use:
# Just run in the Julia REPL
# include("run_default.jl")
# Note that the estimation
# step will take 2-3 hours.
#############################
##############
# Model Setup
##############
# Instantiate the FRBNY DSGE model object
m = XGabaix()
# estimate as of 2015-Q3 using the default data vintage from 2007 Nov 27
m <= Setting(:date_presample_start, quartertodate("1982-Q1"),"Start date of pre-sample")
m <= Setting(:date_forecast_start, quartertodate("2007-Q3"))
# The following settings ensure that this script runs in
# a short amount of time. To properly estimate and
# forecast, we recommend either using the default settings
# (i.e. comment out the settings below) or
# changing the settings yourself.
m <= Setting(:n_mh_simulations, 10000)
m <= Setting(:n_mh_blocks, 125)
m <= Setting(:n_mh_burn, 31)
m <= Setting(:mh_cc, .5)
m <= Setting(:mh_thin, 1)
m <= Setting(:use_population_forecast, false) # Population forecast not available as data to turn off
#m <= Setting(:forecast_block_size, 5) # adjust block size to run on small number of estimations
#############
# Estimation
#############
# Reoptimize parameter vector, compute Hessian at mode, and full posterior
# parameter sampling.
#
# Note some columns will have missing data because not all our data
# is publicly available. By default, `load_data` will error
# if any of the columns in the loaded DataFrame is empty,
# but we turn this feature off by setting the keyword `check_empty_columns = false`.
# Warnings will be still thrown after calling load_data indicating which columns
# are empty. However, estimate will still run when data is missing.
@time begin
df = load_data(m, try_disk = false, check_empty_columns = false, summary_statistics = :none)
data = df_to_matrix(m, df)
estimate(m, data)
end
# produce LaTeX tables of parameter moments
moment_tables(m)
############
# Forecasts
############
# (1) forecast_one produces forecasts of the variables specified in output_vars
# and stores the forecasts in model units (log deviations from steady state).
# (2) compute_meansbands stores the forecast in a MeansBands type, defined in DSGE.jl,
# which transforms the forecast from model units to "human readable" units, i.e.
# the GDP forecast is transformed from annualized quarterly log per-capita growth rates
# to annualized quarterly aggregate percent change.
# The variables we want to forecast. In this case, all of the model observables
output_vars = [:histobs, :forecastobs]
# Modal forecast (point forecast)
forecast_one(m, :mode, :none, output_vars; check_empty_columns = false)
compute_meansbands(m, :mode, :none, output_vars; check_empty_columns = false)
# Full-distribution forecast (point forecast (mean) and uncertainty bands)
# Optionally add 10 processes to run the forecast in parallel (uncomment the 3 lines below).
# Alternatively, you can load the ClusterManagers package and add processes
# using one of the schedulers such as SGE or Slurm.
addprocs(10)
@everywhere using DSGE
m <= Setting(:use_parallel_workers, true)
forecast_one(m, :full, :none, output_vars; check_empty_columns = false)
compute_meansbands(m, :full, :none, output_vars; check_empty_columns = false)
# Comment out the line below if you did not run the forecast in parallel.
rmprocs(procs())