Is there a constraint on number of parameters to be solved in fminsearch run on a data matrix?

1 Ansicht (letzte 30 Tage)
Dear Matlab users,
I am new to Matlab and intend to maximize a customised log-likelihood function. In my early attempts to learn how to do this in Matlab, I decided to first experiment with the exponential distribution. Below is my file for the function to be maximized (admittedly, this may not be the most efficient coding for this problem, so suggestions are very welcome):
function like=expcovariate1_mle(x,xb);
theta=exp(xb(:,3:10)*x');
like = -sum(xb(:,1).*log(theta)-xb(:,2).*theta);
grad= -sum(xb(:,1)./theta-xb(:,2));
hess= -sum(-xb(:,1)./(theta.^2));
end
and here are my codes for executing the above:
clear all;
warning off all
format long
cd 'E:\research\'
xlsread('final_data.xls','Sheet1','A2:Y759');
c=ans(:,8);
t=ans(:,1);
data=ans(:,:);
def=data(:,17);
est=data(:,18);
lia=data(:,19);
nol=data(:,20);
pat=data(:,21);
lap=data(:,22);
nla=data(:,23);
xb=[c,t,ones(758,1),def,est,lia,nol,pat,lap,nla];
options = optimset('MaxFunEvals',5000);
x0=ones(1,8);
[x]=fminsearch(@(x) expcovariate1_mle(x,xb),x0,options);
Out of interest, I have been comparing how the above works when coded in other software (I use STATA and Limdep). What was quite puzzling for me was that when I have up to 6 columns in matrix xb (i.e. xb=[c,t,ones(758,1),def,est,lia,nol,pat] the Matlab codes above produce exactly the same results as STATA/Limdep. However, if my xb matrix contains one or two additional variables, i.e. as coded in the above ( i.e. xb=[c,t,ones(758,1),def,est,lia,nol,pat,lap,nla] ) then Matlab produces very different solved parameters from STATA/limdep. I am puzzled as to why this, as I have been experimenting with the above incrementally, i.e. start with 2 columns, three columns, etc in my matrix xb, but this only produces similar results to STATA/Limdep up to including 6 columns in xb.
Has anyone every experienced this problem before, or am I missing out something obvious from the use of the command fminsearch? I tried to code and use fminunc for the above problem, but this was yielding yet completely different results altogether.
I would very much appreciate any help/suggestions/guidance on this please.

Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by