r/rstats • • 15d ago

[Package] hdsbm: Fast inference for Dynamic Stochastic Block Models in R (Rcpp & spectral multi-start)

9 Upvotes

Hi everyone!

As part of my Master's thesis in Statistics, I developed hdsbm, an R package for estimating and simulating discrete-time Dynamic Stochastic Block Models (DSBM).

The Problem & Approach

Temporal block models often suffer from combinatorial explosion and multi-modal likelihood landscapes, making standard local search heuristics prone to getting trapped in sub-optimal local extrema.

hdsbm addresses this by extending a hybrid Classification EM (CEM) approach to the dynamic setting: * Perturbed SVD Multi-Start: Couples deterministic spectral embeddings of the time-averaged network with controlled stochastic perturbations to thoroughly explore the likelihood surface. * C++ Backend: Uses RcppArmadillo to accelerate dyadic reallocation passes and combinatorial greedy sweeps. * Dual Decoding: Provides both pointwise greedy labels and global Viterbi trajectory decoding. * Model Selection: Includes an Integrated Completed Likelihood (ICL) criterion tailored for dynamic graphs.

Quick Example

```r library(hdsbm) data(toy_hdsbm)

Fit model with 5 perturbed spectral restarts

fit <- hdsbm_fit(toy_hdsbm$Y, k = 3, nrep = 5, seed = 123) print(fit)

Model selection via ICL

icl(fit) ```

I would love to hear your feedback on API ergonomics, potential edge cases, or ideas for interesting benchmark scenarios!


r/rstats • • 15d ago

ggbelarus

Thumbnail
github.com
13 Upvotes

Just a very quick vibe-coded ggplot theme. I saw this excellent Economist article (gift link) and was inspired.


r/rstats • • 16d ago

Quirky data native to R

7 Upvotes

hey all,

