synthpops.ltcfs module¶
Modeling Seattle Metro Long Term Care Facilities
-
synthpops.ltcfs.
generate_ltcfs
(n, with_facilities, datadir, country_location, state_location, location, use_default, smooth_ages, window_length)¶ Generate residents living in long term care facilities and their ages.
- Parameters
n (int) – The number of people to create.
with_facilities (bool) – If True, create long term care facilities, currently only available for locations in the US.
datadir (string) – The file path to the data directory.
country_location (string) – name of the country the location is in
state_location (string) – name of the state the location is in
location – name of the location
use_default (bool) – If True, try to first use the other parameters to find data specific to the location under study; otherwise, return default data drawing from default_location, default_state, default_country.
smooth_ages (bool) – If True, use smoothed out age distribution.
window_length (int) – length of window over which to average or smooth out age distribution
- Returns
The number of people expected to live outside long term care facilities, age_brackets, age_by_brackets dictionary, age distribution adjusted for long term care facility residents already sampled, and facilities with people living in them.
-
synthpops.ltcfs.
assign_facility_staff
(datadir, location, state_location, country_location, ltcf_staff_age_min, ltcf_staff_age_max, facilities, workers_by_age_to_assign_count, potential_worker_uids_by_age, potential_worker_uids, facilities_by_uids, age_by_uid_dic, use_default=False)¶ Assign Long Term Care Facility staff to the generated facilities with residents.
- Parameters
datadir (string) – The file path to the data directory.
location – name of the location
state_location (string) – name of the state the location is in
country_location (string) – name of the country the location is in
ltcf_staff_age_min (int) – Long term care facility staff minimum age.
ltcf_staff_age_max (int) – Long term care facility staff maximum age.
facilities (list) – A list of lists where each sublist is a facility with the resident ages
workers_by_age_to_assign_count (dict) – A dictionary mapping age to the count of employed individuals of that age.
potential_worker_uids (dict) – dictionary of potential workers mapping their id to their age
facilities – A list of lists where each sublist is a facility with the resident IDs
age_by_uid_dic (dict) – dictionary mapping id to age for all individuals in the population
use_default (bool) – If True, try to first use the other parameters to find data specific to the location under study; otherwise, return default data drawing from default_location, default_state, default_country.
- Returns
A list of lists with the facility staff IDs for each facility.
- Return type
list
-
synthpops.ltcfs.
remove_ltcf_residents_from_potential_workers
(facilities_by_uids, potential_worker_uids, potential_worker_uids_by_age, workers_by_age_to_assign_count, age_by_uid_dic)¶ Remove facilities residents from potential workers
-
synthpops.ltcfs.
ltcf_resample_age
(exp_age_distr, a)¶ Resampling younger ages to better match data
- Parameters
exp_age_distr (dict) – age distribution
age (int) – age as an integer
- Returns
Resampled age as an integer.
Notes
This is not always necessary, but is mostly used to smooth out sharp edges in the age distribution when spsamp.resample_age() produces too many of one year and under produces the surrounding ages. For example, new borns (0 years old) may be over produced, and 1 year olds under produced, so this function can be customized to correct for that. It is currently customized to model well the age distribution for Seattle, Washington.
-
synthpops.ltcfs.
generate_larger_households_method_1
(size, hh_sizes, hha_by_size_counts, hha_brackets, cm_age_brackets, cm_age_by_brackets_dic, contact_matrix_dic, single_year_age_distr)¶ Generate ages of those living in households of greater than one individual. Reference individual is sampled conditional on the household size. All other household members have their ages sampled conditional on the reference person’s age and the age mixing contact matrix in households for the population under study.
- Parameters
size (int) – The household size.
hh_sizes (array) – The count of household size s at index s-1.
hha_by_size_counts (matrix) – A matrix in which each row contains the age distribution of the reference person for household size s at index s-1.
hha_brackets (dict) – The age brackets for the heads of household.
cm_age_brackets (dict) – The dictionary mapping age bracket keys to age bracket range matching the household contact matrix.
cm_age_by_brackets_dic (dict) – The dictionary mapping age to the age bracket range it falls within matching the household contact matrix.
contact_matrix_dic (dict) – A dictionary of the age-specific contact matrix for different physical contact settings.
single_year_age_distr (dict) – The age distribution.
- Returns
An array of households for size
size
where each household is a row and the values in the row are the ages of the household members. The first age in the row is the age of the reference individual.
-
synthpops.ltcfs.
generate_all_households_method_1
(N, hh_sizes, hha_by_size_counts, hha_brackets, cm_age_brackets, cm_age_by_brackets_dic, contact_matrix_dic, single_year_age_distr)¶ Generate the ages of those living in households together. First create households of people living alone, then larger households. For households larger than 1, a reference individual’s age is sampled conditional on the household size, while all other household members have their ages sampled conditional on the reference person’s age and the age mixing contact matrix in households for the population under study.
- Parameters
N (int) – The number of people in the population.
hh_sizes (array) – The count of household size s at index s-1.
hha_by_size_counts (matrix) – A matrix in which each row contains the age distribution of the reference person for household size s at index s-1.
hha_brackets (dict) – The age brackets for the heads of household.
cm_age_brackets (dict) – The dictionary mapping age bracket keys to age bracket range matching the household contact matrix.
cm_age_by_brackets_dic (dict) – The dictionary mapping age to the age bracket range it falls within matching the household contact matrix.
contact_matrix_dic (dict) – The dictionary of the age-specific contact matrix for different physical contact settings.
single_year_age_distr (dict) – The age distribution.
- Returns
An array of all households where each household is a row and the values in the row are the ages of the household members. The first age in the row is the age of the reference individual. Households are randomly shuffled by size.
Note
This method is not guaranteed to model the population age distribution well automatically. The method called inside, generate_larger_households_method_1 uses the method ltcf_resample_age to fit Seattle, Washington populations with long term care facilities generated. For a method that matches the age distribution well for populations in general, please use generate_all_households_methods_2.
-
synthpops.ltcfs.
generate_all_households_method_2
(n_nonltcf, hh_sizes, hha_by_size, hha_brackets, cm_age_brackets, cm_age_by_brackets_dic, contact_matrix_dic, ltcf_adjusted_age_distr)¶ Generate the ages of those living in households together. First create households of people living alone, then larger households. For households larger than 1, a reference individual’s age is sampled conditional on the household size, while all other household members have their ages sampled conditional on the reference person’s age and the age mixing contact matrix in households for the population under study. Fix the count of ages in the population before placing individuals in households so that the age distribution of the generated population is fixed to closely match the age distribution from data on the population.
- Parameters
n_nonltcf (int) – The number of people in the population not living in long term care facilities.
hh_sizes (array) – The count of household size s at index s-1.
hha_by_size_counts (matrix) – A matrix in which each row contains the age distribution of the reference person for household size s at index s-1.
hha_brackets (dict) – The age brackets for the heads of household.
cm_age_brackets (dict) – The dictionary mapping age bracket keys to age bracket range matching the household contact matrix.
cm_age_by_brackets_dic (dict) – The dictionary mapping age to the age bracket range it falls within matching the household contact matrix.
contact_matrix_dic (dict) – The dictionary of the age-specific contact matrix for different physical contact settings.
ltcf_adjusted_age_distr (dict) – The age distribution.
- Returns
An array of all households where each household is a row and the values in the row are the ages of the household members. The first age in the row is the age of the reference individual. Households are randomly shuffled by size.