anonymous-submission-acl2025's picture
add 16
b4ae6c9
raw
history blame
962 Bytes
function Z=moments(x, targs)
% If a second argument is passed, it contains that targeted values,and the
% sum of squared errors is returned (for the function minimizer that seeks
% the parameters that can match the targets). If there is no second
% argument, the function just calculates values for the four moments, which
% are available as global variables in the calling program.
global delta1 delta2 delta3 hirerate
pigood=x(1);
alpha=x(2);
lam=x(3);
M=1;
T=2000;
empg(1)=pigood;empb(1)=1-pigood;
for j=2:T
empg(j)=empg(j-1)*(1-lam);
empb(j)=empb(j-1)*(1-alpha)*(1-lam);
end
emp=empg+empb;
delta1=(13*emp(1)-sum(emp(2:14)))/(13*(M));
delta2=(sum(emp(2:14))-sum(emp(15:27)))/sum(emp(2:14));
delta3=(sum(emp(15:T))-sum(emp(28:T)))/sum(emp(15:T));
hirerate=13*emp(1)/(sum(emp)+12*(M));
if nargin==2
Z=(log(targs(1))-log(delta1))^2+...
(log(targs(2))-log(delta2))^2+...
(log(targs(3))-log(delta3))^2;
end