maritime_did_speed_test
Tests whether the difference between eastbound and westbound sailing speeds changed significantly between two time periods, using bootstrap resampling to isolate wind changes from symmetric technology improvements.
Instructions
Formal 2x2 Difference-in-Differences test: direction x period.
Tests whether the difference between eastbound and westbound speeds changed significantly between two time periods. A significant DiD means one direction gained more than the other — isolating wind changes from symmetric technology improvements.
DiD = (period2_east - period1_east) - (period2_west - period1_west)
Uses bootstrap resampling for confidence intervals and p-values. Defaults to voyage-level aggregation for statistically independent samples (daily observations within a voyage are autocorrelated).
Args: period1_years: First period as "YYYY/YYYY" range or "YYYY,YYYY,..." list period2_years: Second period as "YYYY/YYYY" range or "YYYY,YYYY,..." list lat_min: Minimum latitude for position bounding box lat_max: Maximum latitude for position bounding box lon_min: Minimum longitude for position bounding box lon_max: Maximum longitude for position bounding box nationality: Filter tracks by nationality code month_start: Filter by start month (1-12). Supports wrap-around month_end: Filter by end month (1-12). Used with month_start aggregate_by: "voyage" (default, independent samples) or "observation" (more data but autocorrelated) n_bootstrap: Bootstrap iterations (default: 10000) min_speed_km_day: Minimum speed filter (default: 5.0) max_speed_km_day: Maximum speed filter (default: 400.0) wind_force_min: Minimum Beaufort force (0-12). Requires wind data wind_force_max: Maximum Beaufort force (0-12). Requires wind data exclude_years: Years to exclude from both periods, as "YYYY/YYYY" range or "YYYY,YYYY,..." list. output_mode: Response format - "json" (default) or "text"
Returns: JSON or text with 4-cell summary, marginal diffs, DiD estimate, bootstrap 95% CI, and p-value
Tips for LLMs: - Always splits by direction (eastbound vs westbound) - Use lat_min=-50, lat_max=-30 for the Roaring Forties - Positive DiD = eastbound gained more = wind strengthened - Use wind_force_min/max for Beaufort-stratified DiD - Default aggregate_by="voyage" gives correct p-values - If DiD scales with Beaufort, that is genuine wind change - Periods accept comma-separated year lists for non-contiguous years (e.g., "1720,1728,1747" for ENSO El Nino years)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period1_years | Yes | ||
| period2_years | Yes | ||
| lat_min | No | ||
| lat_max | No | ||
| lon_min | No | ||
| lon_max | No | ||
| nationality | No | ||
| month_start | No | ||
| month_end | No | ||
| aggregate_by | No | voyage | |
| n_bootstrap | No | ||
| min_speed_km_day | No | ||
| max_speed_km_day | No | ||
| wind_force_min | No | ||
| wind_force_max | No | ||
| exclude_years | No | ||
| output_mode | No | json |