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: SUREG with if command.


From   "Schaffer, Mark E" <[email protected]>
To   <[email protected]>
Subject   RE: st: SUREG with if command.
Date   Tue, 25 Sep 2012 17:44:21 +0100

Nick,

I think David is right, and in this case -sureg- is not doing the best
it can.

Here's an example with the toy auto dataset.  There are 69 obs for rep78
and 74 obs for everything else.  In the following example,

. sureg (mpg rep78) (trunk turn)

Seemingly unrelated regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"       chi2        P
----------------------------------------------------------------------
mpg                69      1    5.333491    0.1613      15.86   0.0001
trunk              69      1     3.48627    0.3462      26.22   0.0000
----------------------------------------------------------------------

-sureg- could be using all 74 observations for the trunk equation, but
it's using only 69.

It's even clearer with -reg3- (IIRC, -sureg- is implemented using
-reg3-).  If you use -reg3- with the ols option,

. reg3 (mpg rep78) (trunk turn), ols

Multivariate regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"     F-Stat        P
----------------------------------------------------------------------
mpg                69      1     5.41057    0.1619      12.94   0.0005
trunk              69      1    3.497684    0.3610      37.84   0.0000
----------------------------------------------------------------------

-reg3- again uses only 69 obs for the trunk equation even though there
are 74 available and it's being asked to do OLS only.

