[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Re: Maximizing likelihood functions - GSL vs. Matlab

From: AJ Bostian
Subject: [Help-gsl] Re: Maximizing likelihood functions - GSL vs. Matlab
Date: Wed, 02 Jun 2004 15:01:28 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.6) Gecko/20040510

OK, so I found the issue, but it baffles me. I have a space-delimited datafile, and the first line of it is

20 0 0.025 0 0.12

and I'm reading it in using an ifstream called "data":

data >> junk >> Y[0] >> X[0][0] >> X[0][1] >> X[0][2] >> X[0][3];

where junk, X[], and Y[][] are double. But Y[0]=1 (!!!) when I examine the data in the debugger. This is the only data element that this happens to, but it happens every time I load this file. Any thoughts?

After I fixed this, the results were much more comparable with the commercial results, usually to within 2 decimal places of precision. I'm now trying to figure out the remaining differential. I'm using the gsl_multimin minimizers.


AJ Bostian wrote:
I recently programmed up some probit and logit routines in GSL and in Matlab. (The Matlab machine is an i386 and the GSL machine is an x86_64, both running linux) I then compared the output from each of these to the output from some commercial statistical packages like SAS and Stata.

The output from the Matlab code matches up with the commercial output exactly -- the parameter estimates, maximizing value of the likelihood function, etc. are identical. However, the GSL output tends to show a slight improvement in the maximizing value of the likelihood function. The improvement is not large, say a 0.1% difference, but the parameter estimates are noticeably different (5-10%) due to the nonlinearity of the function.

Just to check, I plugged the GSL parameter estimates into the Matlab objective function. The value of the Matlab objective using the GSL parameter estimates is indeed very slightly worse.

I thought that this might be due to differences in precision, but Matlab/SAS/Stata all seem to do calculations in double, which is what I used. I also thought that the choice of GSL minimizer might make a difference, but the result holds under all GSL minimizers.

Obviously, I would like to think that the improvement in the maximizing value of the likelihood function using GSL is real, but it's hard to go up against Matlab/SAS/Stata. Anyone have any thoughts about why this difference might exist, and whether the improvement is legit?

AJ Bostian

PS: Can't beat GSL for speed, though. I blew through 20 iterations of a probit problem in about 0.25 sec using GSL, compared to about 3 sec for Matlab.

AJ Bostian
Dept. of Economics
University of Virginia
Rouss Hall 114
Charlottesville, VA  22904
Email: address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]