Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: RE: e(wexp) versus e(wexp): different routines return different things

From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: RE: e(wexp) versus e(wexp): different routines return different things
Date   Sat, 27 Aug 2011 13:46:02 +0100

Alternatively, this seems to stem from one line in -newey2- (SSC).

est local wexp `"`exp'"'

Clone the program under a new name and fix the line by inserting "=" to taste.

Much ado about not much!


On Sat, Aug 27, 2011 at 12:56 PM, Schaffer, Mark E
<[email protected]> wrote:

> You could use -ivreg2-; there's an "=" in e(wexp) it saves.  You'll need to fiddle with the small, rob and bw options to reproduce the -newey2- results, though.

Rodini, Mark

>> I have a program which executes after I run an estimation
>> procedure, and it does a collapse where weighting is an option.
>> Within the program is the following line:
>> if "`e(wexp)'" != "" {
>>                       collapse (mean) `y_sample' `xb_sample'
>> [fw `e(wexp)']
>>               }
>> I'm running an estimation using "reg" and one using "newey2".
>>  Suppose the name of the weighting variable, should I opt to
>> use it, is "mycount" so for example, I run:
>> reg y high low cows [aw=mycount]
>> and then execute the program.
>> Both estimation routines create as output an estimation
>> "variable" called e(wexp).  Note that this is what is passed
>> to the program as indicated above.
>> 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.
>> I have tried within the program to create a tempname or
>> tempvar, assign e(wexp) to it and then tried running
>> scalar `wts'=regexr(`e(wexp)',"=","")
>> I then replace the `e(wexp)' in the program with `wts' and
>> add an equals sign explicitly in the program.  The idea I was
>> hoping for is that it would replace the "=" with nothing in
>> the macro variable, if one were there.
>> No matter how I try it, it fails, usually with a type
>> mismatch error.  I tried adding double quotes, etc.  I am
>> assuming that because I'm trying to pass it as a scalar, that
>> is what bombs it.  Any thoughts?  I'm guessing it's something
>> pretty basic --I'm kind of new to writing complicated
>> programs which pass lots of stuff.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index