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]

RE: st: RE: outreg2 combined with xtivreg2


From   "Schaffer, Mark E" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: outreg2 combined with xtivreg2
Date   Thu, 29 Aug 2013 12:29:23 +0000

Giacomo,

Thanks for the example.  It looks like you are using the wrong syntax for -outreg2-.  The syntax of -outreg2- is

	outreg2 [varlist]

What you are inserting for [varlist] is the name of the saved first-stage estimation results, whereas I think this is supposed to refer to the variables you want in the table.

In any case, it's quite easy to get -outreg2- to do what you want it to do.

In the example, instead of

webuse abdata, clear
xtivreg2 n (ys = w k), first savefirst fe
outreg2 [_xtivreg2_ys] using prova2, replace

-restore- the results first:

webuse abdata, clear
xtivreg2 n (ys = w k), first savefirst fe
est restore _xtivreg2_ys
outreg2 using prova2, replace

Works for me, should work for you too.

--Mark

> -----Original Message-----
> From: Giacomo PALLARO [mailto:[email protected]]
> Sent: 29 August 2013 06:40
> To: [email protected]
> Subject: RE: st: RE: outreg2 combined with xtivreg2
> 
> Dear Mr. Schaffer,
> thank you for your reply and forgive me if I was not clear in my question.
> Continuing your example:
> 
> ivreg2 n (ys = w k), first savefirst
> 
> OLS estimation
> --------------
> ------------------------------------------------------------------------------
> ys | Coef. Std. Err. t P>|t| [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> w | .0069317 .0111403 0.62 0.534 -.0149286 .028792
> k | .0038175 .0019351 1.97 0.049 .0000203 .0076147
> _cons | 4.617914 .0351991 131.19 0.000 4.548844 4.686985
> ------------------------------------------------------------------------------
> 
> let's run now
> 
> outreg2 [_ivreg2_ys] using prova, replace
> 
> we get exactly the first stage results
> 
> (1)
> _ivreg2_ys
> VARIABLES	ys
> 
> w	0.00693
> (0.0111)
> k	0.00382**
> (0.00194)
> Constant	4.618***
> (0.0352)
> 
> Observations	1,031
> R-squared	0.004
> Standard errors in parentheses
> *** p<0.01, ** p<0.05, * p<0.1
> 
> 
> 
> My problem is not here, it is on the use of xtivreg2.
> 
> xtivreg2 n (ys = w k), first savefirst fe
> 
> ------------------------------------------------------------------------------
> ys | Coef. Std. Err. t P>|t| [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> w | -.106388 .0311445 -3.42 0.001 -.1675134 -.0452626
> k | .1702418 .0119891 14.20 0.000 .1467115 .1937722
> ------------------------------------------------------------------------------
> 
> 
> . outreg2 [_xtivreg2_ys] using prova2, replace
> variable _est__xtivreg2_ys not found
> r(111);
> 
> 
> This problem still remain even after est restore or est replay.
> Stata tells me to store results in _xtivreg2_ys, but outreg2 doesn't access to
> them since, as you noted, the _est_ variable is not generated.
> 
> How can I get, using outreg2 after xtivreg2, similar results with respect to those
> produced using ivreg2?
> 
> Thank you for your attention,
> Best regards
> Giacomo
> 
> Università degli Studi di Padova
> 
> 
> 
> 
> -----Original Message-----
> From: Schaffer, Mark E
> Sent: 27 August 2013 22:02
> To: '[email protected]'
> Subject: RE: outreg2 combined with xtivreg2
> 
> Giacomo,
> 
> I'm not sure exactly what the problem is.
> 
> I tried using the savefirst option with both ivreg2 and xtivreg2. In both cases,
> the first-stage regressions were saved and I could replay them or restore them.
> 
> For example, using the abdata set, after
> 
> webuse abdata, clear
> ivreg2 n (ys = w k), savefirst
> xtivreg2 n (ys = w k), savefirst fe
> 
> when I say
> 
> est dir
> 
> I get
> 
> -------------------------------------------------------------------------
> name | command depvar npar title
> -------------+----------------------------------------------------------
> -------------+-
> _ivreg2_ys | ivreg2 ys 3 First-stage regression: ys
> _xtivreg2_ys | xtivreg2 ys 2
> -------------------------------------------------------------------------
> 
> I can use est replay or est restore with either of these saved results. So I don't
> see what the problem is.
> 
> I do note the discrepancy in terms of variables in memory. As you note, the
> saved first-stage estimation with ivreg2 creates an esample() variable:
> 
> storage display value
> variable name type format label variable label
> -------------------------------------------------------------------------------------------------------
> -----
> _est__ivreg2_ys byte %8.0g esample() from estimates store
> 
> And savefirst with xtivreg2 does not create a corresponding variable.
> 
> I would need to check, but this is probably because xtivreg2 uses
> preserve/restore and newly created variables get lost when the original dataset
> is restore-d at the end.
> 
> But I don't see what this has to do with "exporting first stage results".
> 
> --Mark
> 
> > -----Original Message-----
> > From: [email protected] [mailto:owner-
> > [email protected]] On Behalf Of Giacomo PALLARO
> > Sent: 22 August 2013 14:52
> > To: [email protected]
> > Subject: st: outreg2 combined with xtivreg2
> >
> > Dear all,
> > I'm running on Stata 12 some IV regressions using xtivreg2 and I would
> > like to print the results using outreg2.
> > The help file of xtivreg2 sends you to the help section of ivreg2,
> > where you can
> > find:
> >
> > The savefirst option requests that the individual first-stage
> > regressions be saved for later access using the estimates command. If
> > saved, they can also be displayed using first or ffirst and the ivreg2
> > replay syntax. The regressions are saved with the prefix "_ivreg2_",
> > unless the user specifies an alternative prefix with the savefprefix(prefix)
> option.
> >
> > Using ivreg2 with first savefirst options, I noticed that Stata
> > generates a variable _est__ivreg2_varname. Then using the command "
> outreg2
> > [_ivreg2_*] " I'm able to export the first stage results correctly.
> > Unfortunately with xtivreg2 this doesn't occur. In particular no
> > _est__xtivreg2_varname is generated, despite I get (similarly to
> > ivreg2 case) this expression just before the first stage output of
> > xtivreg2
> >
> > Stored estimation results
> > --------------------------------------------------------------------------------
> > name | command depvar npar title
> > -------------------+--------------------------------------------------
> > -------------------+---------
> > _xtivreg2_~d | xtivreg2 L.notemplo~d 7
> > ----------------------------------------------------------------------
> > ----------
> >
> > Am I wrong somewhere? Is it possible to export first stage results of
> > xtivreg2 in this way? Are there other ways to do it using outreg2?
> >
> > Thank you all in advance,
> > Giacomo
> 
> 
> 
> -----
> Sunday Times Scottish University of the Year 2011-2013
> Top in the UK for student experience
> Fourth university in the UK and top in Scotland (National Student Survey 2012)
> 
> We invite research leaders and ambitious early career researchers to
> join us in leading and driving research in key inter-disciplinary themes.
> Please see www.hw.ac.uk/researchleaders for further information and how
> to apply.
> 
> Heriot-Watt University is a Scottish charity
> registered under charity number SC000278.


----- 
Sunday Times Scottish University of the Year 2011-2013
Top in the UK for student experience
Fourth university in the UK and top in Scotland (National Student Survey 2012)

We invite research leaders and ambitious early career researchers to 
join us in leading and driving research in key inter-disciplinary themes. 
Please see www.hw.ac.uk/researchleaders for further information and how
to apply.

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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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