Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculated travel time to GPs, pharmacies, and sports facilities #16

Merged
merged 7 commits into from
Jan 30, 2025

Conversation

matthewgthomas
Copy link
Member

No description provided.

Copy link
Member

@MikeJohnPage MikeJohnPage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the GP, pharmacies and sport centre scripts use almost identical logic, it would make a lot of sense to extract this code out into functions so that should a change need to be made, it can be made once.

data-raw/healthy-places/travel-time-to-gp.R Show resolved Hide resolved
data-raw/healthy-places/travel-time-to-gp.R Show resolved Hide resolved
data-raw/healthy-places/travel-time-to-gp.R Show resolved Hide resolved
Comment on lines 206 to 212
GP_travel_time_fastest <-
GP_travel_time |>
select(-osm_id) |> # We don't need to know the GP ID for this
group_by(sdz21_code) |>
filter(travel_time_mins == min(travel_time_mins)) |>
ungroup() |>
distinct()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we calculate/use the fastest travel time here. Wouldn't something like the mean be better:

GP_travel_time |>
  select(-osm_id) |> 
  summarize(travel_time_mins = mean(travel_time_mins), .by = "sdz21_code")

Or alternatively, the slowest travel time, so those most in need are covered by the analysis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the England Health Index calculates average minimum distance to travel to the nearest GP/pharmacy/sports centre. Replicating that here, but with travel time instead of distance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the term "average minimum" unclear here. How can something be both an average and a minimum? Do we have access to any code or maths which shows how they calculate this?

I feel like the approach taken in this index isn't quite right. By taking the minimum, is this metric not sensitive to highly skewed left tails on the distribution of travel times? What do you think instead about taking the first quartile mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reading "average minimum" as the average of the minimum travel times/distances for the neighbourhoods within a Local Authority. But appreciate it's unclear. As far as I'm aware, there aren't any detailed technical docs nor code published anywhere.

I take your point about skewed tails. I'll explore the data a bit more this week and have a think about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through the other indicators included in the Health Index, many of them are averages (e.g. crude death rate, percentage of people with (physical health condition), crude crime rates, etc.). For consistency, I'm now wondering whether we should take the mean travel time from neighbourhoods (Super Data Zones, in this case) in each Local Authority. What do you think @MikeJohnPage ?

The travel times from each Super Data Zone to GPs, pharmacies and sports centres are relatively normally distributed:
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you calculate this plot. Is this all travel times from all super data zones per local authority, or the minimum travel ttimes from all super data zones per local authority? I presume the former, but it isn't obvious.

To answer your question I think we need to know how the travel times are distributed within each super data zone. If they are normal, then yes the mean makes more sens than the minimum to me (i.e., I don't think we want to know the best case travel time scenario, but the average...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewgthomas bumping this thread.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right - these are all the travel times from the centroid of each super data zone within each local authority. We don't know how travel times are distributed within a super data zone because we don't have any more spatially granular data (e.g. the equivalents of output areas).

@matthewgthomas
Copy link
Member Author

@MikeJohnPage I've updated the code to calculate mean travel times. Once we merge these changes, I'll change the Scotland Health Index.

@MikeJohnPage MikeJohnPage merged commit 21c5684 into main Jan 30, 2025
@MikeJohnPage MikeJohnPage deleted the travel-times branch January 30, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants