-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mythbusters.qmd
564 lines (455 loc) · 22.3 KB
/
mythbusters.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# Mythbusters: Putting Fantasy Football Beliefs/Anecdotes to the Test {#sec-mythbusters}
## Getting Started {#sec-mythbustersGettingStarted}
### Load Packages {#sec-mythbustersLoadPackages}
```{r}
library("petersenlab")
library("nflreadr")
library("lme4")
library("lmerTest")
library("MuMIn")
library("emmeans")
library("tidyverse")
```
### Specify Package Options {#sec-mythbustersPackageOptions}
```{r}
emm_options(lmerTest.limit = 100000)
emm_options(pbkrtest.limit = 100000)
```
### Load Data {#sec-mythbustersLoadData}
```{r}
#| eval: false
#| include: false
load(file = "./data/nfl_playerContracts.RData")
load(file = file.path(path, "/OneDrive - University of Iowa/Teaching/Courses/Fantasy Football/Data/player_stats_weekly.RData", fsep = ""))
load(file = file.path(path, "/OneDrive - University of Iowa/Teaching/Courses/Fantasy Football/Data/player_stats_seasonal.RData", fsep = ""))
load(file = "./data/nfl_espnQBR_seasonal.RData")
load(file = "./data/nfl_espnQBR_weekly.RData")
```
```{r}
load(file = "./data/nfl_playerContracts.RData")
load(file = "./data/player_stats_weekly.RData")
load(file = "./data/player_stats_seasonal.RData")
load(file = "./data/nfl_espnQBR_seasonal.RData")
load(file = "./data/nfl_espnQBR_weekly.RData")
```
We created the `player_stats_weekly.RData` and `player_stats_seasonal.RData` objects in @sec-calculatePlayerAge.
## Do Players Perform Better in their Contract Year? {#sec-contractYear}
Considerable speculation exists regarding whether players perform better in their last year of their contract (i.e., their "contract year").
Fantasy football talking heads and commentators frequently discuss the benefit of selecting players who are in their contract year, because it supposedly means that player has more motivation to perform well so they get a new contract and get paid more.
To our knowledge, no peer-reviewed studies have examined this question for football players.
One study found that National Basketball Association (NBA) players improved in field goal percentage, points, and player efficiency rating (but not other statistics: rebounds, assists, steals, or blocks) from their pre-contract year to their contract year, and that Major League Baseball (MLB) players improved in runs batted in (RBIs; but not other statistics: batting average, slugging percentage, on base percentage, home runs, fielding percentage) from their pre-contract year to their contract year [@White2014a].
Other casual analyses have been examined contract-year performance of National Football League (NFL) players, including articles in [2012](https://www.4for4.com/2012/preseason/2012-contract-year-players-and-myth-increased-production) (archived [here](https://perma.cc/CT3F-QN5E)) and [2022](https://www.4for4.com/2022/preseason/do-players-perform-better-fantasy-football-contract-year) (archived [here](https://perma.cc/F4F5-7RQZ)).
Let's examine the question empirically.
In order to do that, we have to make some assumptions/constraints.
In this example, we will make the following constraints:
- We will determine a player's contract year programmatically based on the year the contract was signed.
For instance, if a player signed a 3-year contract in 2015, their contract would expire in 2018, and thus their contract year would be 2017.
Note: this is a coarse way of determining a player's contract year because it could depend on when during the year the player's contract is signed.
If we were submitting this analysis as a paper to a scientific journal, it would be important to verify each player's contract year.
- We will examine performance in all seasons since 2011, beginning when most data for player contracts are available.
- For maximum [statistical power](#sec-statisticalPower) to detect an effect if a contract year effect exists, we will examine all seasons for a player (since 2011), not just their contract year and their pre-contract year.
- To ensure a more fair, apples-to-apples comparison of the games in which players played, we will examine *per-game* performance (except for yards per carry, which is based on $\frac{\text{rushing yards}}{\text{carries}}$ from the entire season).
- We will examine regular season games only (no postseason).
- To ensure we do not make generalization about a player's performance in a season from a small sample, the player has to play at least 5 games in a given season for that player–season combination to be included in analysis.
For analysis, the same player contributes multiple observations of performance (i.e., multiple seasons) due to the longitudinal nature of the data.
Inclusion of multiple data points from the same player would violate the [assumption of multiple regression](#sec-assumptionsRegression) that all observations are independent.
Thus, we use mixed-effects models that allow nonindependent observations.
In our mixed-effects models, we include a random intercept for each player, to allow our model to account for players' differing level of performance.
We examine two mixed-effects models for each outcome variable: one model that accounts for the effects of age and experience, and one model that does not.
The model that does not account for the effects of age and experience includes:
a) random intercepts to allow the model to estimate a different starting point for each player
a) a fixed effect for whether the player is in a contract year
The model that accounts for the effects of age and experience includes:
a) random intercepts to allow the model to estimate a different starting point for each player
a) random linear slopes (i.e., random effect of linear age) to allow the model to estimate a different form of change for each player
a) a fixed quadratic effect of age to allow for curvilinear effects
a) a fixed effect of experience
a) a fixed effect for whether the player is in a contract year
```{r}
#| code-fold: true
# Subset to remove players without a year signed
nfl_playerContracts_subset <- nfl_playerContracts %>%
dplyr::filter(!is.na(year_signed) & year_signed != 0)
# Determine the contract year for a given contract
nfl_playerContracts_subset$contractYear <- nfl_playerContracts_subset$year_signed + nfl_playerContracts_subset$years - 1
# Arrange contracts by player and year_signed
nfl_playerContracts_subset <- nfl_playerContracts_subset %>%
dplyr::group_by(player, position) %>%
dplyr::arrange(player, position, -year_signed) %>%
dplyr::ungroup()
# Determine if the player played in the original contract year
nfl_playerContracts_subset <- nfl_playerContracts_subset %>%
dplyr::group_by(player, position) %>%
dplyr::mutate(
next_contract_start = lag(year_signed)) %>%
dplyr::ungroup() %>%
dplyr::mutate(
played_in_contract_year = ifelse(
is.na(next_contract_start) | contractYear < next_contract_start,
TRUE,
FALSE))
# Check individual players
#nfl_playerContracts_subset %>%
# dplyr::filter(player == "Aaron Rodgers") %>%
# dplyr::select(player:years, contractYear, next_contract_start, played_in_contract_year)
#
#nfl_playerContracts_subset %>%
# dplyr::filter(player %in% c("Jared Allen", "Aaron Rodgers")) %>%
# dplyr::select(player:years, contractYear, next_contract_start, played_in_contract_year)
# Subset data
nfl_playerContractYears <- nfl_playerContracts_subset %>%
dplyr::filter(played_in_contract_year == TRUE) %>%
dplyr::filter(position %in% c("QB","RB","WR","TE")) %>%
dplyr::select(player, position, team, contractYear) %>%
dplyr::mutate(merge_name = nflreadr::clean_player_names(player, lowercase = TRUE)) %>%
dplyr::rename(season = contractYear) %>%
dplyr::mutate(contractYear = 1)
# Merge with weekly and seasonal stats data
player_stats_weekly_offense <- player_stats_weekly %>%
dplyr::filter(position_group %in% c("QB","RB","WR","TE")) %>%
dplyr::mutate(merge_name = nflreadr::clean_player_names(player_display_name, lowercase = TRUE))
#nfl_actualStats_offense_seasonal <- nfl_actualStats_offense_seasonal %>%
# mutate(merge_name = nflreadr::clean_player_names(player_display_name, lowercase = TRUE))
player_statsContracts_offense_weekly <- dplyr::full_join(
player_stats_weekly_offense,
nfl_playerContractYears,
by = c("merge_name", "position_group" = "position", "season")
) %>%
dplyr::filter(position_group %in% c("QB","RB","WR","TE"))
#player_statsContracts_offense_seasonal <- full_join(
# player_stats_seasonal_offense,
# nfl_playerContractYears,
# by = c("merge_name", "position_group" = "position", "season")
#) %>%
# filter(position_group %in% c("QB","RB","WR","TE"))
player_statsContracts_offense_weekly$contractYear[which(is.na(player_statsContracts_offense_weekly$contractYear))] <- 0
#player_statsContracts_offense_seasonal$contractYear[which(is.na(player_statsContracts_offense_seasonal$contractYear))] <- 0
#player_statsContracts_offense_weekly$contractYear <- factor(
# player_statsContracts_offense_weekly$contractYear,
# levels = c(0, 1),
# labels = c("no", "yes"))
#player_statsContracts_offense_seasonal$contractYear <- factor(
# player_statsContracts_offense_seasonal$contractYear,
# levels = c(0, 1),
# labels = c("no", "yes"))
player_statsContracts_offense_weekly <- player_statsContracts_offense_weekly %>%
dplyr::arrange(merge_name, season, season_type, week)
#player_statsContracts_offense_seasonal <- player_statsContracts_offense_seasonal %>%
# arrange(merge_name, season)
player_statsContractsSubset_offense_weekly <- player_statsContracts_offense_weekly %>%
dplyr::filter(season_type == "REG")
#table(nfl_playerContracts$year_signed) # most contract data is available beginning in 2011
# Calculate Per Game Totals
player_statsContracts_seasonal <- player_statsContractsSubset_offense_weekly %>%
dplyr::group_by(player_id, season) %>%
dplyr::summarise(
player_display_name = petersenlab::Mode(player_display_name),
position_group = petersenlab::Mode(position_group),
age = min(age, na.rm = TRUE),
years_of_experience = min(years_of_experience, na.rm = TRUE),
rushing_yards = sum(rushing_yards, na.rm = TRUE), # season total
carries = sum(carries, na.rm = TRUE), # season total
rushing_epa = mean(rushing_epa, na.rm = TRUE),
receiving_yards = mean(receiving_yards, na.rm = TRUE),
receiving_epa = mean(receiving_epa, na.rm = TRUE),
fantasyPoints = sum(fantasyPoints, na.rm = TRUE), # season total
contractYear = mean(contractYear, na.rm = TRUE),
games = n(),
.groups = "drop_last"
) %>%
dplyr::mutate(
player_id = as.factor(player_id),
ypc = rushing_yards / carries,
contractYear = factor(
contractYear,
levels = c(0, 1),
labels = c("no", "yes")
))
player_statsContracts_seasonal[sapply(player_statsContracts_seasonal, is.infinite)] <- NA
player_statsContracts_seasonal$ageCentered20 <- player_statsContracts_seasonal$age - 20
player_statsContracts_seasonal$ageCentered20Quadratic <- player_statsContracts_seasonal$ageCentered20 ^ 2
# Merge with seasonal fantasy points data
```
### QB {#sec-contractYearQB}
First, we prepare the data by merging and performing additional processing:
```{r}
#| code-fold: true
# Merge with QBR data
nfl_espnQBR_weekly$merge_name <- paste(nfl_espnQBR_weekly$name_first, nfl_espnQBR_weekly$name_last, sep = " ") %>%
nflreadr::clean_player_names(., lowercase = TRUE)
nfl_contractYearQBR_weekly <- nfl_playerContractYears %>%
dplyr::filter(position == "QB") %>%
dplyr::full_join(
.,
nfl_espnQBR_weekly,
by = c("merge_name","team","season")
)
nfl_contractYearQBR_weekly$contractYear[which(is.na(nfl_contractYearQBR_weekly$contractYear))] <- 0
#nfl_contractYearQBR_weekly$contractYear <- factor(
# nfl_contractYearQBR_weekly$contractYear,
# levels = c(0, 1),
# labels = c("no", "yes"))
nfl_contractYearQBR_weekly <- nfl_contractYearQBR_weekly %>%
dplyr::arrange(merge_name, season, season_type, game_week)
nfl_contractYearQBRsubset_weekly <- nfl_contractYearQBR_weekly %>%
dplyr::filter(season_type == "Regular") %>%
dplyr::arrange(merge_name, season, season_type, game_week) %>%
mutate(
player = coalesce(player, name_display),
position = "QB") %>%
group_by(merge_name, player_id) %>%
fill(player, .direction = "downup")
# Merge with age and experience
nfl_contractYearQBRsubset_weekly <- player_statsContractsSubset_offense_weekly %>%
dplyr::filter(position == "QB") %>%
dplyr::select(merge_name, season, week, age, years_of_experience, fantasyPoints) %>%
full_join(
nfl_contractYearQBRsubset_weekly,
by = c("merge_name","season", c("week" = "game_week"))
) %>% select(player_id, season, week, player, everything()) %>%
arrange(player_id, season, week)
#hist(nfl_contractYearQBRsubset_weekly$qb_plays) # players have at least 20 dropbacks per game
# Calculate Per Game Totals
nfl_contractYearQBR_seasonal <- nfl_contractYearQBRsubset_weekly %>%
dplyr::group_by(merge_name, season) %>%
dplyr::summarise(
age = min(age, na.rm = TRUE),
years_of_experience = min(years_of_experience, na.rm = TRUE),
qbr = mean(qbr_total, na.rm = TRUE),
pts_added = mean(pts_added, na.rm = TRUE),
epa_pass = mean(pass, na.rm = TRUE),
qb_plays = sum(qb_plays, na.rm = TRUE), # season total
fantasyPoints = sum(fantasyPoints, na.rm = TRUE), # season total
contractYear = mean(contractYear, na.rm = TRUE),
games = n(),
.groups = "drop_last"
) %>%
dplyr::mutate(
contractYear = factor(
contractYear,
levels = c(0, 1),
labels = c("no", "yes")
))
nfl_contractYearQBR_seasonal[sapply(nfl_contractYearQBR_seasonal, is.infinite)] <- NA
nfl_contractYearQBR_seasonal$ageCentered20 <- nfl_contractYearQBR_seasonal$age - 20
nfl_contractYearQBR_seasonal$ageCentered20Quadratic <- nfl_contractYearQBR_seasonal$ageCentered20 ^ 2
nfl_contractYearQBR_seasonal <- nfl_contractYearQBR_seasonal %>%
group_by(merge_name) %>%
mutate(player_id = as.factor(as.character(cur_group_id())))
nfl_contractYearQBRsubset_seasonal <- nfl_contractYearQBR_seasonal %>%
dplyr::filter(
games >= 5, # keep only player-season combinations in which QBs played at least 5 games
season >= 2011) # keep only seasons since 2011 (when most contract data are available)
```
Then, we analyze the data.
Below is a mixed model that examines whether a player has a higher QBR per game when they are in a contract year compared to when they are not in a contract year.
```{r}
mixedModel_qbr <- lmerTest::lmer(
qbr ~ contractYear + (1 | player_id),
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_qbr)
MuMIn::r.squaredGLMM(mixedModel_qbr)
emmeans::emmeans(mixedModel_qbr, "contractYear")
mixedModelAge_qbr <- lmerTest::lmer(
qbr ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_qbr)
MuMIn::r.squaredGLMM(mixedModelAge_qbr)
emmeans::emmeans(mixedModelAge_qbr, "contractYear")
```
```{r}
mixedModel_ptsAdded <- lmerTest::lmer(
pts_added ~ contractYear + (1 | player_id),
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_ptsAdded)
MuMIn::r.squaredGLMM(mixedModel_ptsAdded)
emmeans::emmeans(mixedModel_ptsAdded, "contractYear")
mixedModelAge_ptsAdded <- lmerTest::lmer(
pts_added ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_ptsAdded)
MuMIn::r.squaredGLMM(mixedModelAge_ptsAdded)
emmeans::emmeans(mixedModelAge_ptsAdded, "contractYear")
```
```{r}
mixedModel_epaPass <- lmerTest::lmer(
epa_pass ~ contractYear + (1 | player_id),
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_epaPass)
MuMIn::r.squaredGLMM(mixedModel_epaPass)
emmeans::emmeans(mixedModel_epaPass, "contractYear")
mixedModelAge_epaPass <- lmerTest::lmer(
epa_pass ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 | player_id), # removed random slopes to address convergence issue
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_epaPass)
MuMIn::r.squaredGLMM(mixedModelAge_epaPass)
emmeans::emmeans(mixedModelAge_epaPass, "contractYear")
```
```{r}
mixedModel_fantasyPtsPass <- lmerTest::lmer(
fantasyPoints ~ contractYear + (1 | player_id),
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_fantasyPtsPass)
MuMIn::r.squaredGLMM(mixedModel_fantasyPtsPass)
emmeans::emmeans(mixedModel_fantasyPtsPass, "contractYear")
mixedModelAge_fantasyPtsPass <- lmerTest::lmer(
fantasyPoints ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 | player_id), # removed random slopes to address convergence issue
data = nfl_contractYearQBR_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_fantasyPtsPass)
MuMIn::r.squaredGLMM(mixedModelAge_fantasyPtsPass)
emmeans::emmeans(mixedModelAge_fantasyPtsPass, "contractYear")
```
### RB {#sec-contractYearRB}
```{r}
#| code-fold: true
player_statsContractsRB_seasonal <- player_statsContracts_seasonal %>%
dplyr::filter(
position_group == "RB",
games >= 5, # keep only player-season combinations in which QBs played at least 5 games
season >= 2011) # keep only seasons since 2011 (when most contract data are available)
```
```{r}
mixedModel_ypc <- lmerTest::lmer(
ypc ~ contractYear + (1 | player_id),
data = player_statsContractsRB_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_ypc)
MuMIn::r.squaredGLMM(mixedModel_ypc)
emmeans::emmeans(mixedModel_ypc, "contractYear")
mixedModelAge_ypc <- lmerTest::lmer(
ypc ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = player_statsContractsRB_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_ypc)
MuMIn::r.squaredGLMM(mixedModelAge_ypc)
emmeans::emmeans(mixedModelAge_ypc, "contractYear")
```
```{r}
mixedModel_epaRush <- lmerTest::lmer(
rushing_epa ~ contractYear + (1 | player_id),
data = player_statsContractsRB_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_epaRush)
MuMIn::r.squaredGLMM(mixedModel_epaRush)
emmeans::emmeans(mixedModel_epaRush, "contractYear")
mixedModelAge_epaRush <- lmerTest::lmer(
rushing_epa ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = player_statsContractsRB_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_epaRush)
MuMIn::r.squaredGLMM(mixedModelAge_epaRush)
emmeans::emmeans(mixedModelAge_epaRush, "contractYear")
```
```{r}
mixedModel_fantasyPtsRush <- lmerTest::lmer(
fantasyPoints ~ contractYear + (1 | player_id),
data = player_statsContractsRB_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_fantasyPtsRush)
MuMIn::r.squaredGLMM(mixedModel_fantasyPtsRush)
emmeans::emmeans(mixedModel_fantasyPtsRush, "contractYear")
mixedModelAge_fantasyPtsRush <- lmerTest::lmer(
fantasyPoints ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = player_statsContractsRB_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_fantasyPtsRush)
MuMIn::r.squaredGLMM(mixedModelAge_fantasyPtsRush)
emmeans::emmeans(mixedModelAge_fantasyPtsRush, "contractYear")
```
### WR/TE {#sec-contractYearWRTE}
```{r}
#| code-fold: true
player_statsContractsWRTE_seasonal <- player_statsContracts_seasonal %>%
dplyr::filter(
position_group %in% c("WR","TE"),
games >= 5, # keep only player-season combinations in which QBs played at least 5 games
season >= 2011) # keep only seasons since 2011 (when most contract data are available)
```
```{r}
mixedModel_receivingYards <- lmerTest::lmer(
receiving_yards ~ contractYear + (1 | player_id),
data = player_statsContractsWRTE_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_receivingYards)
MuMIn::r.squaredGLMM(mixedModel_receivingYards)
emmeans::emmeans(mixedModel_receivingYards, "contractYear")
mixedModelAge_receivingYards <- lmerTest::lmer(
receiving_yards ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = player_statsContractsWRTE_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_receivingYards)
MuMIn::r.squaredGLMM(mixedModelAge_receivingYards)
emmeans::emmeans(mixedModelAge_receivingYards, "contractYear")
```
```{r}
mixedModel_epaReceiving <- lmerTest::lmer(
receiving_epa ~ contractYear + (1 | player_id),
data = player_statsContractsWRTE_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_epaReceiving)
MuMIn::r.squaredGLMM(mixedModel_epaReceiving)
emmeans::emmeans(mixedModel_epaReceiving, "contractYear")
mixedModelAge_epaReceiving <- lmerTest::lmer(
receiving_epa ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = player_statsContractsWRTE_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_epaReceiving)
MuMIn::r.squaredGLMM(mixedModelAge_epaReceiving)
emmeans::emmeans(mixedModelAge_epaReceiving, "contractYear")
```
```{r}
mixedModel_fantasyPtsReceiving <- lmerTest::lmer(
fantasyPoints ~ contractYear + (1 | player_id),
data = player_statsContractsWRTE_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModel_fantasyPtsReceiving)
MuMIn::r.squaredGLMM(mixedModel_fantasyPtsReceiving)
emmeans::emmeans(mixedModel_fantasyPtsReceiving, "contractYear")
mixedModelAge_fantasyPtsReceiving <- lmerTest::lmer(
fantasyPoints ~ contractYear + ageCentered20 + ageCentered20Quadratic + years_of_experience + (1 + ageCentered20 | player_id),
data = player_statsContractsWRTE_seasonal,
control = lmerControl(optimizer = "bobyqa")
)
summary(mixedModelAge_fantasyPtsReceiving)
MuMIn::r.squaredGLMM(mixedModelAge_fantasyPtsReceiving)
emmeans::emmeans(mixedModelAge_fantasyPtsReceiving, "contractYear")
```
### QB/RB/WR/TE {#sec-contractYearQBRBWRTE}
```{r}
# Placeholder for model predicting fantasy points
# Include player position as a covariate
```
## Conclusion {#sec-mythbustersConclusion}
::: {.content-visible when-format="html"}
## Session Info {#sec-mythbustersSessionInfo}
```{r}
sessionInfo()
```
:::