[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
James Muller <james.muller@internode.on.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: combinatorics |

Date |
Thu, 18 Aug 2005 09:23:17 +1000 |

For sure combinatorial functions can be written quite efficiently in Mata. I'll try a few different things and pick the best performance. Perhaps then other combinatorial-type Stata programs can be re-written to use the more efficient code that does nothing but provide the sets of combinations and permutations.

James

Nick Cox wrote:

In addition to other replies, there is a -selectvars- package on SSC:

----------------------- extract from help -selectvars- produces a list of all possible n-tuples from a list of

variable names. That is, given a list of k variable names, it produces the

empty list; all possible distinct singletons (each individual variable

name); all possible distinct pairs; and so forth. Tuples are bound in " ".

As -selectvars- is intended for programming, the list is not displayed, but

left behind as a saved result.

Note that there is no checking of a possible error with even modest k:

that a full list of (at most 2^k) tuples can not be accommodated in a

macro.

------------------------

Note that -selectvars- long predates Mata. I would be interested to know if it could be speeded up. Mata or not, I have always been queasy about programs like this because I feared that someone would engender a combinatorial explosion (a genuine term in the literature).

Nick n.j.cox@durham.ac.uk

* * 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/

**References**:**st: RE: combinatorics***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: outreg after non-standard estimatoin** - Next by Date:
**st: SAS like command?** - Previous by thread:
**st: RE: combinatorics** - Next by thread:
**st: svyset variables with public use files** - Index(es):

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