Announcement

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

  • problem with reg for fweight

    Hi,
    I want to input a number of people by age classes, but then my code give me one observation for each age classe. I try with the reg function, who say I have 66 millions of observations, but when after I try "tab AGECL" that say again that I have one observation for each classe group. Do somebody know how can I solve this problem ?
    Thanks !

    Code:
    clear
    input byte (AGECL) POPULATION
    1 11965004
    2 11740895
    3 12486039
    4 13345975
    5 11133961
    6 6286470
    end
    label values AGECL AGECL
    label def AGECL 1 "0-14", modify
    label def AGECL 2 "15-29", modify
    label def AGECL 3 "30-44", modify
    label def AGECL 4 "45-59", modify
    label def AGECL 5 "60-74", modify
    label def AGECL 6 "plus de 75", modify
    label var AGECL "âge en classe"
    label var POPULATION "Population par groupe d'âge en France"
    
    reg AGECL [fweight=POPULATION]
    
    
          Source |       SS       df       MS              Number of obs =66958344
    -------------+------------------------------           F(  0,66958343) =    0.00
           Model |           0     0           .           Prob > F      =       .
        Residual |   16878110466958343  2.52068819           R-squared     =  0.0000
    -------------+------------------------------           Adj R-squared =  0.0000
           Total |   16878110466958343  2.52068819           Root MSE      =  1.5877
    
    ------------------------------------------------------------------------------
           AGECL |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |   3.280807    .000194  1.7e+04   0.000     3.280427    3.281188
    ------------------------------------------------------------------------------
    
    
    
    . tab AGECL
    
         âge en |
         classe |      Freq.     Percent        Cum.
    ------------+-----------------------------------
           0-14 |          1       16.67       16.67
          15-29 |          1       16.67       33.33
          30-44 |          1       16.67       50.00
          45-59 |          1       16.67       66.67
          60-74 |          1       16.67       83.33
     plus de 75 |          1       16.67      100.00
    ------------+-----------------------------------
          Total |          6      100.00

  • #2
    I'm not sure I completely follow; however, you used "[fweight=POPULATION]" but not in your -tab- command - if you add it to your -tab- command, you get a total of "66,958,344"

    Comment


    • #3
      Thanks for your reply, I try it, but I have the same problem

      Code:
      tab POPULATION
      
       Population |
       par groupe |
         d'âge en |
           France |      Freq.     Percent        Cum.
      ------------+-----------------------------------
          6286470 |          1       16.67       16.67
         1.11e+07 |          1       16.67       33.33
         1.17e+07 |          1       16.67       50.00
         1.20e+07 |          1       16.67       66.67
         1.25e+07 |          1       16.67       83.33
         1.33e+07 |          1       16.67      100.00
      ------------+-----------------------------------
            Total |          6      100.00

      Comment


      • #4
        Code:
        tab AGECL [fw=POPULATION]

        Comment


        • #5
          Thanks ! Do you know if it's possible to save it without having to make [fw= POPULATION] at each command ? Because I would like to use this population as a reference population for a standardisation, so i would like to save the data (the data that I've got when I make [fw=POPULATION]) in a .dta file

          Comment


          • #6
            The only thing that tabulate is giving you are the percentages and cumulative percentages, which you can calculate. Otherwise, the frequencies are already present in the dataset.

            Code:
            clear
            input byte (AGECL) POPULATION
            1 11965004
            2 11740895
            3 12486039
            4 13345975
            5 11133961
            6 6286470
            end
            label values AGECL AGECL
            label def AGECL 1 "0-14", modify
            label def AGECL 2 "15-29", modify
            label def AGECL 3 "30-44", modify
            label def AGECL 4 "45-59", modify
            label def AGECL 5 "60-74", modify
            label def AGECL 6 "plus de 75", modify
            label var AGECL "âge en classe"
            label var POPULATION "Population par groupe d'âge en France"
            
            tab AGECL [fw=POPULATION]
            
            format POPULATION %14.0f
            egen double pct= total(POPULATION)
            replace pct= (POPULATION/pct)*100
            gen cum_pct=sum(pct)
            Res.:

            Code:
            . tab AGECL [fw=POPULATION]
            
                 âge en |
                 classe |      Freq.     Percent        Cum.
            ------------+-----------------------------------
                   0-14 | 11,965,004       17.87       17.87
                  15-29 | 11,740,895       17.53       35.40
                  30-44 | 12,486,039       18.65       54.05
                  45-59 | 13,345,975       19.93       73.98
                  60-74 | 11,133,961       16.63       90.61
             plus de 75 |  6,286,470        9.39      100.00
            ------------+-----------------------------------
                  Total | 66,958,344      100.00
            
            
            .
            . format POPULATION %14.0f
            
            .
            . egen double pct= total(POPULATION)
            
            .
            . replace pct= (POPULATION/pct)*100
            (6 real changes made)
            
            .
            . gen cum_pct=sum(pct)
            
            . l, sep(0)
            
                 +----------------------------------------------+
                 |      AGECL   POPULA~N         pct    cum_pct |
                 |----------------------------------------------|
              1. |       0-14   11965004   17.869325   17.86933 |
              2. |      15-29   11740895   17.534626   35.40395 |
              3. |      30-44   12486039   18.647473   54.05142 |
              4. |      45-59   13345975   19.931758   73.98318 |
              5. |      60-74   11133961   16.628191   90.61137 |
              6. | plus de 75    6286470   9.3886282        100 |
                 +----------------------------------------------+
            
            .

            Comment


            • #7
              Thanks you very murch this is exactly what I wanted to do !

              Comment

              Working...
              X