# Re: st: two stage model variance estimators

 From Robert Duval To statalist@hsphsun2.harvard.edu Subject Re: st: two stage model variance estimators Date Thu, 15 Sep 2005 17:41:13 -0400

```how many years do you have?

On 9/15/05, Rachel Bouvier <rbouvier@usm.maine.edu> wrote:
> >>> rduval@gmail.com 09/14/05 7:55 PM >>>
> it would actually help if you could sent your commands to the list so
> that we see what's going on,
> best
> robert
>
> Of course.  Thank you for your time.
>
> My first model is regressing the log of GDP on the year (ie, 1996) and
> the square of the year (ie, 3984016).  Originally, I ran this model
> separately for 30 countries.  I then obtained the predicted value of the
> log of GDP for each of those countries (by using -predict-) and used it
> in a second model.
>
> The suggestion was to interact year and year squared with each of the
> countries in the dataset so that I could put them all in one regression,
> using the country dummies and the -noconst- option.  Seems sensible, but
> when I tried it, Stata dropped all the country dummies.  Here was my
> code (I know there are more parsimonious ways to do this, but...):
>
> *All the countries are given an index from 1 to 30.*
> gen  mol  =1 if index== 1
> replace  mol  =0 if index~= 1
> gen  arm =1 if index== 2
> replace  arm =0 if index~= 2
>
> etc.  This generated dummies with 1 if the observation belonged to that
> country (Moldova is #1, for example).
>
> Then, I interacted the dummies with both year and year squared:
>
> gen yrmol=year*mol
> gen yr2mol=yearsq*mol
> gen yrarm=year*arm
> gen yr2arm=yearsq*arm
>
> etc.
>
> Finally, I ran a regression that looks like:
>
> regress lngdp yrmol yr2mol yrarm yr2arm ... mol arm ... , nocons
>
> where mol = Moldavia, arm = Armenia, and so on.
>
> When I run this, I get the following (truncated):
>
> lnpppc1 |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
> Interval]
> mol |  (dropped)
> arm |  (dropped)
> yrmol |   .2019759   1.003532     0.20   0.841    -1.772746
> 2.176698
> yr2mol |  -.0001006   .0005037    -0.20   0.842    -.0010917
> .0008904
> yrarm |    .149713   .4002733     0.37   0.709    -.6379338
> .9373598
> yr2arm |  -.0000744   .0002011    -0.37   0.712    -.0004702
> .0003214
>
> However, when I run the following:
>
> regress lngdp year yearsq if index ==1
>
> for example, I do get results.  That is what I did in order to get the
> predicted variables for the second stage.
>
> Anything jump out at you?  Again, thank you for your time and patience.
>  -Rachel
>
> >>> rduval@gmail.com 09/14/05 7:55 PM >>>
> it would actually help if you could sent your commands to the list so
> that we see what's going on,
> best
> robert
>
> On 9/14/05, Rachel Bouvier <rbouvier@usm.maine.edu> wrote:
> > Hi again.  I tried interacting my xs with country specific dummies
> and
> > running them in a single equation as suggested.  Stata is dropping
> the
> > country dummies, even though I specify the nocons option.  (I
> remember
> > now that this was why I had originally run it in 30 different
> equations
> > - it works fine that way,  but not if I put them all into one
> equation.)
> >  Am I doing something wrong?  It could be because xsq is the square
> of
> > x, but I don't understand why stata would let me do it for an
> individual
> > country but not together.  Sorry for being obtuse.  -Rachel
> >
> > >>> rduval@gmail.com 09/13/05 4:50 PM >>>
> > a possible solution could be to run in a single model  the equation
> >
> >  (1) y = b1 x + b2 xsq
> >
> > interacting your x's with country specific dummies.
> >
> > In other words, you could run a fully interactive model which is
> > equivalent to running 30 different regressions but in a single
> > equation. (make sure you include the country specific dummies too
> that
> > would account for the constant in your separate regressions and
> > specify the nocons option).
> >
> > hope this helps.
> > robert
> >
> >
> > On 9/13/05, Rachel Bouvier <rbouvier@usm.maine.edu> wrote:
> > > Dear statalisters *
> > >
> > > I am confronting a problem much like that described by James
> Hardin
> > in volume 2, issue 3 of the Stata Journal, "The robust variance
> > estimator for two-stage models," where he gave an illustration of
> Stata
> > code to construct the Murphy-Topel variance estimator.
> > >
> > > I am using a variable (call it yhat), predicted in a first (series
> > of) equations, as a regressor in my second equation.
> > >
> > > In other words, my first (series of) regressions looked like this:
> > > (1) y = b1 x + b2 xsq
> > >
> > > Then, I predicted yhat from that regression, and used that in a
> > second regression:
> > > (2) z = b1 yhat + b2 x2 + b2 x3*
> > >
> > > I say "series of" regressions because I have a panel of 30
> countries.
> >  Rather than run one panel data regression and predict each
> country's
> > yhat from that, I ran each country as a separate regression, not
> wanting
> > to assume that they could be pooled.  In other words, I ran equation
> (1)
> > 30 different times, for each country in the dataset.  (It seemed to
> make
> > sense at the time, to both me and my committee!)
> > >
> > > Therein lies my problem.  I would like to adjust the standard
> errors
> > for the fact that I predicted yhat, but as I ran a different
> regression
> > for each country, the solution is not as easy as constructing the
> > Murphy-Topel estimator.  Does anyone have any suggestions? Any help
> > would be much appreciated, before I dive into something that is
> > undoubtedly over my head.  Thanks.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```