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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: re: programming new function |

Date |
Sat, 16 Apr 2005 21:29:38 -0400 |

Renzo replied to Jean-Benoit with

To the best of my knowledge, it is not possible to program a new function on

its own.

Of course, it is possible to modify any official command that StataCorp

writes as an ado file; but I think this "hacking" is risky and not

recommended. Of course, you could create a copy of the command (e.g. you

could make a copy of egen, call it egen2) and than modify the copy using

standard -syntax-. According to the difficulty of the command you are

modifying, this way could be quite difficult too.

Another way that might work on occasion is to write a new command

"wrap-around".

Partially right. Functions that appear in 'help functions' are those used by GENERATE, and the generate command cannot be extended by users to apply new functions. Those functions are coded in C, and are thus quite efficient. Functions that appear after the command EGEN (Extended GENerate) may be either provided by StataCorp or user-written; e.g. findit egenmore for a large library of such functions. You need NOT duplicate official egen.ado, since it is merely a wrapper for those functions. If you create a file _gzap.ado on the adopath, you will be able to use the 'zap' function with egen.

The downside of egen functions is that they are interpreted code, and if they are doing a lot of work they may be quite slow. That is presumably one of the disadvantages that Stata 9's 'mata' matrix programming language may be able to address.

Kit Baum, Boston College Economics

http://ideas.repec.org/e/pba1.html

*

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

**Follow-Ups**:**Re: st: re: programming new function***From:*Jean-Benoit Hardouin <jean-benoit.hardouin@orscentre.org>

**st: extracting diagonal elements from a matrix***From:*Kate Ivanova <kivanova@usc.edu>

- Prev by Date:
**RE: st: switching regression and endogenous variables in mlogit** - Next by Date:
**st: extracting diagonal elements from a matrix** - Previous by thread:
**st: t statistics instead of z statistics in a large sample ?.** - Next by thread:
**st: extracting diagonal elements from a matrix** - Index(es):

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