Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
daniel klein <klein.daniel.81@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: e(wexp) versus e(wexp): different routines return different things |

Date |
Sat, 27 Aug 2011 09:41:38 +0200 |

Mark, following your approach you might code loc wts = subinstr("`e(wexp)'", "=", "", .) if "`e(wexp)'" != "" { collapse (mean) `y_sample' `xb_sample' [fw = `wts'] } Since <wts> holds a string you cannot use a -scalar- here (this is Stata not Mata). Another way to do it would be to add an -if- statement like in if "`e(wexp)'" != "" { if strmatch("`e(wexp)'", "*=*") collapse (mean) `y_sample' `xb_sample' [fw `e(wexp)'] else collapse (mean) `y_sample' `xb_sample' [fw = `e(wexp)'] } No need for regular expression here. However I see another problem with your program. Note that runnig reg y high low cows [aw=mycount] with your code above will, in most cases, still not work. Here is why. You are using <mycount> as analytic weights in the -regress- command and try to use them as frequency weights in your code (which seems weird anyway, be sure you really want to do that). Frequency weighs however cannot be noninteger while analytic weights, as well as sampling weights, contain nonintegers most of the time and we typically use the latter two with estimation commands. Note that e.g. -newey2- (which is a user written program from SSS, plase see http://www.stata.com/support/faqs/res/statalist.html#stata) does not even allow frequency weights. Best Daniel --- Mark wrote Greetings, I have a program which executes after I run an estimation procedure, and it does a collapse where weighting is an option. [...] Here is the kicker: reg returns e(wexp) as "= mycount", but newey2 returns e(wexp) as "mycount" (without the equals sign!) The reg version properly executes the program above, but newey2 gives an error about an inability to weight, since the syntax requires an equals sign. [...] * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: Testing the difference between coefficients with interaction variables** - Next by Date:
**Re: st: regexm** - Previous by thread:
**Re: st: e(wexp) versus e(wexp): different routines return different things** - Next by thread:
**st: Identify a Panel Structure with Incoherent ID and NAME Variable** - Index(es):