My city has recently run a pilot program to mandate that only public transportation use particular sections of the downtown core.
The city has released data about the program. They have sensors at strategic locations across the downtown core to monitor the travel time between segments. The data include:
- The latitude and longitude of the sensor
- A code for the segment (e.g. Yo_Ds_Yo_Ds).
- The time the measurements were made.
- The is the average number of seconds required to travel through a segment. This is a measure of congestion. More time means higher congestion.
The data span 3 months before the pilot began and nearly 8 months after the pilot started. Data is recorded for all hours of the day.
I'm interested in determining how congestion has changed in surrounding areas due to the program coming into effect. I anticipate this will require a smooth in space and time.
The Data and Model
The dataset has 5 columns:
TravelTime-- Avg time in seconds to traverse the segment
Lat/Lon-- coordinates of the sensor
Time-- Time the observation was made
IsProgram-- Binary indicator for if the observation is from the program.
As of now, I use the following to model the data
bam(TravelTime ~ s(Lat,Lon, bs = 'gp', by = IsProgram) + s(Time,bs = 'cc'))
here is my rationale:
I use a bam because I have something like 1,000,000+ observations
IsProgramis a factor indicating if the observation is from when the program was in place. Passing this into the
byargument will allow me to estimate congestion for pre and post program.
I use a
s(Time)to control for the effect of time on congestion. The
ccis because the effect of time is periodic.
Is this a reasonable approach to using GAMS to model this problem? Should I be using a random effects model since I have repeated observations from sensors?
If you need data, I can link to a GitHub repo.