Bookmark and Share

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


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

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


From   "Schaffer, Mark E" <[email protected]>
To   <[email protected]>
Subject   st: RE: e(wexp) versus e(wexp): different routines return different things
Date   Sat, 27 Aug 2011 12:56:31 +0100

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.

--Mark

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Rodini, Mark
> Sent: 27 August 2011 02:50
> To: [email protected]
> Subject: st: e(wexp) versus e(wexp): different routines 
> return different things
> 
> Greetings,
> 
> 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.
> 
> Thanks much.
> 
> Mark
> 
> ----------------------------------------------
> Mark Rodini
> COMPASS LEXECON
> 1111 Broadway, Suite 1500
> Oakland, CA  94607
> 510-285-1258 (direct)
> 510-285-1240 (main)
> 510-285-1245 (fax)
> [email protected]
>  
> This e-mail and attachments may be confidential and protected 
> by legal privilege.  If you are not the intended recipient, 
> be aware that any disclosure, copying, distribution or use of 
> the e-mail or any attachment is prohibited.  If you have 
> received this e-mail in error, please notify us immediately 
> by replying to the sender, and then delete this copy and the 
> reply from your system.  Thank you for your cooperation.
> 
> 
> 
> *
> *   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/
> 


-- 
Heriot-Watt University is a Scottish charity
registered under charity number SC000278.


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


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