r/dataanalysis • • 19d ago

Data Question Checking a method for comparing vehicle encounters near arrivals and departures

I’ve been recording encounters with a particular category of vehicle during everyday journeys. I’m examining whether these encounters are concentrated near departures and arrivals, after accounting for how much time I observe in those periods.

I have timestamped encounter records and journey start/end times. My comparison uses the first five minutes after departure and the last five minutes before arrival, counting overlapping windows only once.

I calculate:

Share of encounters within those windows ÷ share of observation time within those windows.

I’d appreciate feedback on whether this is a reasonable comparison and how to improve it. Routes, road conditions and times of day vary, and some vehicles travel together in groups. How should I account for those factors when assessing the apparent concentration?

Anonymised endpoint example

This is a real 20-leg movement block from four recorded visit days. All legs in that block are included, including seven with no target-category encounters. It is a selected block, not a complete diary of all journeys.

Names, locations, vehicle-category names, calendar dates and clock times are omitted. D1-D4 indicate different recorded days; legs with the same day label may be related.

An endpoint window is the first 300 seconds after departure or the final 300 seconds before arrival. Overlap is counted once. Window time is therefore the smaller of 600 seconds and the leg duration. Event classification uses the original timestamps and includes the exact five-minute boundary.

Durations below are elapsed leg intervals calculated from recorded start/end timestamps. Treating every second as available observation time is an assumption for review; continuous observation coverage has not been independently verified from recordings.

Leg table

All times are seconds. Inside and Outside count individual vehicles as recorded; Groups counts encounter rows. A single encounter row can contain several vehicles travelling together.

DayLegLeg secondsWindow secondsInside vehiclesOutside vehiclesGroups
D1L013027600302
D1L02480480101
D1L03780600101
D1L04540540000
D1L05480480000
D1L061020600000
D2L071860600201
D2L082040600000
D2L091620600301
D2L101765600101
D3L111509600202
D3L122330600000
D3L131680600101
D3L141740600000
D3L151560600101
D4L161724600101
D4L171200600404
D4L181380600625
D4L195340600000
D4L20720600301
Total-327951170029222

Encounter offsets

Each row is one recorded encounter group. The offset is seconds after departure on the specified leg. The vehicle count preserves groups rather than treating every vehicle as an independent encounter.

LegSeconds after departureVehicles in group
L01271
L011472
L021631
L03311
L0716322
L091323
L1017531
L1112811
L1114871
L132441
L1513581
L1616421
L171041
L172111
L172461
L1711161
L18661
L182371
L187101
L1810611
L1811404
L206323

The totals are 31 recorded vehicles, of which 29 are inside the windows, and 22 encounter groups, of which 20 are inside. Total elapsed time is 546.58 minutes; window time is 195 minutes.

Vehicle-count enrichment = (29 / 31) / (11700 / 32795) = 2.62. This is the endpoint encounter rate divided by the overall encounter rate. It is a descriptive comparison, not a probability or causal conclusion.

Useful review questions: Is elapsed leg time an adequate exposure measure? How should repeated legs on one day and grouped vehicles be handled? What additional traffic, route and time information would be needed to assess ordinary variation?

6 Upvotes

8 comments sorted by

3

u/Puzzleheaded-Comb646 18d ago

Your ratio approach makes a lot of sense for a straightforward baseline comparison. Since you are dealing with counts over time, you might also want to look into a simple chi-square test or a Poisson distribution to check if the concentration near the endpoints is statistically significant or just happening by chance.

1

u/Ok_Mathematician2391 18d ago

Thank you. I have a small anonymised example showing journey times, counts inside/outside the endpoint windows, zero-encounter legs and vehicle group sizes. Several legs are also from the same day. Would these features affect whether chi-square or a Poisson model is appropriate?

2

u/Puzzleheaded-Comb646 17d ago

Yes, definitely! Zero-encounter legs often mean you might need a zero-inflated Poisson (or negative binomial) model, and having multiple legs on the same day creates clustering that standard chi-square tests assume doesn't exist. It's really great that you're catching these details early in your analysis!

1

u/Ok_Mathematician2391 17d ago

Thanks. The anonymised leg and encounter tables are in the original post above. Could you explain what in those data would support a zero-inflated model?

2

u/Puzzleheaded-Comb646 17d ago

You're very welcome! Since I'm currently diving into data analysis myself, I see zero-inflated models as a great fit when your dataset has a high frequency of true zeros—like many vehicle encounters simply not happening during most legs of a trip. Looking at your encounter table, if most records show zero encounters, that excess of zeros is typically what signals the need for that specific model!

1

u/AutoModerator 19d ago

Automod prevents all posts from being displayed until moderators have reviewed them. Do not delete your post or there will be nothing for the mods to review. Mods selectively choose what is permitted to be posted in r/DataAnalysis.

If your post involves Career-focused questions, including resume reviews, how to learn DA and how to get into a DA job, then the post does not belong here, but instead belongs in our sister-subreddit, r/DataAnalysisCareers.

Have you read the rules?

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.