--Mark

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Nick Cox
> Sent: 25 September 2012 17:32
> To: [email protected]
> Subject: Re: st: SUREG with if command.
> 
> -sureg- will always do the best it can, and there is no extra trickery
except by
> imputing missing values.
> 
> For clarity, don't think or write in terms of missing observations.
> It's values that are missing, not observations. Remember, for Stata an
> observation is a complete row, record, or case in other terminology.
> 
> Nick
> 
> On Tue, Sep 25, 2012 at 5:21 PM, David Ashcraft
> <[email protected]> wrote:
> > Thanks Nick, by saving number of observations, I meant e.g. for rp1,
I have
> 120 observations so I want -sureg- to utilize 120 observations not 60
> observations.  Is there a way, I could utilize all non-missing
observations for
> each equation in -sureg- model?
> >
> > edit rp? if dummy==1: two variable rp8 and rp9 have all observations
as
> missing. I dropped these two equations from the model for dummy==1. I
> have got some results and these are inline with my expectations. I
also have
> checked for observation where dummy==0 and have found several
instances
> of missing observations.
> > Regards
> >
> > David
> >
> > ----- Original Message -----
> > From: Nick Cox <[email protected]>
> > To: [email protected]
> > Cc:
> > Sent: Tuesday, September 25, 2012 6:34:03 PM
> > Subject: Re: st: SUREG with if command.
> >
> > I've never used -sureg-. It seems to me that it uses or knows
nothing
> > about panel structure, so I surmise that it is indifferent to
> > unbalanced panels as such. But it seems that you do have missing
> > values in different observations and will have problems because
> > -sureg- can only function with non-missing values on all variables
> > named.
> >
> > Look at
> >
> > edit rp? if dummy == 1
> >
> > I don't know what you mean by "save the number of observation[s]".
> >
> > Nick
> >
> > On Tue, Sep 25, 2012 at 4:21 PM, David Ashcraft
> > <[email protected]> wrote:
> >> Hello Nick,
> >>
> >> I think problem is not with the dummy variable. This may be related
-
> sureg- model. It seems to me -sureg- needs a balanced panel resulting
in
> drop of number of observations considerably while implementing
-sureg-.
> >>
> >> Is there any other way where I can save the number of observation
and
> still use seemingly unrelated regression model?
> >>
> >> Below is some descriptive stats for your review.
> >>
> >>
> >> gen dummy=0
> >> . replace dummy = 1 if date2>17532
> >>
> >> (53 real changes made)
> >> . tabulate dummy
> >>
> >>
> >>
> >>       dummy |      Freq.     Percent        Cum.
> >> ------------+-----------------------------------
> >>           0 |         96       64.43       64.43
> >>           1 |         53       35.57      100.00
> >> ------------+-----------------------------------
> >>       Total |        149      100.00
> >>
> >> . su rp1 rp2 rp3 rp4 rp6 rp7 rp8 rp9
> >>
> >>     Variable |       Obs        Mean    Std. Dev.       Min
Max
> >>
-------------+-------------------------------------------------------
> >> -------------+-
> >>          rp1 |       120     .001517    .0469446  -.1935012
.1102614
> >>          rp2 |       120    .0008538    .0545707   -.212302
.1238899
> >>          rp3 |       120    .0016796    .0565703  -.2283529
.1202257
> >>          rp4 |       120    .0016847    .0588602  -.2037239
.1229283
> >>          rp6 |       120    .0015542     .056026  -.2226954
.1190248
> >>
-------------+-------------------------------------------------------
> >> -------------+-
> >>          rp7 |       120    .0016078    .0503465  -.2033414
.1073936
> >>          rp8 |        88    .0023456    .0709356  -.2216449
.1371796
> >>          rp9 |        88    .0033193    .0779086  -.2401649
.1579783
> >>
> >>
> >>
> >>
> >>
> >> ----- Original Message -----
> >> From: Nick Cox <[email protected]>
> >> To: [email protected]
> >> Cc:
> >> Sent: Tuesday, September 25, 2012 2:54:44 PM
> >> Subject: Re: st: SUREG with if command.
> >>
> >> Your results show 60 observations with non-missing values; dummy is
0
> >> on 60 of them (all) and so necessarily 1 on 0 (none) of them.
Stata's
> >> response is reasonable; there are _no_ observations to do your last
> >> command.
> >>
> >> You should perhaps revisit your definition of -dummy-, which
doesn't
> >> divide the dataset.
> >>
> >> Nick
> >>
> >> On Tue, Sep 25, 2012 at 12:42 PM, David Ashcraft
> >> <[email protected]> wrote:
> >>> Hi Statalist,
> >>>
> >>> I am trying to run -sureg- with multiple equation as per below.
Now I
> have divided my data based on dummy variable and I want to see if the
> results are any different based on the dummy variable. Based on my
data, I
> should get three different results i.e. one for the whole sample and
two
> based on the dummy variable. I am getting the same result for the
overall
> sample and where dummy==0 and getting no result for dummy==1.
> >>>
> >>> I don't understand why I am getting this result. Can anyone help
me
> direct to the solution of this problem. I have looked at some older
posts but
> there is no answer.
> >>> Regards
> >>>
> >>> David
> >>>
> >>>
> >>>
> >>> sureg (rp1 rm1)(rp2 rm2)(rp3 rm3)(rp4 rm4)(rp6 rm6)(rp7 rm7)(rp8
> >>> rm8)(rp9 rm9), corr
> >>>
> >>> Seemingly unrelated regression
> >>>
----------------------------------------------------------------------
> >>> Equation          Obs  Parms        RMSE    "R-sq"       chi2
P
> >>>
----------------------------------------------------------------------
> >>> rp1                60      1    .0071761    0.9616    3298.70
0.0000
> >>> rp2                60      1    .0092113    0.9465    2534.55
0.0000
> >>> rp3                60      1    .0082266    0.9544    2847.07
0.0000
> >>> rp4                60      1    .0091633    0.9491    2198.62
0.0000
> >>> rp6                60      1    .0084368    0.9515    2677.13
0.0000
> >>> rp7                60      1    .0060539    0.9711    3703.34
0.0000
> >>> rp8                60      1     .009352    0.9866    5504.52
0.0000
> >>> rp9                60      1    .0115533    0.9832    4137.04
0.0000
> >>>
--------------------------------------------------------------------
> >>> --
> >>>
> >>>
------------------------------------------------------------------------
------
> >>>              |      Coef.   Std. Err.      z    P>|z|     [95%
Conf. Interval]
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp1          |
> >>>          rm1 |   .9992066   .0173974    57.43   0.000     .9651084
1.033305
> >>>        _cons |  -.0000674   .0009287    -0.07   0.942    -.0018876
.0017527
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp2          |
> >>>          rm2 |   .9733916   .0193347    50.34   0.000     .9354963
1.011287
> >>>        _cons |  -.0013549    .001196    -1.13   0.257     -.003699
.0009892
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp3          |
> >>>          rm3 |   .9942406   .0186334    53.36   0.000     .9577198
1.030761
> >>>        _cons |  -.0008887   .0010727    -0.83   0.407    -.0029911
.0012136
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp4          |
> >>>          rm4 |   .9618481   .0205131    46.89   0.000     .9216431
1.002053
> >>>        _cons |   .0010966   .0011632     0.94   0.346    -.0011832
.0033765
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp6          |
> >>>          rm6 |   .9920405   .0191732    51.74   0.000     .9544617
1.029619
> >>>        _cons |  -.0008398    .001099    -0.76   0.445    -.0029937
.0013142
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp7          |
> >>>          rm7 |   .9873097    .016224    60.86   0.000     .9555113
1.019108
> >>>        _cons |   .0001045   .0007886     0.13   0.895    -.0014411
.0016502
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp8          |
> >>>          rm8 |   .9554066   .0128774    74.19   0.000     .9301673
.9806458
> >>>        _cons |   .0009302   .0012033     0.77   0.439    -.0014282
.0032887
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp9          |
> >>>          rm9 |   .9889603   .0153757    64.32   0.000     .9588245
1.019096
> >>>        _cons |  -.0001408   .0014852    -0.09   0.924    -.0030518
.0027703
> >>>
--------------------------------------------------------------------
> >>> ----------
> >>>
> >>> Correlation matrix of residuals:
> >>>
> >>>          rp1      rp2      rp3      rp4      rp6      rp7      rp8
rp9
> >>> rp1   1.0000
> >>> rp2   0.1214   1.0000
> >>> rp3   0.2210   0.9609   1.0000
> >>> rp4   0.4345  -0.0342   0.0495   1.0000
> >>> rp6   0.2268   0.9595   0.9982   0.0447   1.0000
> >>> rp7   0.9088   0.2710   0.3749   0.7114   0.3763   1.0000
> >>> rp8   0.2240   0.0839   0.0896  -0.0739   0.0987   0.1232   1.0000
> >>> rp9   0.2100   0.1163   0.1462  -0.0321   0.1497   0.1600   0.7653
1.0000
> >>>
> >>> Breusch-Pagan test of independence: chi2(28) =   338.778, Pr =
0.0000
> >>>
> >>> . sureg (rp1 rm1)(rp2 rm2)(rp3 rm3)(rp4 rm4)(rp6 rm6)(rp7 rm7)(rp8
> >>> rm8)(rp9 rm9)if dummy==0, corr
> >>>
> >>> Seemingly unrelated regression
> >>>
----------------------------------------------------------------------
> >>> Equation          Obs  Parms        RMSE    "R-sq"       chi2
P
> >>>
----------------------------------------------------------------------
> >>> rp1                60      1    .0071761    0.9616    3298.70
0.0000
> >>> rp2                60      1    .0092113    0.9465    2534.55
0.0000
> >>> rp3                60      1    .0082266    0.9544    2847.07
0.0000
> >>> rp4                60      1    .0091633    0.9491    2198.62
0.0000
> >>> rp6                60      1    .0084368    0.9515    2677.13
0.0000
> >>> rp7                60      1    .0060539    0.9711    3703.34
0.0000
> >>> rp8                60      1     .009352    0.9866    5504.52
0.0000
> >>> rp9                60      1    .0115533    0.9832    4137.04
0.0000
> >>>
--------------------------------------------------------------------
> >>> --
> >>>
> >>>
------------------------------------------------------------------------
------
> >>>              |      Coef.   Std. Err.      z    P>|z|     [95%
Conf. Interval]
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp1          |
> >>>          rm1 |   .9992066   .0173974    57.43   0.000     .9651084
1.033305
> >>>        _cons |  -.0000674   .0009287    -0.07   0.942    -.0018876
.0017527
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp2          |
> >>>          rm2 |   .9733916   .0193347    50.34   0.000     .9354963
1.011287
> >>>        _cons |  -.0013549    .001196    -1.13   0.257     -.003699
.0009892
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp3          |
> >>>          rm3 |   .9942406   .0186334    53.36   0.000     .9577198
1.030761
> >>>        _cons |  -.0008887   .0010727    -0.83   0.407    -.0029911
.0012136
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp4          |
> >>>          rm4 |   .9618481   .0205131    46.89   0.000     .9216431
1.002053
> >>>        _cons |   .0010966   .0011632     0.94   0.346    -.0011832
.0033765
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp6          |
> >>>          rm6 |   .9920405   .0191732    51.74   0.000     .9544617
1.029619
> >>>        _cons |  -.0008398    .001099    -0.76   0.445    -.0029937
.0013142
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp7          |
> >>>          rm7 |   .9873097    .016224    60.86   0.000     .9555113
1.019108
> >>>        _cons |   .0001045   .0007886     0.13   0.895    -.0014411
.0016502
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp8          |
> >>>          rm8 |   .9554066   .0128774    74.19   0.000     .9301673
.9806458
> >>>        _cons |   .0009302   .0012033     0.77   0.439    -.0014282
.0032887
> >>>
-------------+------------------------------------------------------
> >>> -------------+----------
> >>> rp9          |
> >>>          rm9 |   .9889603   .0153757    64.32   0.000     .9588245
1.019096
> >>>        _cons |  -.0001408   .0014852    -0.09   0.924    -.0030518
.0027703
> >>>
--------------------------------------------------------------------
> >>> ----------
> >>>
> >>> Correlation matrix of residuals:
> >>>
> >>>          rp1      rp2      rp3      rp4      rp6      rp7      rp8
rp9
> >>> rp1   1.0000
> >>> rp2   0.1214   1.0000
> >>> rp3   0.2210   0.9609   1.0000
> >>> rp4   0.4345  -0.0342   0.0495   1.0000
> >>> rp6   0.2268   0.9595   0.9982   0.0447   1.0000
> >>> rp7   0.9088   0.2710   0.3749   0.7114   0.3763   1.0000
> >>> rp8   0.2240   0.0839   0.0896  -0.0739   0.0987   0.1232   1.0000
> >>> rp9   0.2100   0.1163   0.1462  -0.0321   0.1497   0.1600   0.7653
1.0000
> >>>
> >>> Breusch-Pagan test of independence: chi2(28) =   338.778, Pr =
0.0000
> >>>
> >>> . sureg (rp1 rm1)(rp2 rm2)(rp3 rm3)(rp4 rm4)(rp6 rm6)(rp7 rm7)(rp8
> >>> rm8)(rp9 rm9)if dummy==1, corr insufficient observations r(2001);
> >
> > *
> > *   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/


-- 
Heriot-Watt University is the Sunday Times
Scottish University of the Year 2011-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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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