Learn R Programming

shinymrp: Applying Multilevel Regression and Poststratification in R

shinymrp allows users to apply Multilevel Regression and Poststratification (MRP) methods to a variety of datasets, from electronic health records to sample survey data, through an end-to-end Bayesian data analysis workflow. Whether you’re a researcher, analyst, or data engineer, shinymrp provides robust tools for data cleaning, exploratory analysis, flexible model building, and insightful result visualization.

  • Data preparation: Clean, preprocess and display the input data.
  • Descriptive statistics: Visualize key summary statistics.
  • Model building: Specify and fit models with various predictors as fixed or varying effects. Guide your model selection with detailed model diagnostics and comparison metrics.
  • Result visualization: Generate graphs to convey population-level and subgroup estimates, facilitating interpretation and communication of your findings.

Getting Started

You can use shinymrp in two flexible ways:

Shiny App

The graphical user interface (GUI), built with the Shiny framework, is designed for newcomers and those looking for an interactive, code-free analysis experience.

Launch the app locally in R with:

shinymrp::run_app()

Try the Demo

Explore the Shiny app without installation via our online demo.

Need a walk-through? Watch our step-by-step video tutorial.

Object-Oriented Programming Interface

Leverage the full flexibility of the exported R6 classes for a programmatic workflow, ideal for advanced users and those integrating MRP into larger R projects.

Import shinymrp in scripts or R Markdown documents just like any other R package:

library(shinymrp)

Installation

Install the latest release from CRAN:

install.packages("shinymrp")

Install the latest development version from GitHub:

# If 'remotes' is not installed:
install.packages("remotes") 
remotes::install_github("mrp-interface/shinymrp")

The package installation does not automatically install all prerequisites. Specifically, shinymrp uses CmdStanR as the bridge to run Stan, a state-of-the-art platform for Bayesian modeling. Stan requires a modern C++ toolchain (compiler and GNU Make build utility).

Learn More

For detailed guidance, check our introductory vignette: Getting started with shinymrp.

This product uses the Census Bureau Data API but is not endorsed or certified by the Census Bureau.

Copy Link

Version

Install

install.packages('shinymrp')

Monthly Downloads

198

Version

0.10.0

License

MIT + file LICENSE

Maintainer

Toan Tran

Last Published

December 4th, 2025

Functions in shinymrp (0.10.0)

MRPWorkflow-method-demo_bars

Create demographic comparison bar plots
MRPModel-method-stan_code

Return model Stan code.
MRPWorkflow-method-outcome_map

Visualize raw outcome measure by geography
MRPWorkflow-method-load_pstrat

Load custom poststratification data
example_model

Return example MRPModel object with estimation results.
MRPWorkflow-method-sample_size_map

Create sample size map
MRPWorkflow

MRPWorkflow objects
MRPWorkflow-method-outcome_plot

Create summary plots of the outcome measure
MRPWorkflow-method-preprocess

Preprocess sample data
MRPWorkflow-method-link_acs

Link sample data to ACS data
MRPWorkflow-method-pp_check

Perform posterior predictive check
MRPWorkflow-method-preprocessed_data

Return preprocessed sample data
mrp_workflow

Create a new MRPWorkflow object
run_app

Run the Shiny Application
shinymrp-package

shinymrp: Interface for Multilevel Regression and Poststratification
example_pstrat_data

Return example poststratification data
example_sample_data

Return example data
MRPModel-method-fit

Fit multilevel regression model using cmdstanr
MRPModel-method-metadata

Return model metadata.
MRPModel-method-diagnostics

Return sampling diagnostics
MRPModel-method-check_estimate_exists

Check if poststratification has been performed
MRPModel-method-check_fit_exists

Check if model has been fitted
MRPModel-method-log_lik

Create inputs for leave-one-out cross-validation
MRPModel-method-ppc

Create input for posterior predictive check
MRPModel-method-model_spec

Return model specification
MRPModel-method-poststratify

Run poststratification to generate population estimates
MRPModel-method-formula

Return model formula
MRPModel

MRPModel objects
MRPModel-method-summary

Return posterior summary table
MRPWorkflow-method-create_model

Create a new MRPModel object
MRPWorkflow-method-estimate_map

Create a choropleth map of MRP estimates
MRPWorkflow-method-compare_models

Compare models using LOO-CV
MRPWorkflow-method-covar_hist

Create geographic covariate distribution histogram
MRPModel-method-save

Save model object to file
MRPWorkflow-method-estimate_plot

Visualize estimates for demographic groups