Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • List countries in estimated regression

    Hello,,
    I have a dataset with 98 countries. When I estimate the regression it only uses 92 countries. Can you help me with the command to have a list of the countries that were used in the estimated regression?
    Thank you in advance

  • #2
    If ‘country’ was properly coded, you just need to type something like - regress yvar i.country - for the matter. You see “i.” relates to factor notation. But if you have missing values, the regression will deal with listwise deletion.
    Last edited by Marcos Almeida; 12 May 2019, 11:31.
    Best regards,

    Marcos

    Comment


    • #3
      Stata estimation commands create the returned function e(sample) which is true (1) for observations that are included in the results and false (0) for observations not used in the regression. The example below uses this to list the observations excluded from the regression (only because that was a shorter list to copy and paste!).
      Code:
      . sysuse auto, clear
      (1978 Automobile Data)
      
      . describe, short
      
      Contains data from /Applications/Stata/ado/base/a/auto.dta
        obs:            74                          1978 Automobile Data
       vars:            12                          13 Apr 2016 17:45
       size:         3,182                          
      Sorted by: foreign
      
      . regress price length i.rep78
      
            Source |       SS           df       MS      Number of obs   =        69
      -------------+----------------------------------   F(5, 63)        =      3.76
             Model |   132668930         5  26533786.1   Prob > F        =    0.0048
          Residual |   444128029        63  7049651.25   R-squared       =    0.2300
      -------------+----------------------------------   Adj R-squared   =    0.1689
             Total |   576796959        68  8482308.22   Root MSE        =    2655.1
      
      ------------------------------------------------------------------------------
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            length |   65.02221   15.48443     4.20   0.000     34.07904    95.96537
                   |
             rep78 |
                2  |   728.5196   2105.194     0.35   0.730    -3478.374    4935.414
                3  |   1539.622   1940.569     0.79   0.431    -2338.295     5417.54
                4  |   1777.926   1980.059     0.90   0.373    -2178.907    5734.759
                5  |     2572.1   2061.701     1.25   0.217    -1547.881     6692.08
                   |
             _cons |  -7724.697   3477.005    -2.22   0.030    -14672.94   -776.4562
      ------------------------------------------------------------------------------
      
      . list make price length rep78 if !e(sample)
      
           +-----------------------------------------+
           | make             price   length   rep78 |
           |-----------------------------------------|
        3. | AMC Spirit       3,799      168       . |
        7. | Buick Opel       4,453      170       . |
       45. | Plym. Sapporo    6,486      182       . |
       51. | Pont. Phoenix    4,424      203       . |
       64. | Peugeot 604     12,990      192       . |
           +-----------------------------------------+
      Last edited by William Lisowski; 12 May 2019, 11:49.

      Comment


      • #4
        Hello,

        It is not working. I have the regression:
        xtrifreg Y X1 X2 X3, fe i(country_) q (10)

        I have a panel data with 98 countries and several years. When I estimate the regression it´s only used 92 countries. Whta is the command to know what countries are included (or the ones that are not included) in the sample?
        Thank you in advance.

        Best regards

        Comment


        • #5
          That is a much different problem than you posed in post #1, which neither mentioned the panel structure of the data, nor the actual regression command you used.

          Perhaps something like this will do what you need, again listing the countries not used rather than the ones used.
          Code:
          xtrifreg Y X1 X2 X3, fe i(country_) q (10)
          bysort country_: egen used = max(e(sample))
          egen tag = tag(country_)
          list country_ if tag & used==0
          Please a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

          It is unsatisfying to take the time to answer a question only to learn that the time was misspent because the problem description omitted important details. I see from past topics you have started that this has been the case before.

          The more you help others understand your problem, the more likely others are to be able to help you solve your problem.
          Last edited by William Lisowski; 12 May 2019, 14:15.

          Comment


          • #6
            I fully agree with William. Logically, I wrongly assumed the ‘regression estimation’ was done under - regress - command. However, after several ‘trials’ (and errors) I realized the issue deals in fact with a very specific type of regression. You have more than 3 dozens posts in the forum, hence I also assume you are fully aware of the FAQ advice. In the forthcoming posts, please share exactly what was typed and what Stata gave back.
            Best regards,

            Marcos

            Comment

            Working...
            X