“glmnet (Friedman et al. 2010) is a powerful R package for learning sparse models in supervised learning, but only its most basic capabilities are widely used. This book describes the full range of glmnet’s capabilities and provides code which readers can adapt for their own purposes.”
Tag: statistics
Two thirds of straight women are unwilling to date a bisexual man
{performance} package – model checking
The performance package computes indices of model quality and goodness of fit, including \(R^2\) (including for LMMs), RMSE, ICCs, and tests for overdispersion, zero-inflation, convergence, and singularity. It also simplifies posterior predictive checks for every model with a simulate function.
Trying elastic net regularisation with correlated predictors
First simulate data where \(x_1\) to \(x_3\) are identical and \(x_4\) is uncorrelated with them. Each \(x\) is a z-score.
Set \(y = 0.2 (x_1 + x_2 + x_3) + 0.3 x_4 + \epsilon\).
Now try elastic nets, varying \(\alpha\) from 0 (ridge regression) to 1 (lasso). I used 10‑fold cross‑validation to select \(\lambda\), keeping the coefficients for the smallest \(\lambda\), and used the same fold assignments across all values of \(\alpha\).
Here’s a picture of the coefficients. Note how the correlated predictor slopes separate as \(\alpha\) increases until only one survives with a slope of about three times 0.2 (to compensate for the other missing identical predictors). The uncorrelated predictor slope stays the same.

Here’s a table of coefficients for a selection of \(\alpha\), including the results from an unpenalised regression with only \(x_1\) and \(x_4\) as predictors:
| Variable | α = 0 | α = 0.9 | α = 1 | Unpenalised regression |
|---|---|---|---|---|
| (Intercept) | 0.002 | 0.002 | 0.002 | 0.002 |
| x1 | 0.198 | 0.243 | 0.600 | 0.603 |
| x2 | 0.196 | 0.188 | ||
| x3 | 0.195 | 0.169 | ||
| x4 | 0.271 | 0.287 | 0.287 | 0.290 |
Testing 1 2 3 (4 5 6 7 8 …)
When should you adjust p‑values or confidence intervals for multiple testing? It’s a complicated (and often painful) question, with the wide continuum of possible answers depicted below by Susan Ahmed (1991):

I haven’t met anyone who’s an ultra conservative (on this dimension), but it may be an interesting exercise to estimate how many statistical tests you’re likely to use in a lifetime and what, e.g., a lifetime Bonferroni penality would do to your career.
Sabine Hoffmann and colleagues (2026) offer a helpful guide on what to do. They summarise their principle as follows: “multiple testing should be adjusted for if and only if authors, when reporting and interpreting their findings, put more emphasis on the results of one or several of the tests because of their small p‑value(s)” (p. 3).
This criterion of emphasis applies throughout your reporting, from the title and abstract through to the depths of the results section and discussion. They illustrate this using the example of a study that tested the impact of seven vitamins on mortality (p. 8).
Suppose you find two statistically significant findings out of seven.
If your title were “Vitamin D and vitamin B12 are independent risk factors for all‑cause mortality”, then you need to adjust.
If your title were “Two out of seven vitamins are independent risk factors for all‑cause mortality”, then you don’t.
References
Ahmed, S. W. (1991). Issues arising in the application of Bonferroni procedures in federal surveys. ASA Proceedings of the Survey Research Methods Section, 344–349.
Hoffmann, S., Lemster, S., Collins, G., Hapfelmeier, A., Heinze, G., Mayr, A., Schmid, M., Wilcke, J. C., & Boulesteix, A. (2026). When to Adjust for Multiple Testing: A Unifying Guiding Principle. Biometrical Journal, 68(4), e70148.
Where UK gets its gas (2024)
From the Digest of UK Energy Statistics (DUKES): natural gas, last updated July 2025.
Gas imports:

Flows of natural gas from production and imports through to consumption:

The UK’s most important import pipeline:

Religion in England and Wales (2011 and 2021 census data)
I bet this doesn’t match people’s intuitions – particularly given the volume of media coverage. Data here.

Deaths in immigration detention
The latest statistics are available up to end of 2024 here (tab Det_05b has a breakdown by centre):
| Year | Number | Sex | Age | Nationality | Cause of death | Place of incident | Place of death |
|---|---|---|---|---|---|---|---|
| 2017 | 1 | Male | 18 to 29 | Poland | Self-inflicted | Morton Hall IRC | In detention |
| 2017 | 1 | Male | 30 to 49 | Poland | Other | The Verne IRC | In the community |
| 2017 | 1 | Male | 30 to 49 | Slovenia | Self-inflicted | The Verne IRC | In detention |
| 2017 | 1 | Male | 18 to 29 | Poland | Self-inflicted | Harmondsworth IRC | In the community |
| 2017 | 1 | Male | 50 to 69 | China | Natural causes | Dungavel IRC | In detention |
| 2017 | 1 | Male | 30 to 49 | Jamaica | Natural causes | Morton Hall IRC | In the community |
| 2017 | 1 | Male | 18 to 29 | Iraq | Self-inflicted | Morton Hall IRC | In detention |
| 2018 | 1 | Male | 50 to 69 | Algeria | Natural causes | Harmondsworth IRC | In detention |
| 2019 | 1 | Male | 30 to 49 | Nigeria | Other | Harmondsworth IRC | In detention |
| 2020 | 0 | ||||||
| 2021 | 1 | Male | 30 to 49 | Czechia | Self-inflicted | Morton Hall IRC | In detention |
| 2021 | 1 | Male | 30 to 49 | Romania | Natural causes | Dungavel IRC | In the community |
| 2022 | 1 | Male | 30 to 49 | Iraqi | Natural causes | Manston STHF | In the community |
| 2023 | 1 | Male | 30 to 49 | Columbia | Self-inflicted | Colnbrook IRC | In detention |
| 2023 | 1 | Male | 30 to 49 | Albania | Self-inflicted | Brook House IRC | In the community |
| 2024 | 1 | Male | 18 to 29 | France | Natural causes | Brook House IRC | In detention |
The stats for 2025 are due to be published 27 August 2026. Release dates are in the Research and statistics calendar.
Correcting for multiplicity in the {emmeans} package
Blog post by Andrea Onofri, using {emmeans}, comparing Tukey’s HSD with the multivariate t. Code replicated here.
Lots of useful vignettes on the package page, including for interactions, LMMs, and svyglm.
