Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: any way to speed up mkmat (or is there an alternative)?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: any way to speed up mkmat (or is there an alternative)?
Date   Sun, 6 Feb 2005 17:29:39 -0000

(0) -mkmat- is interpreted code. 

For each call to -mkmat- there is a 

(1) -preserve- of your data 

and a 

(2) double loop over your variables and your 
observations filling in the matrix element by 
element 

To avoid the problem (0) you might write 
an alternative to -mkmat- as C code and make 
it a plug-in. 

To minimise the problem (1) you could check
to see that you are not working with a 
relatively small subset of a relatively
large dataset, because otherwise the
-preserve- will be relatively expensive. 

It is difficult for me to see how (2) 
can be avoided. It would be speeded up 
by a plug-in. 

On the whole, not using -mkmat- but 
building in your own matrix creation 
code is probably the best way to go. 
You could of course borrow ideas 
from -mkmat-. 

Nick 
[email protected] 

Elizabeth Bruch

> I'm writing a program that computes diagnostics (residuals, 
> leverages, and 
> cook's distance) for the clogit model. The program is 
> working, but.. it's 
> *really* slow. I've isolated the source of the slowness to 
> the "mkmat" 
> commands (for each observation in the data I construct 3 
> matrices, and each 
> matrix takes about 5 seconds to create). I should add that 
> the matrices I 
> construct for each observation are small (two are 1x17 and 
> the third is 6x6).
> 
> Is there any faster alternative to mkmat? Why is this command 
> so slow? Is 
> there any way I can speed it up?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index