Skip to content

Commit

Permalink
fix a couple of typos
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinsimpson committed Dec 20, 2024
1 parent 2c91de5 commit abe3bc6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
13 changes: 8 additions & 5 deletions paper.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors:
orcid: 0000-0002-9084-8413
affiliation: 1
affiliations:
- name: Department of Animal and Veterinary Science, Aarhus University, Denmark
- name: Department of Animal and Veterinary Sciences, Aarhus University, Denmark
index: 1
date: 26 June 2024
citation_author: Simpson
Expand All @@ -25,6 +25,12 @@ journal: JOSS

# Summary

```{r, setup, echo = FALSE, cache = FALSE, results = "hide"}
pkgs <- c("mgcv", "gratia", "ggplot2", "geomtextpath", "dplyr", "tibble", "patchwork")
res <- vapply(pkgs, library, logical(1), character.only = TRUE,
logical.return = TRUE)
```

Generalized additive models [GAMs, @Hastie1990-bx; @Wood2017-qi] are an extension of generalized linear models that allows the effects of covariates to be modelled as smooth functions. GAMs are increasingly used in many areas of science [e.g. @Pedersen2019-ff; @Simpson2018-wc] because the smooth functions allow nonlinear relationships between covariates and the response to be learned from the data through the use of penalized splines. Within the R [@rcore2024] ecosystem, Simon Wood's *mgcv* package [@Wood2017-qi] is widely used to fit GAMs and is a *Recommended* package that ships with R as part of the default install. A growing number of other R packages build upon *mgcv*, for example as an engine to fit specialised models not handled by *mgcv* itself [e.g. *GJMR*, @Marra2023-gjrm], or to make use of the wide range of splines available in *mgcv* [e.g. *brms*, @Burkner2017-ms].

The *gratia* package builds upon *mgcv* by providing functions that make working with GAMs easier. *gratia* takes a *tidy* approach [@Wickham2014-ev] providing *ggplot2* [@Wickham2016-dg] replacements for *mgcv*'s base graphics-based plots, functions for model diagnostics and exploration of fitted models, and a family of functions for drawing samples from the posterior distribution of a fitted GAM. Additional functionality is provided to facilitate the teaching and understanding of GAMs. The overall aim of *gratia* is to abstract away some of the complexity of working with GAMs fitted using *mgcv* to allow researchers to focus on using and interrogating their model rather than the technical R programming needed to achieve this.
Expand Down Expand Up @@ -55,9 +61,6 @@ $$
with additive Gaussian noise ($\mu = 0, \sigma = 1$), and the associated penalty matrix, prepared using functions from *gratia*.

```{r penalised-spline-basis-and-penalty, echo = FALSE, fig.height = 5, fig.width = 10, fig.cap = "\\label{fig:basis-funs}Basis functions (a) and associated penalty matrix (b) for a penalised, low rank, thin plate regression spline. a) shows the individual basis functions (thin coloured lines; numbers indicate which basis function each line represents) multiplied by their respective model coefficients, as well as the data (black points) to which the GAM was fitted. The estimated smooth is shown as the thick grey line. b) shows the penalty matrix for the basis shown in a). Note the 9th basis function (labelled 'F9', which is the linear function at the lower left to upper right in a), is not affected by the penalty as it has 0 second derivative everywhere, and hence the resulting penalty for this function is 0.", fig.pos = "t!"}
pkgs <- c("mgcv", "gratia", "ggplot2", "geomtextpath", "dplyr", "tibble", "patchwork")
res <- vapply(pkgs, library, logical(1), character.only = TRUE,
logical.return = TRUE)
# simulate data
sim_d <- tibble(x = withr::with_seed(1234, runif(100))) |>
mutate(
Expand Down Expand Up @@ -243,7 +246,7 @@ The posterior distribution of average chlorophyll *a* is summarised using `media

# Conclusion

*gratia* provides a range of functionality to make working with estimated GAMs easier for users. It is designed to take some of the pain out of working with models, simplifying plotting of smooths and related features (differences, derivatives) and exposing the powerful machinery of the *mgcv* package without the need for a deep understanding of GAMs, splines, and the inner structure of *mgcv*'s model objects. As such, it provides a useful addition for anyone wanting to use GAMs in their data analyses without requiring them to be a GAM expert.
*gratia* provides a range of functionality to make working with estimated GAMs easier for users. It is designed to take some of the pain out of working with models, simplifying plotting of smooths and related features (differences, derivatives) and exposes the powerful machinery of the *mgcv* package without the need for a deep understanding of GAMs, splines, and the inner structure of *mgcv*'s model objects. As such, it provides a useful addition for anyone wanting to use GAMs in their data analyses without requiring them to be a GAM expert.

