def calc_probability_LD_migration_zvoleff(person, time): """ Calculates the probability of local-distant migration for an agent, using the results of Alex Zvoleff's empirical analysis of the CVFS data, following the results of the analysis conducted by Massey et al. (2010). """ ######################################################################### # Intercept inner = rcParams['migration.ld.zv.coef.intercept'] if person.is_in_school(): inner += rcParams['migration.ld.zv.coef.in_school'] inner += person.get_years_schooling() * rcParams['migration.ld.zv.coef.years_schooling'] ####################################################################### # Household level variables household = person.get_parent_agent() inner += rcParams['migration.ld.zv.coef.own_farmland'] * household._own_land ####################################################################### # Neighborhood level variables neighborhood = household.get_parent_agent() inner += rcParams['migration.ld.zv.coef.log_market_min_ft'] * np.log(neighborhood.NFOs['market_min_ft'] + 1) ######################################################################### # Other controls if person.get_sex() == "female": inner += rcParams['migration.ld.zv.coef.female'] ethnicity = person.get_ethnicity() assert ethnicity!=None, "Ethnicity must be defined" if ethnicity == "HighHindu": # This was the reference level pass elif ethnicity == "HillTibeto": inner += rcParams['migration.ld.zv.coef.ethnicHillTibeto'] elif ethnicity == "LowHindu": inner += rcParams['migration.ld.zv.coef.ethnicLowHindu'] elif ethnicity == "Newar": inner += rcParams['migration.ld.zv.coef.ethnicNewar'] elif ethnicity == "TeraiTibeto": inner += rcParams['migration.ld.zv.coef.ethnicTeraiTibeto'] age = person.get_age_years() if (age >= 15) & (age <= 24): inner += rcParams['migration.ld.zv.coef.age15-24'] elif (age > 24) & (age <= 34): inner += rcParams['migration.ld.zv.coef.age24-34'] elif (age > 34) & (age <= 44): inner += rcParams['migration.ld.zv.coef.age34-44'] elif (age > 44) & (age <= 55): inner += rcParams['migration.ld.zv.coef.age45-55'] elif (age > 55): # Reference class pass prob = 1./(1 + np.exp(-inner)) if rcParams['log_stats_probabilities']: logger.debug("Person %s local-distant migration probability %.6f (age: %s)"%(person.get_ID(), prob, person.get_age_years())) return prob
def calc_probability_marriage_zvoleff(person, time): """ Calculates the probability of marriage for an agent, using the results of Alex Zvoleff's empirical analysis of the CVFS data, following the results of the analysis conducted by Yabiku (2006). """ inner = rcParams['marrtime.zv.coef.(Intercept)'] ethnicity = person.get_ethnicity() assert ethnicity!=None, "Ethnicity must be defined" if ethnicity == "HighHindu": # This was the reference level pass elif ethnicity == "HillTibeto": inner += rcParams['marrtime.zv.coef.ethnicHillTibeto'] elif ethnicity == "LowHindu": inner += rcParams['marrtime.zv.coef.ethnicLowHindu'] elif ethnicity == "Newar": inner += rcParams['marrtime.zv.coef.ethnicNewar'] elif ethnicity == "TeraiTibeto": inner += rcParams['marrtime.zv.coef.ethnicTeraiTibeto'] # Gender if person.get_sex() == "female": inner += rcParams['marrtime.zv.coef.genderfemale'] age = person.get_age_years() inner += rcParams['marrtime.zv.coef.age'] * age inner += rcParams['marrtime.zv.coef.I(age^2)'] * (age ** 2) # Neighborhood characteristics neighborhood = person.get_parent_agent().get_parent_agent() log_percent_agveg = np.log((neighborhood._land_agveg / neighborhood._land_total)*100 + 1) inner += rcParams['marrtime.zv.coef.interp_logpercagveg'] * log_percent_agveg inner += rcParams['marrtime.zv.coef.SCHLFT'] * neighborhood.NFOs['school_min_ft'] inner += rcParams['marrtime.zv.coef.HLTHFT'] * neighborhood.NFOs['health_min_ft'] inner += rcParams['marrtime.zv.coef.BUSFT'] * neighborhood.NFOs['bus_min_ft'] inner += rcParams['marrtime.zv.coef.MARFT'] * neighborhood.NFOs['market_min_ft'] inner += rcParams['marrtime.zv.coef.EMPFT'] * neighborhood.NFOs['employer_min_ft'] # Schooling inner += rcParams['marrtime.zv.coef.schooling_yrs'] * person.get_years_schooling() if person.is_in_school(): inner += rcParams['marrtime.zv.coef.in_school'] # Account for monthly differences in marriage rates - some days (and # months) are more auspicious for marriage than others. month_num = int(np.mod(np.round(time*12, 0), 12) + 1) if month_num == 1: # This was the reference level pass elif month_num == 2: inner += rcParams['marrtime.zv.coef.month2'] elif month_num == 3: inner += rcParams['marrtime.zv.coef.month3'] elif month_num == 4: inner += rcParams['marrtime.zv.coef.month4'] elif month_num == 5: inner += rcParams['marrtime.zv.coef.month5'] elif month_num == 6: inner += rcParams['marrtime.zv.coef.month6'] elif month_num == 7: inner += rcParams['marrtime.zv.coef.month7'] elif month_num == 8: inner += rcParams['marrtime.zv.coef.month8'] elif month_num == 9: inner += rcParams['marrtime.zv.coef.month9'] elif month_num == 10: inner += rcParams['marrtime.zv.coef.month10'] elif month_num == 11: inner += rcParams['marrtime.zv.coef.month11'] elif month_num == 12: inner += rcParams['marrtime.zv.coef.month12'] prob = 1./(1 + np.exp(-inner)) if rcParams['log_stats_probabilities']: logger.debug("Person %s marriage probability %.6f (age: %s)"%(person.get_ID(), prob, person.get_age_years())) return prob