Announcement

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

  • Create Migration Variable

    Hello,

    I want to plot the absolute migration from East-Germany to West-Germany from 1990 to 2019 using panel data. My results show a different migration pattern than is usually found with the same data.

    This is one approach for absolute migration:
    Code:
    gen migration_ost_west = 1 if sampreg == 1 & L.sampreg == 2
    egen total_migration_per_year = total(migration_ost_west), by(syear)
    preserve
    duplicates drop syear, force
    twoway (line total_migration_per_year syear if syear >= 1990), ///
           xtitle(Jahr) ytitle(Absolute Migration von Ost nach West)
    restore
    This is another approach for absolute migration:
    Code:
    gen migration = 1 if sampreg == 1 & sampreg[_n-1] == 2
    egen mig_total = sum(migration), by(syear)
    preserve
    duplicates drop syear, force
    line mig_total syear
    restore
    The idea behind both approaches is that when a person has lived in East-Germany (sampreg == 2) in the previous year and lives in West-Germany (sampreg == 1) in the current year, the person has migrated from east to west.

    When I weight (variable phrf) the migration variable to get results for the whole population, the plot also does not look correct.
    Code:
    preserve
    gen mig_population = migration_ost_west * phrf
    egen mig_pop_year = sum(mig_population), by(syear)
    duplicates drop syear, force
    line mig_pop_year syear if syear >= 1990
    restore
    Are there mistakes in the codes or are there better approaches to create the migration variables and plot them?

    Thank you very much in advance for helping.

  • #2
    What would be the point of such an exercise? To show that your sample is representative of the actual population? There is no data example provided, but all you would need to do is tag individuals who migrated from East to West and then collapse the data by summing it up by year.

    Code:
    help collapse
    If you simply want to demonstrate migration patterns, official estimates are available from your national statistics agency (https://www.destatis.de/EN/Themes/So...migration.html), so there's no need to project them.

    Code:
    import delimited "https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Bevoelkerung/_Grafik/_Interaktiv/Daten/wanderungen-bund-neue-laender.csv?__blob=value", clear
    destring westgegenüberost - westnachostmitberlin, dpcomma replace
    twoway line ostnachwest jahr, xtitle("") ytitle(Thousands) title(Germany East to West Migration 1991-2022) note(Source: Statistisches Bundesamt)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	50.1 KB
ID:	1743368

    Comment


    • #3
      Thank you for your answer, Andrew. I have to use given data and cannot use the prepared data by the national statistics agency.

      Is this what you mean, using the collapse command?
      Code:
      gen migration_ost_west = 1 if sampreg == 1 & L.sampreg == 2
      replace migration_ost_west = migration_ost_west * phrf
      preserve
      collapse (sum)migration_ost_west, by(syear)
      duplicates drop syear, force
      line migration_ost_west syear if syear >= 1990
      restore

      Comment


      • #4
        collapse (sum)migration_ost_west, by(syear)
        duplicates drop syear, force
        The highlighted line is redundant since you are collapsing by year. But, assuming that you have individual-level panel data and your weights are frequency weights, that does it.

        Comment


        • #5
          Thank you very much.

          Comment

          Working...
          X