Learn R Programming

⚠️There's a newer version (4.2.3) of this package.Take me there.

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.2.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Patrick Breheny

Last Published

January 21st, 2026

Functions in plmmr (4.2.2)

create_design_in_memory

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

helper function to implement lasso penalty
get_hostname

a function to return the computer's host name
index_samples

A function to align genotype and phenotype data
plmm_loss

Loss method for "plmm" class
lam_names

Generate nicely formatted lambda vec
plmm_format

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

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

Fit a linear mixed model via penalized maximum likelihood.
predict.plmm

Predict method for plmm class
create_design

a function to create a design for PLMM modeling
plot.cv_plmm

Plot method for cv_plmm class
plot.plmm

Plot method for plmm class
predict_within_cv

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

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

A function to print the summary of a plmm model
impute_snp_data

A function to impute SNP data
name_and_count_bigsnp

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

A function to rotate filebacked data
pretty_time

a function to format the time
print.summary.cv_plmm

Print method for summary.cv_plmm objects
plmm_checks

plmm_checks
cv_plmm

Cross-validation for plmm
standardize_filebacked

A helper function to standardize a filebacked matrix
setup_lambda

Compute sequence of lambda values
standardize_in_memory

A helper function to standardize matrices
read_plink_files

A function to read in PLINK files using bigsnpr methods
get_data

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

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

A function to help with accessing example PLINK files
untransform_in_memory

Untransform coefficient values back to the original scale In memory
untransform_delim

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

Calculate a relatedness matrix
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
untransform_plink

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

A helper function to subset big.matrix objects
summary.cv_plmm

A summary function for cv_plmm objects
summary.plmm

A summary method for the plmm objects
untransform

Untransform coefficient values back to the original scale
process_plink

Preprocess PLINK files using the bigsnpr package
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
plmmr-package

plmmr: Penalized Linear Mixed Models for Correlated 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()
admix

Admix: Semi-simulated SNP data
coef.plmm

Coef method for "plmm" class
coef.cv_plmm

Coef method for "cv_plmm" class
align_ids

A helper function to support process_plink()
SCAD

helper function to implement SCAD penalty
MCP

helper function to implement MCP penalty The helper functions to implement each penalty.
add_predictors

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

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

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

A helper function to count constant features
create_log

create_log_file
construct_variance

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

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

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

Cross-validation internal function for cv_plmm
eigen_K

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

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