Announcement

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

  • Computing an equation

    Dear statalists,

    I am going to compute this equation"
    Click image for larger version

Name:	eq4.PNG
Views:	1
Size:	5.9 KB
ID:	1701594
    I have ac,k,1980 below and Ic,t.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str24 country int year  long  Ic
    "Angola"                   1991   9368
    "Brazil"                   1991  13508
    "Cape Verde"               1991  15714
    "China"                    1991    356
    "France"                   1991  13742
    "Guinea Bissau"            1991   3162
    "India"                    1991    491
    "Italy"                    1991    860
    "Mozambique"               1991   3186
    "Other American countries" 1991  15856
    "Other European countries" 1991   5402
    "Sao Tome and Principe"    1991   2007
    "Spain"                    1991   6273
    "United Kingdom"           1991   5977
    "Angola"                   2001  37014
    "Brazil"                   2001  31869
    "Cape Verde"               2001  33145
    "China"                    2001   2176
    "France"                   2001  15359
    "Guinea Bissau"            2001  15824
    "India"                    2001   1571
    "Italy"                    2001   1793
    "Mozambique"               2001   4685
    "Other American countries" 2001  10663
    "Other European countries" 2001   8387
    "Sao Tome and Principe"    2001   8517
    "Spain"                    2001   9047
    "United Kingdom"           2001   8227
    "Angola"                   2011  26954
    "Brazil"                   2011 109787
    "Cape Verde"               2011  38895
    "China"                    2011  11458
    "France"                   2011  14360
    "Guinea Bissau"            2011  16360
    "India"                    2011   3148
    "Italy"                    2011   3443
    "Mozambique"               2011   3766
    "Other American countries" 2011   8797
    "Other European countries" 2011   9238
    "Sao Tome and Principe"    2011  10408
    "Spain"                    2011  10486
    "United Kingdom"           2011  15774
    "Angola"                   2021  31556
    "Brazil"                   2021 199810
    "Cape Verde"               2021  27144
    "China"                    2021  16631
    "France"                   2021  19064
    "Guinea Bissau"            2021  15298
    "India"                    2021  14130
    "Italy"                    2021  13829
    "Mozambique"               2021   4283
    "Other American countries" 2021  16070
    "Other European countries" 2021  11193
    "Sao Tome and Principe"    2021  10024
    "Spain"                    2021  12811
    "United Kingdom"           2021  24609
    end
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str24 country float  (ack1980    year)
    "Angola"                     .18891397 1980
    "Brazil"                     .08501214 1980
    "Cape Verde"                 .29381713 1980
    "China"                    .0021214846 1980
    "France"                      .0962645 1980
    "Guinea Bissau"             .015580184 1980
    "India"                     .003207685 1980
    "Italy"                     .008910236 1980
    "Mozambique"                 .04511125 1980
    "Other American countries"   .00957214 1980
    "Other European countries"    .0707897 1980
    "Sao Tome and Principe"      .02386246 1980
    "Spain"                      .09492371 1980
    "United Kingdom"             .02520324 1980
    end
    Please share with me your ideas.

    Gratefully yours,
    Paris

  • #2
    You leave us to guess that in your formula the subscript "c" corresponds to the variable "country" in both datasets, the subscript t corresponds to the variable "year" in the first dataset, the subscript "1980" corresponds to the constant value of the variable "year" in the second dataset, which is NOT intended to be matched to the variable "year" in the first dataset when the two are merged, the subscript k doesn't correspond to any variable in the data, and the value of Ic,t is given by the variable Ic in the first dataset, and the value of ac,k,1980 is given by the variable ack1980 in the second dataset.

    Even if a value of k were presented in the second dataset, I do not see how I-hat can have a subscript of k when the outermost of your double summations is over k. Perhaps you meant Ihatc,t?

    Code:
     describe using `data1', simple
    country  year     Ic
    
    . describe using `data2', simple
    country  ack1980  year
    
    . use `data1'
    
    . generate k = 42
    
    . merge m:1 country using `data2', keepusing(ack1980)
    
        Result                      Number of obs
        -----------------------------------------
        Not matched                             0
        Matched                                56  (_merge==3)
        -----------------------------------------
    
    . rename Ic Ict
    
    . generate product = ack1980 * Ict
    
    . collapse (sum) Ihat_ct=product, by(country year)
    
    . list if year==1991, clean noobs
    
                         country   year    Ihat_ct  
                          Angola   1991   1769.746  
                          Brazil   1991   1148.344  
                      Cape Verde   1991   4617.042  
                           China   1991   .7552485  
                          France   1991   1322.867  
                   Guinea Bissau   1991   49.26454  
                           India   1991   1.574973  
                           Italy   1991   7.662803  
                      Mozambique   1991   143.7244  
        Other American countries   1991   151.7758  
        Other European countries   1991    382.406  
           Sao Tome and Principe   1991   47.89196  
                           Spain   1991   595.4564  
                  United Kingdom   1991   150.6398  
    
    .

    Comment


    • #3
      Prof William, sorry I tried to express the question simply but already missed the key clues.

      ac,k,1980: is the share of immigrants from country c in metropolitan area k in 1980.
      Ic,t: is the total number of immigrants from country c that arrived in time t. (t=1991, 2001, 2011, 2021)



      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str24 country str13 metropolitain_area float ack1980
      "Angola"                   "Centro,Lisboa"   .18891397
      "Brazil"                   "Centro,Lisboa"   .08501214
      "Cape Verde"               "Centro,Lisboa"   .29381713
      "China"                    "Centro,Lisboa" .0021214846
      "France"                   "Centro,Lisboa"    .0962645
      "Guinea Bissau"            "Centro,Lisboa"  .015580184
      "India"                    "Centro,Lisboa"  .003207685
      "Italy"                    "Centro,Lisboa"  .008910236
      "Mozambique"               "Centro,Lisboa"   .04511125
      "Other American countries" "Centro,Lisboa"   .00957214
      "Other European countries" "Centro,Lisboa"    .0707897
      "Sao Tome and Principe"    "Centro,Lisboa"   .02386246
      "Spain"                    "Centro,Lisboa"   .09492371
      "United Kingdom"           "Centro,Lisboa"   .02520324
      end
      Ihat kt is correct.

      Comment


      • #4
        Thank you. The code doesn't need to change much.
        Code:
        describe using `data1', simple
        describe using `data2', simple
        use `data1'
        merge m:1 country using `data2', keepusing(metropolitain_area ack1980)
        rename Ic Ict
        generate product = ack1980 * Ict
        collapse (sum) Ihat_ct=product, by(metropolitain_area year country)
        order metropolitain_area, first
        list if year==1991, clean abbreviate(20)
        Code:
        . describe using `data1', simple
        country  year     Ic
        
        . describe using `data2', simple
        country             metropolitain_area  ack1980
        
        . use `data1'
        
        . merge m:1 country using `data2', keepusing(metropolitain_area ack1980)
        
            Result                      Number of obs
            -----------------------------------------
            Not matched                             0
            Matched                                56  (_merge==3)
            -----------------------------------------
        
        . rename Ic Ict
        
        . generate product = ack1980 * Ict
        
        . collapse (sum) Ihat_ct=product, by(metropolitain_area year country)
        
        . order metropolitain_area, first
        
        . list if year==1991, clean abbreviate(20)
        
               metropolitain_area                    country   year    Ihat_ct  
          1.        Centro,Lisboa                     Angola   1991   1769.746  
          2.        Centro,Lisboa                     Brazil   1991   1148.344  
          3.        Centro,Lisboa                 Cape Verde   1991   4617.042  
          4.        Centro,Lisboa                      China   1991   .7552485  
          5.        Centro,Lisboa                     France   1991   1322.867  
          6.        Centro,Lisboa              Guinea Bissau   1991   49.26454  
          7.        Centro,Lisboa                      India   1991   1.574973  
          8.        Centro,Lisboa                      Italy   1991   7.662803  
          9.        Centro,Lisboa                 Mozambique   1991   143.7244  
         10.        Centro,Lisboa   Other American countries   1991   151.7758  
         11.        Centro,Lisboa   Other European countries   1991    382.406  
         12.        Centro,Lisboa      Sao Tome and Principe   1991   47.89196  
         13.        Centro,Lisboa                      Spain   1991   595.4564  
         14.        Centro,Lisboa             United Kingdom   1991   150.6398  
        
        .

        Comment


        • #5
          You are amazing Prof William.
          I could not have done it without you.
          That worked truly. Your solution is direct and good-looking as always.

          Comment

          Working...
          X