Professional Documents
Culture Documents
All 'Mt19937ar' 'Seed'
All 'Mt19937ar' 'Seed'
stream1 = RandStream('mt19937ar','Seed',3454671);
RandStream.setGlobalStream(stream1);
X = importdata('ATT.dat');
R=X(:,4);
N=length(R);
mu_mom = mean(R);
sigma_mom =var(R);
se_mu=sigma_mom/N;
mom=[mu_mom sigma_mom];
A=eye(4);
theta_gmm = fminsearch(@(z) gmmtheta(z,R,A),mom);
display(theta_gmm);
theta = zeros(1000,2);
for i=1:1000
useme=randsample(1:N,N,1);
data=R(useme);
theta(i,:)=fminsearch(@(z) gmmtheta(z,data,A),mom);
end
V = cov(theta);
SE = [V(1,1)^.5 V(2,2)^.5];
display('Standard Errors of estimates in fraction data');
display(SE);
R1=X(:,4)*100;
N=length(R1);
mu_mom1 = mean(R1);
sigma_mom1 =var(R1);
se_mu1=sigma_mom1/N;
mom1=[mu_mom1 sigma_mom1];
A=eye(4);
theta_gmm1 = fminsearch(@(z) gmmtheta(z,R1,A),mom1);
display(theta_gmm1);
theta1 = zeros(100,2);
for i=1:100
usemea=randsample(1:N,N,1);
data=R1(usemea);
theta1(i,:)=fminsearch(@(z) gmmtheta(z,data,A),mom1);
end
Vf = cov(theta1);
SEf = [Vf(1,1)^.5 Vf(2,2)^.5];
est=zeros(100,4);
for j=1:100
usemeb=randsample(1:N,N,1);
data=R(usemeb);
[drop est(j,:)]=gmmtheta(theta_gmm,data,A);
end
W_starf = inv(cov(est));
theta_gmm_optf = fminsearch(@(z) gmmtheta(z,R,W_starf),mom);
display('Estimates in fraction with optimal weighting matrix');
display(theta_gmm_optf);
est1=zeros(100,4);
for j=1:100
usemeb=randsample(1:N,N,1);
data=R1(usemeb);
[drop est1(j,:)]=gmmtheta(theta_gmm,data,A);
end
W_starp = inv(cov(est1));
theta_gmm_optp = fminsearch(@(z) gmmtheta(z,R1,W_starp),mom1);
display('Estimates in percent with optimal weighting matrix');
display(theta_gmm_optp);
theta_op = zeros(100,2);
for i=1:100
usemea=randsample(1:N,N,1);
data=R1(usemea);
theta_op(i,:)=fminsearch(@(z) gmmtheta(z,data,W_starp),mom1);
end
SEO=cov(theta_op);
display('Standard Errors of Optimal Estimator');
display(SEO);
theta_gmm =
1.0e-03 *
0.646633702531645
0.353948023210452
1.0e-04 *
0.161727669868224
0.069601355201851
theta_gmm1 =
0.453829620835656
15.865882480990512
5.019505180848497
0.276620458065776
2.694598980936541
0.000287800882949
0.023245014712629