alan-turing-institute / vivarium_population_spenser

Vivarium microsimulation tools used to model population evolution with the SPENSER project
GNU General Public License v3.0
3 stars 0 forks source link

Build an Immigration module #29

Closed crangelsmith closed 4 years ago

crangelsmith commented 4 years ago
crangelsmith commented 4 years ago

Hi @kasra-hosseini , just to let you know (and avoid duplicating work) that the function to compute migration rates developed in PR #32 should work for both the emigration rates and immigration rates.

kasra-hosseini commented 4 years ago

Hi @crangelsmith, great! Thanks! I am reviewing the PR now.

kasra-hosseini commented 4 years ago

Branch: feature/29-build-an-immigration

kasra-hosseini commented 4 years ago

Hi again @crangelsmith , I used your code to plot the migration rates and here is a plot:

Screenshot 2020-07-20 at 16 45 12

To reproduce:

# Population (total)
plt.figure(figsize=(15, 10))
plt.plot(asfr_data_emigration["age_start"], 
         asfr_data_emigration["mean_value"], 
         '.', c='k', lw=4, markersize=12)
plt.xlabel("Age", size=32)
plt.ylabel("Migration rate", size=32)
plt.xticks(size=24, rotation=90)
plt.yticks(size=24)
plt.grid()
plt.show()

I am wondering if the large values at older ages are expected?

crangelsmith commented 4 years ago

Hi @kasra-hosseini , thanks for spotting this! I did some checks and I think this is a product of categories with very low statistics, where the predicted number of migrants is higher that the total number of people in that area. I found this particular case:

I guess we will have to cater for this scenarios, let's discuss with Nik tomorrow about it.

kasra-hosseini commented 4 years ago

Hi @crangelsmith Sounds good and thanks for checking. I also implemented the very first version of the immigration component. It is deterministic now in the sense that the total number of immigrants should be specified a priori. Then, at each time step, we sample from the migration rates to assign age/gender/... to the new immigrants. Here is one output example in which:

(no fertility)

Screenshot 2020-07-21 at 12 01 17
kasra-hosseini commented 4 years ago

I still need to review and add the test_immigration.py. Once these are finished, I will send a PR.

kasra-hosseini commented 4 years ago

See PR: https://github.com/alan-turing-institute/vivarium_public_health_spenser/pull/34