-
Notifications
You must be signed in to change notification settings - Fork 6
/
gen_moments.m
30 lines (21 loc) · 1.19 KB
/
gen_moments.m
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
function moments = gen_moments(mhat, rec_low_price,err_var,Nsubs,sample,nmoments,boot)
% This code computes the moments from simmulated trade flow and price data
moments = zeros(Nsubs,nmoments);
Ngoods = length(rec_low_price);
rng(072279+boot)
for sub_runs = 1:Nsubs
% Add disturbances to the trade shares, the err_var is the st.dev
% to the error term in the gravity regression
%m = trade_add_error(mhat, err_var,007+sub_runs+boot);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draw the number of goods that we want
keep = randi(Ngoods,sample,1);
final_price_tilde = (rec_low_price(keep,:))';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute the new estimate of theta given this, add to old because we
% want the sum.
% moments(sub_runs,:) = thetaest_est_mod_exact(final_price_tilde, m);
moments(sub_runs,:) = thetaest_est_mod_exact(final_price_tilde, mhat);
% using the .mex provides alot of speed up. I will include the
% regular file as well.
end