-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_components.py
82 lines (67 loc) · 2.03 KB
/
test_components.py
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
import numpy as np
import time
from auxiliary.Model import Model
from auxiliary.Sample import Sample
from auxiliary.estimation_func import *
if __name__=='__main__':
seed = 10082021
np.random.seed(seed)
alpha = 0.5
delta = 0.05
deep_param = {
"beta" : 0.96,
"gamma": 0.05,
"rho" : 0.75,
"sigma" : 0.15
}
discretization_param = {
"size_shock_grid" : 11,
"range_shock_grid" : 2.575
}
approx_param = {
"max_iter" : 1000,
"precision" : 1e-5,
"size_capital_grid" : 101,
}
sim_param = {
"number_firms" : 3,
"number_simulations_per_firm" : 3,
"number_years_per_firm" : 10,
"burnin" : 200,
"seed" : 10082021,
}
visualization_param = {
"alpha grid bounds" : (0.35, 0.65),
"delta grid bounds" : (0.03,0.07),
"fixed alpha" : 0.5,
"fixed delta" : 0.05,
"parameter grid size" : 20
}
mom_param = {
"no_moments" : 3,
"no_param" : 2,
}
opt_param = {
"solver" : "bobyqa",
# "solver" : "dual_annealing",
"start_value" : np.array([alpha, delta]),
"bounds_optimizer": [[0.001,1], [0.001, 0.3]],
"bounds_optimizer_bobyqa" : (np.array([0,0]), np.array([1,0.3])),
"max_iter" : 1000,
"step_size" : np.finfo(float).eps**(1/3),
"noise_range" : 10**(-np.linspace(1,6,6)),
"noisy_function_opt" : False
}
model = Model(deep_param, discretization_param, approx_param)
sample = Sample(mom_param)
# model._solve_model(alpha, delta, approx_param)
# model.visualize_model_sol(alpha, delta, approx_param)
# model.visualize_mom_sensitivity(visualization_param, sim_param)
print(sample.sample_mom)
# est, sim_mom, res, se = get_estimation_results(sample, model, sim_param, opt_param)
# print(f'{est=}')
# print(f'{sim_mom=}')
# print(res)
# print(se)
run_noisy_estimation(sample, model, sim_param, opt_param)
print("Done!")