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]
Re: st: outreg2 not giving wide format in MP 11.2
From
Farasat Bokhari <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: outreg2 not giving wide format in MP 11.2
Date
Thu, 11 Aug 2011 16:45:37 -0700 (PDT)
John,
Thanks much for the info. Will try working with outreg (use to use it long time ago). Just tried your code and got an error msg. saying `option keep() not allowed'. I updated to sg97_3 but still did not work. will look around and see if I can find the correct update with the keep option.
Thanks,fb
----- Original Message -----
From: John Luke Gallup <[email protected]>
To: [email protected]
Cc:
Sent: Friday, August 12, 2011 12:23 AM
Subject: Re: st: outreg2 not giving wide format in MP 11.2
Farasat,
The fact that the logit and probit results do not merge as you expect in -outreg2- is due to a change in the way Stata reports the results of these estimations in the e(b) matrix. For some reason, although the models are univariate and there are no auxiliary statistics in e(b), Stata added the independent variables as equation names in version 10. Since you use different independent variables (at least in name) in the two estimations, -outreg2- thinks the coefficients are different.
In -outreg- (_not_ -outreg2-) which I am more familiar with since I wrote it, you can get around this by lopping off the equation names using the -keep- option:
sysuse auto, clear
clonevar for2 = foreign
logit foreign mpg turn price headr, or robust
outreg, keep(foreign:) or replace
logit for2 mpg turn price, or robust
outreg using a, keep(for2:) or merge
Two differences from your example:
- you need the -or- option to get odds ratios in the -outreg- table
- this saves to a Word document, not an Excel table
In -outreg-, this would have worked without the -keep- option if the independent variables had had the same name in both estimations:
sysuse auto, clear
clonevar for2 = foreign
g i = 1
logit foreign mpg turn price headr if i == 1, or robust
outreg, or replace
logit foreign mpg turn price if i == 1, or robust
outreg using a, or merge
John
On Aug 11, 2011, at 3:37 PM, Farasat Bokhari wrote:
> Eric.
>
>
> i tried using reg with outreg2 and everything works fine but not for logit or probit (not even with the sideway option). i dont think it was ment to work this way. up until version 10.1 it was working fine. in fact, in version 10.1, i was also able to generate descriptive stats and output them using outreg2 (see the code below) as well as use it after probits.
>
>
>
> will send an email to the author and see if he is willing to update the code for MP11.2.
>
> thanks, fb
>
>
> code for outreg2 after sum command:
>
>
>> #delimit;
>> mean assistance rewards sanctions lawsum clindex hrindex djindex gender age black othr
>> ace hispanic
>> if sample1 == 1 & pubsch == 1 [pw=weight] , over(adhd) cluster(state);
>>
>> #delimit;
>> outreg2 using descriptivestatsver07.xls, excel long replace noaster auto(3) bdec(3) ;
>>
>> #delimit;
>> mean assistance rewards sanctions lawsum clindex hrindex djindex gender age black othr
>> ace hispanic
>> if sample3 == 1 & pubsch==1 [pw=weight], over(medsadhd) cluster(state);
>>
>>
>> #delimit;
>> outreg2 using descriptivestatsver07.xls, long excel append noaster auto(3) bdec(3);
>>
>
>
>
>> /*********** Probit 1.1 : Pr(ADHD) = f(assistance) **************************/
>> #delimit;
>> probit adhd assistance
>> age gender black othrace hispanic family2 family3 family4
>> poverty1-poverty7 edu1 edu2
>> pctpop5t19 lnsped lnlunch pupiltchratio
>> lnschip2 lnmcaidpop lnschippop
>> if sample1 == 1 & pubsch == 1 [pw=weight], cluster(state);
>>
>> outreg2 using estimate-pradhd-prmeds-nschlaws2003-ver07.xls,
>> excel append symbol($^a$,$^b$,$^c$) auto(2);
>>
>>
>> /*********** Probit 1.1 : Pr(ADHD) = f(rewards) *****************************/
>> #delimit;
>> probit adhd rewards
>> age gender black othrace hispanic family2 family3 family4
>> poverty1-poverty7 edu1 edu2
>> pctpop5t19 lnsped lnlunch pupiltchratio
>> lnschip2 lnmcaidpop lnschippop
>> if sample1 == 1 & pubsch == 1 [pw=weight], cluster(state);
>> outreg2 using estimate-pradhd-prmeds-nschlaws2003-ver07.xls,
>> excel append symbol($^a$,$^b$,$^c$) auto(2);
>
>
> ****************************************************************************************************************************************************************
>
>
>
> ----- Original Message -----
> From: Eric Booth <[email protected]>
> To: "<[email protected]>" <[email protected]>
> Cc:
> Sent: Thursday, August 11, 2011 9:35 PM
> Subject: Re: st: outreg2 not giving wide format in MP 11.2
>
> <>
>
> It appears to be an issue with the way multiple logit estimation results are handled by -outreg2- (from SSC by the way) . When I run your example with -regress- it works in the way you expect , ex:
>
> ************
> sysuse auto, clear
> clonevar for2 = foreign
> g i = 1
> #delimit;
> logit foreign
> mpg turn price headr
> if i == 1, or robust ;
> outreg2 using a.xls, replace excel;
>
> logit for2
> mpg turn price
> if i == 1, or robust ;
> outreg2 using a.xls, append excel sortvar(turn price mpg ) see ;
> **try adding the 'sideway' option to see the difference
> #delimit cr
>
> #delimit;
> reg foreign
> mpg turn price headr
> if i == 1 ;
> outreg2 using a.xls, replace excel;
>
>
> #delimit;
> reg for2
> mpg turn price
> if i == 1 ;
> outreg2 using a.xls, append excel sortvar(turn price mpg ) see ;
> #delimit cr
> ************
> If this is intentional then I missed it in the help file -- if not, it might be worth emailing the author (Roy Wada) and seeing if he is willing to change this behavior . If you add the option 'sideway' to the logit -outreg2-, the coefficients line up (but the SE are no longer under the coeff).
>
> Other options include (1) re-insheeting the .xls tables you made, manipulating the tables (shifting the cells upward to align the coeff. across the rows), and re-exporting them; (2) using other table production programs like -estout- or -outreg- from SSC (3) writing your own program to do what you want.
>
> - Eric
> On Aug 11, 2011, at 8:33 AM, Farasat Bokhari wrote:
>
>> I am using outreg2 after a logit command on multiple dependent variables. No matter what I do, the columns from multiple regressions are not next to each other. I have even tried forcing it by using the "wide" option (which is the default anyway) but the output file does not contain columns next to each other but rather vertically stacked. The prob. has started showing up in my stata 11.2 MP (was not there in state 10). Any suggestions on how to proceed?
>>
>> Thanks.
>>
>> example of code used:
>>
>>
>>
>> #delimit;
>> logit y1
>> x1 x2 x3 x4
>> if useobs == 1, or robust ;
>> #delimit;
>> outreg using a.xls, replace excel wide;
>>
>>
>> #delimit;
>> logit y2
>> x1 x2 x3
>> if useobs == 1, or robust ;
>> #delimit;
>> outreg using a.xls, append excel wide;
>>
>> *
>> * 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/
>
>
> *
> * 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/
>
>
> *
> * 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/
>
*
* 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/
*
* 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/