Stefan Hansen
stefanforfan.bsky.social
Stefan Hansen
@stefanforfan.bsky.social
statistician at aarhus university

https://github.com/snhansen
Pinned
I made a Shiny app to showcase the differences between using a linear fit, a categorical fit and a (restricted cubic) spline fit under various data generating mechanisms.

The app is available at: apps.biostat.au.dk/stefan/splin...

Feel free to use it in your teaching #rstats #datascience #statssky
Reposted by Stefan Hansen
New web app to make apaquarto documents (APA style via Quarto)

wjschne.github.io/posts/2025-0...

Direct link:

wjschne.github.io/apa7maker/

#quarto #QuartoPub #rstats
W. Joel Schneider
Announcing a web app for creating apaquarto documents.
wjschne.github.io
September 5, 2025 at 2:27 PM
Reposted by Stefan Hansen
Happy to announce ✨quarto-revealjs-editable✨

This fully supersedes the imagemover extension, as I back then didn't realize the potential. You can now also move, resize, change font size and alignment for text in your slides

github.com/EmilHvitfeld...
#quarto #slidecrafting
August 20, 2025 at 5:39 PM
Vibe-estimanding is my new favorite expression! A concise description of a widespread phenomenon in health science research.
Yeah. Confusing. I do enjoy having conversations when people use language like this to know what they actually mean. Usually what they’re actually doing though is vibe-estimanding
August 21, 2025 at 12:41 PM
Reposted by Stefan Hansen
Now on CRAN, ggdiagram is a #ggplot2 extension that draws diagrams programmatically in #Rstats. Allows for precise control in how objects, labels, and equations are placed in relation to each other.
wjschne.github.io/ggdiagram/ar...
August 20, 2025 at 10:43 AM
Consider the following DAG where both exposure and frailty have positive effects on pregnancy (P) and healthy child (Y). Say, I'm interested in the effect of the exposure on having healthy children in my population. #stats #causalsky #episky #statsky #causalinference
May 27, 2025 at 8:36 AM
I've made my first R package {ciwidth}. It's nothing big, but it lets you calculate the sample size needed for obtaining a confidence interval for a mean or mean difference with a certain width with a given probability. Take a look here: github.com/snhansen/ciw... #rstats #statssky
GitHub - snhansen/ciwidth: Sample size calculations based on confidence intervals
Sample size calculations based on confidence intervals - snhansen/ciwidth
github.com
May 23, 2025 at 5:40 AM
Reposted by Stefan Hansen
I did update the figure a bit and added labels, but it probably works better as sequential slides in a presentation. If you want the code and the pptx just drop me a dm and I’ll send it all your way.
April 10, 2025 at 8:13 AM
Reposted by Stefan Hansen
I've been playing with Quarto shortcodes, so here's a simple CV template that is easily customized using shortcodes and renders quickly/prettily using Typst:

github.com/christopherk...
March 23, 2025 at 3:40 PM
Reposted by Stefan Hansen
Our new work shows the associations between maternal health in pregnancy and autism are attributable to familial confounding. Comprehensive atlas of these associations (>230 dx) + results from sibling comparisons + paternal negative control (DK >1.1M) tinyurl.com/3y4kafu9 @naturemedicine.bsky.social
Familial confounding in the associations between maternal health and autism - Nature Medicine
Using national registry data from Denmark, 30 maternal diagnoses linked to offspring autism were identified with most associations attributable to family-level factors rather than direct causal effect...
tinyurl.com
February 3, 2025 at 2:58 PM
We're already six days into this year's Advent of Code. This is my sixth year participating and I'm having a lot of fun. I'll be posting my crude Python solutions to my GitHub: github.com/snhansen/adv...

Want to join, then go visit adventofcode.com/2024

#adventofcode #python
December 6, 2024 at 9:33 AM
Reposted by Stefan Hansen
This was my tenth(!) year building 25 days of puzzles for #AdventOfCode. You can solve them all for free! Most people write code to solve them, but you can solve them however you like. I hope they help people become better programmers. 🌟

The first puzzle comes out in two hours: adventofcode.com
Advent of Code 2024
adventofcode.com
December 1, 2024 at 2:57 AM
Reposted by Stefan Hansen
Here is a 1-page summary for your wall

This talk is based on our Christmas article from 2022

t.co/y4GVFmTOfs
December 7, 2023 at 11:38 AM
Reposted by Stefan Hansen
With respect, this suggests quite a serious misunderstanding about why we randomise. We do this to ensure imbalances are random. Our analyses treat them as such, and ensure valid inference. The problem here is with the idea that point estimates are useful, rather than with randomisation.
November 26, 2024 at 5:22 PM
Reposted by Stefan Hansen
Quarto 1.6 is out! 🎉 Download it here: quarto.org/docs/download/

