Articles by Gavin L. Simpson

Using random effects in GAMs with mgcv

February 2, 2021 | Gavin L. Simpson

There are lots of choices for fitting generalized linear mixed effects models within R, but if you want to include smooth functions of covariates, the choices are limited. One option is to fit the model using gamm() from the mgcv ???? or gamm4() from the gamm4 ????, which use lme() (nlme ????) or ...
[Read more...]

Getting data from the Canada Covid-19 Tracker using R

January 31, 2021 | Gavin L. Simpson

Last semester (Fall 2020) I taught a new course in healthcare data science for the Johnson Shoyama Graduate School in Public Policy. One of the final topics of the course was querying application programming interfaces (APIs) from within R. The example we used was querying data on the Covid 19 pandemic from ...
[Read more...]

Two new versions of gratia released

January 30, 2021 | Gavin L. Simpson

While the Covid-19 pandemic and teaching a new course in the fall put paid to most of my development time last year, some time off work this January allowed me time to work on gratia ???? again. I released 0.5.0 to CRAN in part to fix an issue with tests not running ...
[Read more...]

Extrapolating with B splines and GAMs

June 3, 2020 | Gavin L. Simpson

An issue that often crops up when modelling with generlaized additive models (GAMs), especially with time series or spatial data, is how to extrapolate beyond the range of the data used to train the model? The issue arises because GAMs use splines to learn from the data using basis functions. ...
[Read more...]

gratia 0.4.1 released

May 31, 2020 | Gavin L. Simpson

After a slight snafu related to the 1.0.0 release of dplyr, a new version of gratia is out and available on CRAN. This release brings a number of new features, including differences of smooths, partial residuals on partial plots of univariate smooths, and a number of utility functions, while under the ...
[Read more...]

Rendering your README with GitHub Actions

April 30, 2020 | Gavin L. Simpson

There’s one thing that has bugged me for a while about developing R packages. We have all these nice, modern tools we have for tracking our code, producing web sites from the roxygen documentation, an so on. Yet for every code commit I make to the master branch of ... [Read more...]

Pivoting tidily

October 25, 2019 | Gavin L. Simpson

One of the fun bits of my job is that I have actual time dedicated to helping colleagues and grad students with statistical or computational problems. Recently I’ve been helping one of our Lab Instructors with some data that from their Plant Physiology Lab course. Whilst I was writing ...
[Read more...]

radian: a modern console for R

June 18, 2019 | Gavin L. Simpson

Whenever I’m developing R code or writing data wrangling or analysis scripts for research projects that I work on I use Emacs and its add-on package Emacs Speaks Statistics (ESS). I’ve done so for nigh on a couple of decades now, ever since I switched full time to ...
[Read more...]

Tibbles, checking examples, & character encodings

January 22, 2019 | Gavin L. Simpson

Recently I’ve been preparing my gratia package for submission to CRAN. During my pre-flight testing I noticed an issue under Windows checking the examples in the package against the reference output I generated on linux. In the latest release of the tibble package, the way tibbles are printed has ... [Read more...]

Confidence intervals for GLMs

December 10, 2018 | Gavin L. Simpson

You've estimated a GLM or a related model (GLMM, GAM, etc.) for your latest paper and, like a good researcher, you want to visualise the model and show the uncertainty in it. In general this is done using confidence intervals with typically 95% converage. If you remember a little bit of ...
[Read more...]

Introducing gratia

October 23, 2018 | Gavin L. Simpson

I use generalized additive models (GAMs) in my research work. I use them a lot! Simon Wood’s mgcv package is an excellent set of software for specifying, fitting, and visualizing GAMs for very large data sets. Despite recently dabbling with brms, mgcv is still my go-to GAM package. The ...
[Read more...]

Fitting GAMs with brms: part 1

April 21, 2018 | Gavin L. Simpson

Regular readers will know that I have a somewhat unhealthy relationship with GAMs and the mgcv package. I use these models all the time in my research but recently we’ve been hitting the limits of the range of models that mgcv can fit. So I’ve been looking into ...
[Read more...]

Comparing smooths in factor-smooth interactions II

December 14, 2017 | Gavin L. Simpson

In a previous post I looked at an approach for computing the differences between smooths estimated as part of a factor-smooth interaction using s()’s by argument. When a common-or-garden factor variable is passed to by, gam() estimates a separate smooth for each level of the by factor. Using the (...
[Read more...]

First steps with MRF smooths

October 19, 2017 | Gavin L. Simpson

One of the specialist smoother types in the mgcv package is the Markov Random Field (MFR) smooth. This smoother essentially allows you to model spatial data with an intrinsic Gaussian Markov random field (GMRF). GRMFs are often used for spatial data measured over discrete spatial regions. MRFs are quite flexible ... [Read more...]

First steps with MRF smooths

October 19, 2017 | Gavin L. Simpson

One of the specialist smoother types in the mgcv package is the Markov Random Field (MRF) smooth. This smoother essentially allows you to model spatial data with an intrinsic Gaussian Markov random field (GMRF). GRMFs are often used for spatial data measured over discrete spatial regions. MRFs are quite flexible ...
[Read more...]

Prediction intervals for GLMs part II

May 1, 2017 | Gavin L. Simpson

One of my more popular answers on StackOverflow concerns the issue of prediction intervals for a generalized linear model (GLM). Comments, even on StackOverflow, aren’t a good place for a discussion so I thought I’d post something hereon my blog that went into a bit more detail as ... [Read more...]
1 2 3 4

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)