# Acknowledgements

Expand Down
8 changes: 5 additions & 3 deletions paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors:
orcid: 0000-0002-9084-8413
affiliation: 1
affiliations:
- name: Department of Animal and Veterinary Science, Aarhus University, Denmark
- name: Department of Animal and Veterinary Sciences, Aarhus University, Denmark
index: 1
date: 26 June 2024
citation_author: Simpson
Expand All @@ -25,6 +25,8 @@ journal: JOSS

# Summary



Generalized additive models [GAMs, @Hastie1990-bx; @Wood2017-qi] are an extension of generalized linear models that allows the effects of covariates to be modelled as smooth functions. GAMs are increasingly used in many areas of science [e.g. @Pedersen2019-ff; @Simpson2018-wc] because the smooth functions allow nonlinear relationships between covariates and the response to be learned from the data through the use of penalized splines. Within the R [@rcore2024] ecosystem, Simon Wood's *mgcv* package [@Wood2017-qi] is widely used to fit GAMs and is a *Recommended* package that ships with R as part of the default install. A growing number of other R packages build upon *mgcv*, for example as an engine to fit specialised models not handled by *mgcv* itself [e.g. *GJMR*, @Marra2023-gjrm], or to make use of the wide range of splines available in *mgcv* [e.g. *brms*, @Burkner2017-ms].

The *gratia* package builds upon *mgcv* by providing functions that make working with GAMs easier. *gratia* takes a *tidy* approach [@Wickham2014-ev] providing *ggplot2* [@Wickham2016-dg] replacements for *mgcv*'s base graphics-based plots, functions for model diagnostics and exploration of fitted models, and a family of functions for drawing samples from the posterior distribution of a fitted GAM. Additional functionality is provided to facilitate the teaching and understanding of GAMs. The overall aim of *gratia* is to abstract away some of the complexity of working with GAMs fitted using *mgcv* to allow researchers to focus on using and interrogating their model rather than the technical R programming needed to achieve this.
Expand Down Expand Up @@ -214,13 +216,13 @@ fs |> # take the posterior draws
## # A tibble: 1 x 6
## chl_a .lower .upper .width .point .interval
## <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 0.932 0.757 1.17 0.95 median qi
## 1 1.07 0.870 1.33 0.95 median qi
```
The posterior distribution of average chlorophyll *a* is summarised using `median_qi()` from the *ggdist* package [@Kay2024-rv; @Kay2024-uj]. While we could use the base R function `quantile()` to compute the interval, the use of `median_qi()` illustrates how *gratia* tries to interact with other packages.

# Conclusion

*gratia* provides a range of functionality to make working with estimated GAMs easier for users. It is designed to take some of the pain out of working with models, simplifying plotting of smooths and related features (differences, derivatives) and exposing the powerful machinery of the *mgcv* package without the need for a deep understanding of GAMs, splines, and the inner structure of *mgcv*'s model objects. As such, it provides a useful addition for anyone wanting to use GAMs in their data analyses without requiring them to be a GAM expert.
*gratia* provides a range of functionality to make working with estimated GAMs easier for users. It is designed to take some of the pain out of working with models, simplifying plotting of smooths and related features (differences, derivatives) and exposes the powerful machinery of the *mgcv* package without the need for a deep understanding of GAMs, splines, and the inner structure of *mgcv*'s model objects. As such, it provides a useful addition for anyone wanting to use GAMs in their data analyses without requiring them to be a GAM expert.

# Acknowledgements

Expand Down
Binary file modified paper_files/figure-latex/m1-appraise-1.pdf
Binary file not shown.
Binary file modified paper_files/figure-latex/m2-appraise-1.pdf
Binary file not shown.
Binary file modified paper_files/figure-latex/m2-draw-1.pdf
Binary file not shown.
Binary file modified paper_files/figure-latex/penalised-spline-basis-and-penalty-1.pdf
Binary file not shown.

0 comments on commit abe3bc6

Please sign in to comment.