Quarto 1.6 supports unified branding across formats, updates to RevealJS, a new shortcode to reorder content, a landscape page block, and more. Blog post: quarto.org/docs/blog/po...
Quarto 1.6 – Quarto
Quarto 1.6 supports unified branding across formats, updates to RevealJS, a new shortcode to reorder content, a landscape page block, and more. There are also a couple of breaking changes that will af...
quarto.org
November 25, 2024 at 8:40 PM
To new users and followers: Here's a Shiny app showing the differences between three ways of including a continuous covariate in linear regression models.

Feel free to use it in your teaching or elsewhere! #rstats #datascience #statssky #stats #epi #episky
I made a Shiny app to showcase the differences between using a linear fit, a categorical fit and a (restricted cubic) spline fit under various data generating mechanisms.

The app is available at: apps.biostat.au.dk/stefan/splin...

Feel free to use it in your teaching #rstats #datascience #statssky
November 14, 2024 at 12:33 PM
Reposted by Stefan Hansen
In clinical research, you will often receive feedback on study design, stats, and/or data analysis from an editor or reviewer that is simply wrong. Here is a list of common "statistical myths" and references you can use to push back.

discourse.datamethods.org/t/reference-...
Reference Collection to push back against "Common Statistical Myths"
Note: This topic is a wiki, meaning that this main body of the topic can be edited by others. Use the Reply button only to post questions or comments about material contained in the body, or to sugge...
discourse.datamethods.org
November 12, 2024 at 6:19 AM
With the recent influx of new users, I wanted to repost some of my Shiny apps that might be helpful to others.

Feel free to use them in your teaching or other projects!
#rstats #datascience #stats
My students often struggle with selection and measurement error bias in linear regression models, so I have made two Shiny apps to help visualize these concepts:

apps.biostat.au.dk/stefan/selec...
apps.biostat.au.dk/stefan/measu...

Feel free to use them in your teaching
#rstats #datascience #stats
November 13, 2024 at 8:44 AM
Reposted by Stefan Hansen
New blog post! I helped build Idaho's official election results website (with #rstats and #quartopub) and we did some neat stuff to auto-generate hundreds of R chunks. Here's a guide about how to create tabsets and slides programmatically with inline knitr chunks www.andrewheiss.com/blog/2024/11...
November 4, 2024 at 2:06 PM
Reposted by Stefan Hansen
A few months ago, I gave a workshop on “(Pretty) big data wrangling with DuckDB and Polars”.

Slides, notebooks etc. are all available here: grantmcdermott.com/duckdb-polars/

#EconSky
August 23, 2024 at 5:40 PM
Reposted by Stefan Hansen
📊When teaching or giving a talk, do you like presenting plots step by step, revealing e.g. one group at a time? This is often useful for walking through complex results.

I made a R package that makes it extremely easy to do this!

ggreveal: Reveal a ggplot incrementally
#rstats #dataviz #ggplot2
Reveal a ggplot incrementally
Provides functions that make it easy to reveal ggplot2 graphs incrementally. The functions take a ggplot2 object and return a list of plots showing data incrementally by panels, layers, groups, the va...
www.weverthon.com
July 24, 2024 at 5:49 PM
When converting RevealJS .html slides made with Quarto to .pdf using the {pagedown} package (or Chrome in general), code chunks are indented by a large margin. Is there a way to remove this indentation? #rstats #quartopub
May 31, 2024 at 1:42 PM
Reposted by Stefan Hansen
Timeless
April 20, 2024 at 9:29 PM
What software do you use to make teaching videos? I'm looking for something simple that can capture my screen and overlay audio. Some editing capabilities would be nice. I've used Camtasia before, but not sure if there is something better out there.
#StatsSky #EpiSky
January 25, 2024 at 6:56 AM
Reposted by Stefan Hansen
New {paletteer} release dropped over the weekend! 159 color palettes have been added from vangogh, ButterflyColors, MoMAColors, PrettyCols, waRhol, MexBrewer, and ltc. Bringing the total to 2759 palettes from 75 different packages 🎨 #rstats

github.com/EmilHvitfeld...
January 22, 2024 at 10:15 PM
Reposted by Stefan Hansen
A meandering post, even for me, on rAnDoM cOnFoUnDiNg.

Will probably regret the title but hey, there it is.
tpmorris.substack.com/p/oxymoronic...
January 16, 2024 at 3:12 PM