The main function of the package - uses bootstrap resampling to run fantasy football season simulations supported by historical rankings and nflfastR data, calculating optimal lineups, and returns aggregated results.

ff_simulate(
  conn,
  n_seasons = 100,
  n_weeks = 14,
  best_ball = FALSE,
  seed = NULL,
  gp_model = c("simple", "none"),
  base_seasons = 2012:2020,
  actual_schedule = FALSE,
  pos_filter = c("QB", "RB", "WR", "TE", "K"),
  verbose = getOption("ffsimulator.verbose", default = TRUE)
)

Arguments

conn

an connection to a league made with ff_connect() and friends (required)

n_seasons

number of seasons to simulate, default = 100

n_weeks

number of weeks per season, default = 14

best_ball

a logical: are weekly wins based on optimal lineups?

seed

an integer to control reproducibility

gp_model

select between "simple", "none" to apply a model for whether a player played in a given game, defaults to "simple"

base_seasons

a numeric vector that selects seasons as base data, earliest available is 2012

actual_schedule

a logical: use actual ff_schedule? default is FALSE

pos_filter

a character vector of positions to filter/run, default is c("QB","RB","WR","TE","K")

verbose

a logical: print status messages? default is TRUE, configure with options(ffsimulator.verbose)

Value

an ff_simulation object which can be passed to plot() and contains the output data from the simulation.

See also

vignette("basic") for example usage

vignette("custom") for examples on using the subfunctions for your own processes.

Examples

# \donttest{ conn <- mfl_connect(2021, 22627) ff_simulate(conn, n_seasons = 25)
#> ── Starting simulation 2021-09-19 01:00:51 ─────────────────────────────────────
#> Importing data
#> Importing data...done! 2021-09-19 01:01:19
#>
#> Generating Projections
#> Generating Projections...done! 2021-09-19 01:01:19
#>
#> Calculating Roster Scores
#> Calculating Roster Scores...done! 2021-09-19 01:01:19
#>
#> Optimizing Lineups
#> Optimizing Lineups...done! 2021-09-19 01:01:23
#>
#> Building Schedules
#> Building Schedules...done! 2021-09-19 01:01:23
#>
#> Summarising Simulation Data
#> Summarising Simulation Data...done! 2021-09-19 01:01:23
#>
#> ── Simulation complete! 2021-09-19 01:01:23 ────────────────────────────────────
#> <ff_simulation: 25 simulated seasons of Four-Eight Dynasty League> #> List of 7 #> $ summary_simulation:Classes ‘data.table’ and 'data.frame': 12 obs. of 11 variables: #> $ summary_season :Classes ‘data.table’ and 'data.frame': 300 obs. of 12 variables: #> $ summary_week :Classes ‘data.table’ and 'data.frame': 4200 obs. of 16 variables: #> $ roster_scores :Classes ‘data.table’ and 'data.frame': 112350 obs. of 23 variables: #> $ projected_scores :Classes ‘data.table’ and 'data.frame': 112350 obs. of 14 variables: #> $ league_info : tibble [1 × 17] (S3: tbl_df/tbl/data.frame) #> $ simulation_params :List of 9
# }