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

289

Version

4.2.3

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Patrick Breheny

Last Published

January 26th, 2026

Functions in plmmr (4.2.3)

plmm_prep

PLMM prep: a function to run checks, SVD, and rotation prior to fitting a PLMM model This is an internal function for cv_plmm
predict.plmm

Predict method for plmm class
plmm_checks

plmm_checks
plmm_loss

Loss method for "plmm" class
plot.cv_plmm

Plot method for cv_plmm class
plot.plmm

Plot method for plmm class
plmm_format

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

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

Predict method to use in cross-validation (within cvf)
plmmr-package

plmmr: Penalized Linear Mixed Models for Correlated Data
process_delim

A function to read in large data files as an FBM
print.summary.cv_plmm

Print method for summary.cv_plmm objects
print.summary.plmm

A function to print the summary of a plmm model
process_plink

Preprocess PLINK files using the bigsnpr package
relatedness_mat

Calculate a relatedness matrix
rotate_filebacked

A function to rotate filebacked data
read_data_files

A function to read in a large file as a numeric file-backed matrix (FBM) Note: this function is a wrapper for bigstatsr::big_read()
setup_lambda

Compute sequence of lambda values
pretty_time

a function to format the time
read_plink_files

A function to read in PLINK files using bigsnpr methods
unzip_example_data

For Linux/Unix and MacOS only, here is a companion function to unzip the .gz files that ship with the plmmr package
summary.plmm

A summary method for the plmm objects
untransform_delim

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

Untransform coefficient values back to the original scale In memory
standardize_filebacked

A helper function to standardize a filebacked matrix
summary.cv_plmm

A summary function for cv_plmm objects
subset_filebacked

A helper function to subset big.matrix objects
standardize_in_memory

A helper function to standardize matrices
untransform_plink

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

Untransform coefficient values back to the original scale
MCP

helper function to implement MCP penalty The helper functions to implement each penalty.
coef.cv_plmm

Coef method for "cv_plmm" class
coef.plmm

Coef method for "plmm" class
cv_plmm

Cross-validation for plmm
create_design

a function to create a design for PLMM modeling
cvf

Cross-validation internal function for cv_plmm
count_constant_features

A helper function to count constant features
add_predictors

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

helper function to implement SCAD penalty
big_cbind

a version of cbind() for file-backed matrices
construct_variance

a function to create the estimated variance matrix from a PLMM fit
create_log

create_log_file
align_ids

A helper function to support process_plink()
admix

Admix: Semi-simulated SNP data
count_cores

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

Functions to convert between FBM and big.matrix type objects
estimate_eta

Estimate eta (to be used in rotating the data) This function is called internally by plmm()
eigen_K

A function to take the eigendecomposition of K Note: This is faster than taking SVD of X when p >> n
find_example_data

A function to help with accessing example PLINK files
get_data

Read in processed data This function is intended to be called after either process_plink() or process_delim() has been called once.
create_design_filebacked

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

a function to return the computer's host name
create_design_in_memory

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

Fit a linear mixed model via penalized maximum likelihood.
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
impute_snp_data

A function to impute SNP data
lam_names

Generate nicely formatted lambda vec
log_lik

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

helper function to implement lasso penalty