From: Raj on
Dear Matlab folks,

I am using the Stats toolbox logistic regression function "mnrfit".
(This is in v6.2 of the Stats toolbox, R2008a).

Using the profiler, I am finding that line 441 in nominalFit takes up
99% of the CPU time:
XWX = XWX + W(kron1,kron1) .* (xstar(1,kron2)'*xstar(1,kron2));

A couple of lines above that, the Matlab function contains a commented-
out
alternative version of the line, with the note "Do these computations
but more efficiently"
% Do these computations, but more efficiently
% XWX = XWX + kron(W(1:k-1,1:k-1), xstar'*xstar);

The ordinalFit subfunction similarly has a line which takes up most of
the CPU time,
line 324, with again a commented-out note giving a more efficient
version.

These XWX update lines certainly seem to be eating up more CPU than
necessary.
I don't have enough knowledge of how the algorithm is implemented
to be able to tell whether the commented-out "more efficient" versions
do exactly the same thing, whether they actually work more
efficiently,
or whether their gain in efficiency might come from relying on some
kind of
assumption which could potentially fail to hold and thereby introduce
a nasty bug.

Any suggestions greatly appreciated.
It would certainly be nice to have this code run faster,
and it appears to already contain more efficient alternative lines,
except that they were put in but then commented out.

Many thanks,

Raj
From: Raj on
On Jul 14, 9:25 am, Peter Perkins
<Peter.Perk...(a)MathRemoveThisWorks.com> wrote:
> On 7/13/2010 5:54 PM, Raj wrote:
>
> > It would certainly be nice to have this code run faster,
> > and it appears to already contain more efficient alternative lines,
> > except that they were put in but then commented out.
>
> Raj, you have it the wrong way around.  The commented out code is in
> there simply to make the lines that actually execute easier to follow.

Dear Peter,

Many thanks for the clarification.

Raj