Learn R Programming

plmmr

The plmmr (penalized linear mixed models in R) package contains functions that fit penalized linear mixed models to correct for unobserved confounding effects.

Three small datasets ship with plmmr, and tutorials walking through how to analyze these data sets are documented in the plmmr website.

Installation

To install the latest version of the package from GitHub, use this:

devtools::install_github("pbreheny/plmmr")

You can also install plmmr from CRAN:

install.packages('plmmr')

Minimal example

library(plmmr)
X <- rnorm(100*20) |> matrix(100, 20)
y <- rnorm(100)
fit <- plmm(X, y) 
plot(fit)

cvfit <- cv_plmm(X, y)
plot(cvfit)
summary(cvfit)

So how fast is plmmr? And how well does it scale?

These questions are addressed in our manuscript describing plmmr, along with its accompanying GitHub repository. However, using GWAS data from a study with 1,400 samples and 800,000 SNPs, a full plmmr analysis will run in about half an hour using a single core on a laptop.

Copy Link

Version

Install

install.packages('plmmr')

Monthly Downloads

159

Version

4.3.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Patrick Breheny

Last Published

June 11th, 2026

Functions in plmmr (4.3.0)

cv_plmm

Cross-validation for plmm
get_data

Read in processed data
find_example_data

A function to help with accessing example PLINK files.
create_design_in_memory

A function to create a design with an in-memory X matrix
create_design_filebacked

A function to create a design matrix, outcome, and penalty factor to be passed to a model fitting function
impute_snp_data

A function to impute SNP data
lam_names

Generate nicely formatted lambda vector
plmm

Fit a linear mixed model via penalized maximum likelihood.
plmm_fit

PLMM fit: A function that fits a PLMM using the values returned by plmm_prep()
log_lik

Evaluate the negative log-likelihood of an intercept-only Gaussian plmm model
plmm_checks

A function to perform checks on passed objects before model fitting.
name_and_count_bigsnp

A helper function to label and summarize the contents of a bigSNP
index_samples

A function to align genotype and phenotype data
print.summary.plmm

A function to print the summary of a plmm model
print.summary.cv_plmm

Print method for summary.cv_plmm objects
predict_within_cv

Predict method to use in cross-validation (within cvf())
predict.cv_plmm

Predict method for cv_plmm class
plmm_loss

Loss method for plmm class
predict.plmm

Predict method for plmm class
pretty_time

A function to format the time
plmm_format

PLMM format: a function to format the output of a model constructed with plmm_fit()
plmm_prep

PLMM prep: a function to run checks, eigendecomposition, and rotation prior to fitting a PLMM model
plmmr-package

plmmr: Penalized Linear Mixed Models for Correlated Data
plot.plmm

Plot method for plmm class
plot.cv_plmm

Plot method for cv_plmm class
standardize_in_memory

A helper function to standardize matrices
process_delim

A function to read in large data files as a filebacked big.matrix
subset_filebacked

A helper function to subset big.matrix objects
untransform_plink

Untransform coefficient values back to the original scale for file-backed data
process_plink

Preprocess PLINK files using the bigsnpr package
read_plink_files

A function to read in PLINK files using bigsnpr methods
untransform_in_memory

Untransform coefficient values back to the original scale in memory
read_data_files

A function to read in a large file as a numeric file-backed matrix
relatedness_mat

Calculate a relatedness matrix
unzip_example_data

Companion function to unzip the .gz files that ship with the plmmr package.
rotate_filebacked

A function to rotate filebacked data
standardize_filebacked

A helper function to standardize a filebacked matrix
setup_lambda

Compute sequence of lambda values for plmm models
untransform

Untransform coefficient values back to the original scale
summary.cv_plmm

A summary function for cv_plmm objects
summary.plmm

A summary method for plmm objects
untransform_delim

Untransform coefficient values back to the original scale for file-backed data
compute_blup

A function to compute the BLUP
coef.plmm

Coef method for plmm class
coef.cv_plmm

Coef method for cv_plmm class
create_design

A function to create a design for PLMM modeling
add_predictors

A helper function to add predictors to a filebacked matrix of data
admix

Admix: Semi-simulated SNP data
estimate_eta

Estimate eta (to be used in rotating the data)
construct_variance

A function to construct the estimated variance matrix from a PLMM fit
count_constant_features

A helper function to count constant features
count_cores

A helper function to count the number of cores available on the current machine
align_ids

A helper function to support create_design_filebacked()
big_cbind

A version of cbind() for file-backed matrices
eigen_K

A function to take the eigendecomposition of K
cvf

Cross-validation internal function for cv_plmm()
create_log

Create the .log file