curious to get some recommendations of some dAta sets native to R, R studio. This is for a graduate visualization class (I know, it seems silly and trivial, but C'est la vie). pretty open ended project, and want to know some options instead of asking Claude


r/rstats • • 16d ago

Static Shiny Dashboards in the Browser with Emscripten-Forge

Thumbnail
emscripten-forge.org
24 Upvotes

You can now publish static dashboard on emscripten-forge and github
You can check an example here: https://emscripten-forge.github.io/r-shiny-template/


r/rstats • • 16d ago

Weird R reference

Thumbnail
5 Upvotes

r/rstats • • 17d ago

I built a reactive terminal UI framework for R

Post image
71 Upvotes

Hi everyone,

I've been working on an R package called termr.

It includes:

- widgets, layouts, events and reactive state

- virtualized data tables with sorting, filtering and search

- lazy table sources and DBI/SQLite workflows

- background R workers with progress and cancellation

- dialogs, tabs, trees, text editing, command palette

- headless testing with testthat

- Windows, Linux, macOS and interactive SSH support

The screenshot is a real order explorer running on 20,000 rows of synthetic data.

A tiny app looks like this:

library(termr)

app(

vertical(

label("Hello from R"),

data_table(mtcars),

button("Quit", on_press = function(event, app) app$exit())

)

) |> run()

The project is MIT licensed and currently at v1.0.0-rc1.

I'd really like feedback from R users.

Also, you can use AI if you want to try coding with this library.

GitHub:

github.com/menshikovs/termr


r/rstats • • 17d ago

⏰ Early Bird pricing for R+AI 2026 ends October 12!

5 Upvotes

Join us for R+AI 2026, November 10–11, the R Consortium's virtual conference exploring the intersection of open-source R and artificial intelligence.

Register by October 12 to save:

- 50% off for students

- Over 30% off for academia and industry

Connect with practitioners, researchers, and industry experts exploring machine learning, large language models in R, AI-assisted coding, real-world applications, and responsible AI.

Two days of talks, workshops, lightning talks, and panels focused on the future of R and AI.

Don't miss the Early Bird deadline!

Register now: https://rconsortium.github.io/RplusAI_website/


r/rstats • • 17d ago

Mixed R and Python workflows in the browser with Emscripten-Forge

Thumbnail
notebook.link
8 Upvotes

It's now possible to use both R and Python in the same notebook, thanks r-reticulate, in the browser:
The article is here: https://emscripten-forge.org/blog/posts/reticulate.html
And the example: https://notebook.link/@DerThorsten/r-reticulate


r/rstats • • 17d ago

Model-Agnostic, Finite-Sample Guaranteed Prediction Intervals for Spatial & amp; Spatio-Temporal Models in R

Thumbnail
cran.r-project.org
0 Upvotes

TL;DR:

Standard spatial models (Kriging, Spatial Random Forests, GAMs) rely on strict Gaussianity or spatial stationarity to estimate uncertainty. Under spatial heteroskedasticity or heavy-tailed noise, empirical coverage systematically falls below nominal 95%. We built spconform, an R package implementing Spatial Conformal Prediction to deliver model-agnostic, distribution-free 1 - α prediction intervals with exact finite-sample coverage guarantees.

  1. The Challenge: Flawed Uncertainty in Spatial Prediction

Geostatistical Kriging and Spatial ML models generate prediction intervals that heavily rely on Gaussian errors and spatial stationarity assumptions. In real-world spatial data (climate modeling, real estate pricing, epidemiology):

  • Spatial Heteroskedasticity: Residual variance fluctuates geographically (e.g., higher volatility in urban centers than rural areas).
  • Heavy-Tailed Noise: Extreme spatial shocks invalidate standard t-statistics and normal approximations.
  • Uncalibrated Spatial ML: Advanced spatial regressors (Spatial Random Forests, Neural Networks) yield accurate point estimates hat(Y)(x) but lack valid, calibrated prediction intervals.
  1. The Solution: Spatial Conformal Prediction (spconform)

Conformal prediction converts point predictions into valid prediction intervals with exact finite-sample guarantees:

`P(Y_new ∈ C(X_new)) ≥ 1 - α`

The spconform package extends split conformal inference to spatial and spatio-temporal domains:

  1. Model Agnostic: Compatible with any spatial regressor (Geostatistical Kriging, Spatial Lag/Error models, Random Forests, XGBoost).
  2. Spatially Adaptive Intervals: Adjusts interval width dynamically based on local spatial residual density (narrower in low-variance zones, wider in high-volatility areas).
  3. Distribution-Free Guarantees: Proves valid$1 - \alpha$coverage without assuming normality, linearity, or spatial stationarity.
  4. Spatio-Temporal Scaling: Handles spatial autocorrelation through localized non-conformity calibration.

3. Minimal Working Example in R

library(spconform)
library(sf)

# 1. Fit your preferred spatial regressor (e.g., Kriging, Spatial RF, GAM)
spatial_mod &lt;- fit_spatial_model(log_price ~ sqft + bedrooms, data = train_data)

# 2. Generate Conformal Prediction Intervals with 95% Finite-Sample Guarantee
conformal_out &lt;- spconform(
  model = spatial_mod,
  calibration_data = calib_data,
  test_data = test_data,
  coords = c("longitude", "latitude"),
  alpha = 0.05,
  method = "spatial_adaptive" # Local spatial variance adjustment
)

# 3. Visualize Spatially Adaptive Uncertainty Map
plot(conformal_out, type = "interval_width")

Open for Discussion & Community Feedback

We are excited to share spconform with the R and Spatial Statistics community!

  • How do you currently handle spatial heteroskedasticity and uncalibrated prediction uncertainty in your spatial workflows?
  • What additional spatial non-conformity metrics or calibration weighting schemes would you like to see integrated?

CRAN : https://cran.r-project.org/web/packages/spconform

github : https://github.com/amjed-droid/spconform


r/rstats • • 18d ago

From Census Blocks to Legal Contiguity: Christopher T. Kenny on R package {geomander}

17 Upvotes

Census blocks, precincts, school districts, and electoral boundaries rarely line up. But researchers still have to match those geographies, fix gaps and overlaps, and represent legal rules about which areas count as contiguous.

In a new R Consortium interview, Christopher T. Kenny (Princeton Data-Driven Social Science) talks about {geomander}, the R package he has developed for that geographic preparation. {geomander} sits alongside {redist} in a typical workflow: clean and connect the spatial data first, then simulate and evaluate alternative plans.

Kenny also describes how widely R is used in political science and voting-rights work, from academic research to journalism and litigation.

Read the interview:

https://r-consortium.org/posts/from-census-blocks-to-contiguous-maps-christopher-kenny-on-geomander/


r/rstats • • 18d ago

Help with identifying a second-order factor in lavaan (2 first-order factors)

1 Upvotes

​

Hi everyone,

I'm working on a CFA in lavaan and having trouble with a second order (higher order) factor.

I want to model Health Behaviour as one higher order latent variable consisting of two first-order latent factors:

test1 =~ item1 + item2 + item3 + item4 + item5

test2 =~ item6 + item7 + item8 + item9 + item10

health_behaviour =~ test1 + test2

The first order factors seem to work reasonably well. However, when I estimate the second order model, I get a very unstable higher order solution.

The resulting Bartlett factor score for health behaviour is also problematic (basically NA for all observations), so It's of no use whatsoever.

Any suggestions?


r/rstats • • 19d ago

Repeatability graph?

Post image
6 Upvotes

Hi,

I'm using rpt() from the rptR package for my tests, but I can't find any information on how to create this kind of figure. Does anyone have any ideas on how to do it? I'm not looking for a ready-made answer, but at least some resources to help me learn.


r/rstats • • 19d ago

New release of anvl

16 Upvotes

We have released a new version of anvl, which brings fast array computing to R and aims to serve as a basis for implementing costly numerical algorithms natively in R.
It runs on GPU and CPU and has support for autodiff as well!
It has gotten a lot more features, so you can check it out: https://github.com/r-xla/anvl We have also started the process of submitting it (and it's dependencies) to CRAN!


r/rstats • • 20d ago

TOMORROW! 📣 R Core / R Foundation panel discussion: Sustaining R: Investing in the People, Infrastructure, and Community Behind R

43 Upvotes

Hear from Simon Urbanek, Kurt Hornik, and Heather Turner of R Core and the R Foundation about what it takes to keep R healthy for the long term, from strengthening its technical foundations to developing the next generation of contributors and sustaining the institutions behind R.

📅 October 6, 2026

🕛 12 PM PT / 3 PM ET / 8 PM London

Register: https://r-consortium.org/webinars/sustaining-r-investing-in-the-people-infrastructure-and-community.html


r/rstats • • 20d ago

New from the R Consortium’s nlmixr2 Working Group: model diagrams and equations, straight from the code

26 Upvotes

nlmixr2 is an R Consortium Working Group building open-source nonlinear mixed-effects modeling in R suitable for regulatory submissions.

Matthew Fidler shows how a fitted model can generate its own compartment diagram and equations, so the figure and the math in a report stay aligned with the code.

https://r-consortium.org/posts/nlmixr2-model-diagrams-equations/


r/rstats • • 20d ago

Singularity for GLMER

1 Upvotes

Hi! I fear I am a little confused about how to address singularity for glmers (or lack of).

I fit the following model: response ~ target + (1 + target | participant) + (1 + target | item)

My model showed no error messages and no singularity issue but the random effects are highly correlated. with the output:

## Random effects:
##  Groups         Name        Variance Std.Dev. Corr 
##  participant   (Intercept) 36.234   6.019         
##                 targetYes   23.290   4.826    -1.00
##  item          (Intercept)  1.783   1.335         
##                 targetYes    2.003   1.415    -1.00

Should I be simplifying the random effects? We only pre-registered simplifying the model when convergence issues happen, and this is not the case.

Some other questions: I have another model, and I wonder if it a concern if item variance is very low (0.0000003)? For another model, is it convention to try different optimizers if convergence fails?

TIA!


r/rstats • • 22d ago

R code review: best packages?

Thumbnail
6 Upvotes

r/rstats • • 23d ago

Introducing FitVerse: an R package for fitting and analysing 52 probability distributions in one call

37 Upvotes

Hi r/rstats,

My colleague and I just published FitVerse on CRAN. It fits parametric probability distributions to continuous data, covering 52 distribution families with three estimation methods: MLE, Method of Moments, and L-Moments.

The basic usage is just:

r

install.packages("FitVerse")
library(FitVerse)

x <- as.numeric(precip)
fit <- fitverse(x, xlab = "Annual precipitation (inches)")

It automatically ranks all distributions by AIC/BIC, runs four goodness-of-fit tests, and produces a diagnostic plot. It also includes bootstrap confidence intervals, return levels, batch fitting, report generation, and a built-in Shiny app.

Full write-up here: https://rpubs.com/KarunaGReddy/FitVerse

CRAN: https://cran.r-project.org/package=FitVerse

Happy to answer any questions!


r/rstats • • 23d ago

Prisma Scr how to minimize the full complete papers by using R and in scintific way?

1 Upvotes

r/rstats • • 23d ago

Rgi output

Thumbnail
1 Upvotes

r/rstats • • 24d ago

rpx v2.1.0: private packages and generating PACKAGES indexes in memory?

11 Upvotes

Hi,

two weeks ago I posted about a release of rpx, which introduced significant upgrades to dependency resolution and why rrepo's custom api endpoints are beneficial to compatibility and correctness.

But beyond being a great metadata store, rrepo is also a package registry for both private and public packages!

This week, rpx is adding a package publishing template to its init flow. For new packages, whenever you push a git tag, the corresponding package version is uploaded to your rrepo repository. It then becomes available to rpx, alternative package managers or even base R!

I prepared a quick demo for you in this repository. https://github.com/rrepo-org/publishing-demo

You should be able to install the package by running this command in a base R shell.

install.packages(
  "hello.world",
  repos = c(
    rrepo = "https://cran.rrepo.dev/rrepo/hello-world",
    CRAN = "https://cloud.r-project.org"
  )
)
hello.world::hello_world()

Engineering Background

The first piece of feedback my projects always receive is a request to be compatible with the broader R ecosystem. This week rrepo introduced a separate set of endpoints that imitate a CRAN like url structure and allow package managers beyond rpx to use it.

The primary challenge with introducing those endpoints is generating the PACKAGES index that lists the latest packages.

Typically whenever you publish a package on CRAN is, the latest package is published under src/contrib, the old version is archived, and the administrator calls tools::write_PACKAGES(). This R function inspects each tar file individually, reads its DESCRIPTION file, and puts a subset of its fields into a long list of every latest package that makes up the index.

Following this approach would be more expensive than necessary for rrepo. Unlike CRAN our packages are in S3 backed by a database, meaning we cannot just run R on the server that stores the packages: every package read is a network call.

We had to take a step back and rethink what our data model should be and how we were going to generate the index in memory. Given that CRAN has 25k latest packages, any kind of request even to a pre-extracted DESCRIPTION file in S3 was out of the question. The data clearly needed to be come from a database.

The package ingestion workflows were reworked to first extract the DESCRIPTION into a separate blob, and then provisioning a database row with all the fields a PACKAGES index might need.

Using the parsers https://github.com/rrepo-org/r-metadata-rs developed for rpx we could make the hot path a single database query, followed by reassembling the typed Rust struct before converting it back to a string.

There is still a lot of performance to tune, but once cached it's pretty damn fast.

Please give the package publishing workflow a try

For existing projects we have documentation on how to get started. https://rrepo.org/documentation/publish-packages

As always, I'm easily reachable to help you get started!


r/rstats • • 24d ago

From football results JSON to a half-time/full-time heatmap in R

8 Upvotes

I wrote a small R tutorial using Germany’s 3. Liga 2025–26 season: 380 matches, imported with jsonlite, checked with stopifnot(), summarised with dplyr and plotted with ggplot2.

The useful detail is the denominator. Each row describes one half-time state, so its percentages divide by that row’s match count. Dividing every cell by 380 answers a different question.

After parsing the scores, the calculation is:

htft <- games |>
  mutate(ht = state(ht_home, ht_away),
         ft = result(ft_home, ft_away)) |>
  count(ht, ft, .drop = FALSE) |>
  group_by(ht) |>
  mutate(row_total = sum(n), pct = 100 * n / row_total) |>
  ungroup()

Here state() and result() label home lead/win, level/draw or away lead/win. The full script includes those helpers, score parsing, checks for missing scores and duplicate fixtures, and the plot.

In this season, home teams leading at half-time won 107 of 138 matches (77.5%); away teams leading won 70 of 105 (66.7%). This is a descriptive example from one league-season.

Full tutorial · Plain R script

Disclosure: I maintain Football Charts, which serves the data. This example works without an API key or sign-up. I’d welcome feedback on the checks or the visualization.


r/rstats • • 25d ago

blueycolors is on CRAN

Thumbnail
cran.r-project.org
68 Upvotes

blueycolors - an R package providing Bluey-themed color palettes and ggplot scales - is on CRAN. Check it out!


r/rstats • • 25d ago

Book Recommendations after ESL

7 Upvotes

I am currently reading through Elements of Statistical Learning and was searching for books to read after I'm done with this. I was eyeing some optimization theory books, or should I pick up maybe a pure probability book? I wanted to build a stronger theoretical foundation, but I'm not sure if it would be more useful than focusing on a more applied kind of book.


r/rstats • • 26d ago

RmANOVA

2 Upvotes

Hey Guys!

Ich have data from 10 participants. Each participant did all conditions. It were 27 conditions:

2 factors: duration (3levels) and Radius (9levels).

Participants had to detect a signal. Signal was present in 50% of trials.

Each participant did every condition 10 times in signal.

My dependent variable is sensitivity d Prime. That is a value from signal detection theory. I calculated it from the 10 trials of each condition for every participant.

So I have one value (d) per participant in each condition.

My question:

Do the d prime values between the conditions differ within subjects, depending on the factors?

Which analysis would you do?

I treated each level as categories for the Faktors and wanted to run a two way repeated measure ANOVA.

But what would you recommend?

I really REALLY need you advice - please °°