Using Optimization Toolbox to Estimate Population Parameters
Ältere Kommentare anzeigen
I'm working on an economics research paper on labor supply. I'd like to uncover the population parameters for 'alpha' - the disutility of work. To avoid getting into the background, this problem can be simplified down to the following equation:
Y* = max(utility(w,Y,X,k))
= max(w*Y - X*Y^(1-k)/(1-k))
where w and k are constants, Y is a vector of possible values for labor, Y* is the value of labor that maximizes utility, and X is alpha, a variable that is log-normally distributed for the population.
I have real data for Y*, Y, w, and k from which I'd eventually like to derive the true parameters of alpha, but first I'd like to feed MATLAB fake data to ensure that the optimization routine is working.
I wrote the following function to find the square difference between the Y* generated from guessed X paramenters and the true Y*.
if true
% code
function[difference] = min_dif(x,k,fake_labor_data,numsims)
%%SETUP
% Separate out individual paramaters:
mu = x(1);
sigma = x(2);
%
%%DRAW ALPHAS FOR SAMPLE
alpha_draws = lognrnd(mu,sigma,[numsims,1]);
alpha_draws = repmat(alpha_draws,1,31);
%
%%UTILITY
% Replicate task matrix for all simulations
L = 0:1:30;
L = repmat(L,numsims,1);
% Calculate each person's utility for each of the possible tasks:
utility = 7 * L - alpha_draws .* L .^ (1+k) / (1+k);
% Find the task with the maximum utility for each person:
[~,index] = max(utility,[],2);
labor_supplied = index - 1;
%
%%DISTRIBUTION OF LABOR
[a,~] = hist(labor_supplied,unique(labor_supplied));
dist_labor = a' ./ numsims ;
%
%%SQUARED DIFFERENCE
cdf_sim = cumsum(dist_labor)';
cdf_act = cumsum(fake_labor_data,2);
% Calculate Difference
diff = sum(((cdf_sim - cdf_act).^2),2);
difference = diff;
end
end
I then use fmincon to minimize the difference and return the estimated X parameters:
if true
% code
tic
[param_estimates,func,exitflag] = fmincon( @(x) ...
min_dif(x,k,fake_labor_data,numsims),options);
toc
end
But it's not working. The solver barely moves at all, and has never returned the correct parameters. What can I do?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Problem-Based Optimization Setup finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!