Skip to contents

Rescales trip rate factors so the minimum value for each trip type is 1, if requested in settings. Use to harmonize trip rates across platforms.

Usage

rescale_trip_rate_factors(raw_factors, settings)

Arguments

raw_factors

data.table with required columns:

  • trip_type — trip type label

  • app_weekday — trip rate factor for app platform, weekday

  • app_weekend — trip rate factor for app platform, weekend

  • web_weekday — trip rate factor for web platform, weekday

  • web_weekend — trip rate factor for web platform, weekend Additional columns as needed for other platforms and day groups Rows: one per trip type. Keys: (trip_type). Modified by reference: no (returns copy).

settings

list. Must include:

  • trip_rate_factor_rescaling — whether to rescale factors

Value

data.table with columns:

  • trip_type — trip type label

  • app_weekday — rescaled trip rate factor for app platform, weekday

  • app_weekend — rescaled trip rate factor for app platform, weekend

  • web_weekday — rescaled trip rate factor for web platform, weekday

  • web_weekend — rescaled trip rate factor for web platform, weekend Additional columns as needed for other platforms and day groups. Rows: one per trip type. Keys: (trip_type). Modified by reference: no (returns copy).

Details

  • Checks settings for trip_rate_factor_rescaling flag.

  • If TRUE, rescales each trip type so minimum factor is 1.

  • Returns a copy; does not modify by reference.

Settings

  • trip_rate_factor_rescaling (direct): If TRUE, rescales factors. Default from settings.

See also

  • extract_trip_rate_factors

  • scripts/weighting/trip_rate_factors.R

Other trip rate modeling: calc_trip_rate_factor(), calculate_aggegrate_trip_rates(), extract_trip_rate_factors(), prepare_trip_adj_model_dt()

Examples

## Not run:
raw_factors <- data.table(trip_type = "auto", app_weekday = 1.2)
settings <- list(trip_rate_factor_rescaling = TRUE)
rescale_trip_rate_factors(raw_factors, settings)
#> Rescaling trip rate factors...
#> Rescaled trip rate factors (if reference factor is not rMove):
#> Key: <trip_type>
#>    trip_type app_weekday
#>       <char>       <num>
#> 1:      auto           1
#> Key: <trip_type>
#>    trip_type app_weekday
#>       <char>       <num>
#> 1:      auto           1
## End(Not run)