access.Access.raam

Access.raam(name='raam', cost=None, supply_values=None, normalize=False, tau=60, rho=None, max_cycles=150, initial_step=0.2, half_life=50, min_step=0.005, verbose=False)[source]

Calculate the rational agent access model. [Saxon and Snow, 2019]

Parameters:
namestr

Column name for access values

coststr

Name of cost variable, for reaching supply sites.

supply_values{str, list}

Name(s) of supply values in supply_df

normalizebool

If True, return normalized access values; otherwise, return raw access values

taufloat

tau parameter (travel time scale)

rhofloat

rho parameter (congestion cost scale)

max_cyclesint

How many cycles to run the RAAM optimization for.

initial_step{int, float}

If an float < 1, it is the proportion of a demand site that can shift, in the first cycle. If it is an integer, it is simply a limit on the total number.

half_lifeint

How many cycles does it take to halve the move rate?

min_step{int, float}

This is the minimum value, to which the moving fraction converges.

verbosebool

Print some information as the optimization proceeds.

Returns:
accesspandas Series

Accessibility score for origin locations.

Examples

Import the base Access class and Datasets.

>>> from access import Access, Datasets

Load each of the example datasets which correspond to the demand (population), supply (doctors and dentists) and cost (travel time), respectively. The sample data represents the Chicago metro area with a 50km buffer around the city boundaries.

>>> chi_docs_dents   = Datasets.load_data('chi_doc')
>>> chi_population   = Datasets.load_data('chi_pop')
>>> chi_travel_costs = Datasets.load_data('chi_times')
>>> chi_docs_dents.head()
         geoid  doc  dentist
0  17031010100    1        1
1  17031010201    0        1
2  17031010202    4        1
3  17031010300    4        1
4  17031010400    0        2
>>> chi_population.head()
         geoid   pop
0  17031010100  4854
1  17031010201  6450
2  17031010202  2818
3  17031010300  6236
4  17031010400  5042

The chi_travel_costs dataset is the cost matrix, showing the travel time between each of the Census Tracts in the Chicago metro area.

>>> chi_travel_costs.head()
        origin         dest   cost
0  17093890101  17031010100  91.20
1  17093890101  17031010201  92.82
2  17093890101  17031010202  92.95
3  17093890101  17031010300  89.40
4  17093890101  17031010400  84.97

Now, create an instance of the Access class and specify the demand, supply, and cost datasets.

>>> chicago_primary_care = Access(demand_df = chi_population, demand_index = "geoid",
                                  demand_value = "pop",
                                  supply_df = chi_docs_dents, supply_index = "geoid",
                                  supply_value = ["doc", "dentist"],
                                  cost_df = chi_travel_costs, cost_origin  = "origin",
                                  cost_dest = "dest", cost_name = "cost")

With the demand, supply, and cost data provided, we can now produce the RAAM access measures defining a floating catchment area of 30 minutes by setting the tau value to 30 (60 minutes is the default).

>>> chicago_primary_care.raam(tau = 30)
             raam_doc  raam_dentist
geoid
17031010100  1.027597      1.137901
17031010201  0.940239      1.332557
17031010202  1.031144      1.413279
...........  ........      ........
17197884101  2.365171      1.758800
17197884103  2.244007      1.709857
17197980100  2.225820      1.778264

You can access the results stored in the Access.access_df attribute.

>>> chicago_primary_care.access_df
              pop  raam_doc  raam_dentist
geoid
17031010100  4854  1.027597      1.137901
17031010201  6450  0.940239      1.332557
17031010202  2818  1.031144      1.413279
...........   ....  ........      ........
17197884101  4166  2.365171      1.758800
17197884103  2776  2.244007      1.709857
17197980100  3264  2.225820      1.778264

By providing a string to the name argument, you can call the Access.raam method again using a different parameter of tau and save the outputs without overwriting previous ones.

>>> chicago_primary_care.raam(name = "raam2", tau = 2)
>>> chicago_primary_care.access_df
              pop  raam_doc  raam_dentist  raam45_doc  raam45_dentist
geoid
17031010100  4854  1.027597      1.137901    0.967900        1.075116
17031010201  6450  0.940239      1.332557    0.908518        1.133207
17031010202  2818  1.031144      1.413279    0.962915        1.206775
...........   ....  ........      ........   ........       ........
17197884101  4166  2.365171      1.758800    1.921161        1.495642
17197884103  2776  2.244007      1.709857    1.900596        1.517022
17197980100  3264  2.225820      1.778264    1.868281        1.582177

If euclidean costs are available (see Access.access.create_euclidean_distance()), you can use euclidean distance instead of time to calculate RAAM access measures. Insted of being measured in minutes, tau would now be measured in meters.

>>> chicago_primary_care.raam(name = "raam_euclidean", tau = 100, cost = "euclidean")