Skip to content

Commit 89e144c

Browse files
20250101 - GAM model
1 parent ff2bfa2 commit 89e144c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mixed-models.qmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,8 @@ performance::check_model(pointsPerSeason_positionAgeRandomLinearFixedQuadraticSl
19961996

19971997
#### Generalized Additive Model {#sec-fantasyPointsByAgeExperienceModelsAgeGAM}
19981998

1999+
To fit a generalized additive model, we first determine how many cores are available for multicore processing.
2000+
19992001
```{r}
20002002
#| label: parallel-cores-mixed-models
20012003
#| include: false
@@ -2011,10 +2013,12 @@ num_cores <- parallelly::availableCores() - 1
20112013
num_true_cores <- parallelly::availableCores(logical = FALSE) - 1
20122014
```
20132015

2016+
We fit a generalized additive model using the `mgcv::bam()` function of the `mgcv` package [@R-mgcv; @Wood2017].
2017+
20142018
```{r}
20152019
#| label: gam-mixed-models
20162020
2017-
pointsPerSeason_gam <- bam( # using bam() instead of gam() for faster estimation due to large size of data
2021+
pointsPerSeason_gam <- mgcv::bam( # using bam() instead of gam() for faster estimation due to large size of data
20182022
fantasyPoints ~ positionFactor + s(ageCentered20, by = positionFactor) + years_of_experience + s(player_idFactor, ageCentered20, bs = "re"),
20192023
data = player_stats_seasonal_offense_subset,
20202024
nthreads = num_cores

0 commit comments

Comments
 (0)