Announcement

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

  • #16
    When I used -xi- Stata didn't give the last two lines, only when I used -xi:-

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(ideology partisanship) float gini
    . 6 .310057
    . 1 .322721
    . 3 .344811
    . 5 .353524
    . 4 .353524
    . 1 .353524
    . 4 .353524
    . 0 .353524
    . 4 .324742
    . 0 .353814
    . 3 .340153
    . 4 .340153
    . 6 .329563
    . 3 .329563
    . 6 .364493
    . 0 .364493
    . 1 .353524
    . 3 .353524
    . 1 .310057
    . 3 .293463
    . 4 .322721
    . 4 .322721
    . 5 .348168
    . 5 .313803
    . 6 .290328
    . 0 .313803
    . 3 .290328
    . 3 .293463
    . 3 .293463
    . 1 .311737
    . 6 .311737
    . 1 .322721
    . 0 .340811
    . 1 .320216
    . 1 .320216
    . 1 .353814
    . 1 .353814
    . 1 .339702
    . 4 .339702
    . 2 .332231
    . 4 .377125
    . 6 .310057
    . 5 .310057
    . 6 .310057
    . 4 .311737
    . 0 .311737
    . 6 .311737
    . 1 .311737
    . 1 .311737
    . 1 .290328
    . 1 .324742
    . 6 .311737
    . 2 .329563
    . 1 .364493
    . 0 .364493
    . 0 .329563
    . 5 .329563
    . 3 .329563
    . 2 .329563
    . 6 .329563
    . 6 .329563
    . 0 .353524
    . 0 .353524
    . 6 .310741
    . 4 .329563
    . 2 .301993
    . 1 .293463
    . 6 .290328
    . 1 .355091
    . 5 .355091
    . 5 .339702
    . 5 .332231
    . 2 .332231
    . 4 .377125
    . 2 .332231
    . 1 .353814
    . 5 .311737
    . 6 .311737
    . 1 .377125
    . 1 .377125
    . 3 .311737
    . 6 .329563
    . 1 .322721
    . 3 .332231
    . 1 .315749
    . 4  .36388
    . 4 .348168
    . 1 .348168
    . 1 .348168
    . 5 .290328
    . 5 .310057
    . 6 .324742
    . 5 .340811
    . 6 .320216
    . 0 .311737
    . 1 .311737
    . 0 .339702
    . 2 .311737
    . 5 .329563
    . 2 .291198
    end
    label values ideology ideology_label
    label values partisanship partisanship_label
    label def partisanship_label 0 "Strong Democrat", modify
    label def partisanship_label 1 "Weak Democrat", modify
    label def partisanship_label 2 "Independent - Democrat", modify
    label def partisanship_label 3 "Independent - Independent", modify
    label def partisanship_label 4 "Independent - Republican", modify
    label def partisanship_label 5 "Weak Republican", modify
    label def partisanship_label 6 "Strong Republican", modify

    Comment


    • #17
      ideology is entirely missing in this example dataset. If that's true generally, then it's a problem. Show us the results of

      Code:
      tab ideology if ideology < . 

      Comment


      • #18
        This is what I get:

        IDEOLOGY: |
        Liberal-Conservative Scale | Freq. Percent Cum.
        -----------------------------+-----------------------------------
        Extremely liberal | 307 2.11 2.11
        Liberal | 1,468 10.09 12.21
        Slightly liberal | 1,908 13.12 25.33
        Moderate, middle of the road | 4,907 33.74 59.07
        Slightly conservative | 2,928 20.13 79.21
        Conservative | 2,608 17.93 97.14
        Extremely conservative | 416 2.86 100.00
        -----------------------------+-----------------------------------
        Total | 14,542 100.00

        Comment


        • #19
          So, you have non-missing values on ideology. Perhaps the problem is missing data in the other variables -- all the variables mentioned must be non-missing in each observation -- or your xtset settings don't match your data. That could happen if you have gaps in time or non-unit time spacing. Show us the results of

          Code:
          xtset
          copying and pasting between CODE delimiters like this:

          Code:
          . webuse grunfeld, clear
          
          . xtset
                 panel variable:  company (strongly balanced)
                  time variable:  year, 1935 to 1954
                          delta:  1 year
          
          .

          Comment


          • #20
            Code:
            . xtset id year
                   panel variable:  id (unbalanced)
                    time variable:  year, 1968 to 2000, but with gaps
                            delta:  1 unit
            Is it because it says unbalanced? I was told I could use xtserial for unbalanced data, maybe that's wrong?

            Comment


            • #21
              No; it's the gaps.

              You told Stata that you have yearly data, so to Stata the previous value of any variable (for each panel) is (and can only be) for the previous year.

              Evidently you have no surveys in consecutive years. Either you need to specify delta() to xtset (which will work if and only if your data are regularly spaced) or you need to set up your own time metric.

              Lag 1 means previous value if and only if the previous value was 1 time unit earlier.

              The next piece of information is the results of

              Code:
              tab year
              presented as in #20.

              Comment


              • #22
                Code:
                tab year
                
                      STUDY |
                  VARIABLE: |
                    Year of |
                      Study |      Freq.     Percent        Cum.
                ------------+-----------------------------------
                       1968 |      1,336        7.83        7.83
                       1970 |      1,181        6.92       14.75
                       1972 |      1,323        7.76       22.51
                       1974 |        971        5.69       28.20
                       1976 |      1,027        6.02       34.22
                       1978 |      1,352        7.93       42.15
                       1980 |        704        4.13       46.27
                       1982 |        702        4.12       50.39
                       1984 |      1,123        6.58       56.97
                       1986 |      1,323        7.76       64.73
                       1988 |      1,040        6.10       70.82
                       1990 |      1,065        6.24       77.07
                       1992 |      1,400        8.21       85.27
                       1994 |      1,133        6.64       91.92
                       1996 |        951        5.57       97.49
                       2000 |        428        2.51      100.00
                ------------+-----------------------------------
                      Total |     17,059      100.00

                Comment


                • #23
                  Hi,

                  Sorry I changed a bit of my dataset (I dropped some variables before). The correct code is:

                  Code:
                  tab year
                  
                        STUDY |
                    VARIABLE: |
                      Year of |
                        Study |      Freq.     Percent        Cum.
                  ------------+-----------------------------------
                         1954 |      1,041        3.47        3.47
                         1956 |      1,616        5.39        8.86
                         1958 |      1,330        4.43       13.29
                         1960 |      1,123        3.74       17.04
                         1962 |      1,172        3.91       20.95
                         1964 |      1,439        4.80       25.74
                         1966 |      1,191        3.97       29.72
                         1968 |      1,433        4.78       34.49
                         1970 |      1,232        4.11       38.60
                         1972 |      1,410        4.70       43.30
                         1974 |      1,030        3.43       46.74
                         1976 |      1,126        3.75       50.49
                         1978 |      1,465        4.88       55.38
                         1980 |        746        2.49       57.86
                         1982 |        772        2.57       60.44
                         1984 |      1,207        4.02       64.46
                         1986 |      1,423        4.74       69.21
                         1988 |      1,110        3.70       72.91
                         1990 |      1,149        3.83       76.74
                         1992 |      1,506        5.02       81.76
                         1994 |      1,253        4.18       85.94
                         1996 |      1,078        3.59       89.53
                         1998 |        896        2.99       92.52
                         2000 |        466        1.55       94.07
                         2002 |      1,062        3.54       97.62
                         2004 |        715        2.38      100.00
                  ------------+-----------------------------------
                        Total |     29,991      100.00

                  Comment


                  • #24
                    Try

                    Code:
                    xtset id year, delta(2)
                    and see if that helps.
                    -------------------------------------------
                    Richard Williams, Notre Dame Dept of Sociology
                    StataNow Version: 19.5 MP (2 processor)

                    EMAIL: [email protected]
                    WWW: https://www3.nd.edu/~rwilliam

                    Comment


                    • #25
                      It worked. Thank you!

                      Comment

                      Working...
                      X