https://github.com/biometris/lmmsolver

See https://biometris.github.io/LMMsolver for a full description

https://github.com/biometris/lmmsolver

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.8%) to scientific vocabulary

Keywords

cran mixed-models r-package splines
Last synced: 5 months ago · JSON representation

Repository

See https://biometris.github.io/LMMsolver for a full description

Basic Info
Statistics
  • Stars: 16
  • Watchers: 4
  • Forks: 2
  • Open Issues: 0
  • Releases: 3
Topics
cran mixed-models r-package splines
Created over 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog

README.Rmd

---
output: github_document
bibliography: ./vignettes/bibliography.bib
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "70%"
)
```

# LMMsolver 

[![](https://www.r-pkg.org/badges/version/LMMsolver)](https://www.r-pkg.org/pkg/LMMsolver)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/LMMsolver)](https://www.r-pkg.org/pkg/LMMsolver)
[![R-CMD-check](https://github.com/Biometris/LMMsolver/workflows/R-CMD-check/badge.svg)](https://github.com/Biometris/LMMsolver/actions?workflow=R-CMD-check)
[![codecov](https://codecov.io/gh/Biometris/LMMsolver/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Biometris/LMMsolver)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14527379.svg)](https://doi.org/10.5281/zenodo.14527379)

The aim of the `LMMsolver` package is to provide an efficient and flexible system to estimate variance components using restricted maximum likelihood or REML [@Patterson1971], for models where the mixed model equations are sparse. An important feature of the package is smoothing with P-splines [@Eilers1996]. The sparse mixed model P-splines formulation [@boer2023] is used, which makes the computations fast. The computational advantage of the sparse mixed model formulation is especially clear for two-dimensional smoothing [@boer2023;@carollo2024].



## Installation

* Install from CRAN:

```{r, eval = FALSE}
install.packages("LMMsolver")
```

* Install latest development version from GitHub (requires [remotes](https://github.com/r-lib/remotes) package):

```{r, eval = FALSE}
remotes::install_github("Biometris/LMMsolver", ref = "develop", dependencies = TRUE)
```

## Example

As an example of the functionality of the package we use the `USprecip` data set in the `spam` package [@Furrer2010].

```{r USprecip data}
library(LMMsolver)
library(ggplot2)

## Get precipitation data from spam
data(USprecip, package = "spam")

## Only use observed data.
USprecip <- as.data.frame(USprecip)
USprecip <- USprecip[USprecip$infill == 1, ]
head(USprecip[, c(1, 2, 4)], 3)
```

A two-dimensional P-spline can be defined with the `spl2D()` function, with longitude and latitude as covariates, and anomaly (standardized monthly total precipitation) as response variable:

```{r runobj}
obj1 <- LMMsolve(fixed = anomaly ~ 1,
                 spline = ~spl2D(x1 = lon, x2 = lat, nseg = c(41, 41)),
                 data = USprecip)
```







The spatial trend for the precipitation can now be plotted on the map of the USA, using the `predict` function of `LMMsolver`: 

```{r Plot_USprecip, fig.alt="Precipitation anomaly USA"}
lon_range <- range(USprecip$lon)
lat_range <- range(USprecip$lat)
newdat <- expand.grid(lon = seq(lon_range[1], lon_range[2], length = 200),
                      lat = seq(lat_range[1], lat_range[2], length = 300))
plotDat <- predict(obj1, newdata = newdat)

plotDat <- sf::st_as_sf(plotDat, coords = c("lon", "lat"))
usa <- sf::st_as_sf(maps::map("usa", regions = "main", plot = FALSE))
sf::st_crs(usa) <- sf::st_crs(plotDat)
intersection <- sf::st_intersects(plotDat, usa)
plotDat <- plotDat[!is.na(as.numeric(intersection)), ]

ggplot(usa) + 
  geom_sf(color = NA) +
  geom_tile(data = plotDat, 
            mapping = aes(geometry = geometry, fill = ypred), 
            linewidth = 0,
            stat = "sf_coordinates") +
  scale_fill_gradientn(colors = topo.colors(100))+
  labs(title = "Precipitation (anomaly)", 
       x = "Longitude", y = "Latitude") +
  coord_sf() +
  theme(panel.grid = element_blank())
```

Further examples can be found in the vignette.
```r
vignette("Solving_Linear_Mixed_Models")
```

# References

Owner

  • Name: Wageningen Universtiy & Research, Biometris
  • Login: Biometris
  • Kind: organization
  • Email: biometris@wur.nl
  • Location: Wageningen, The Netherlands

Biometris develops statistical and mathematical methods for the quantification of biological processes and processes in our living environment.

GitHub Events

Total
  • Release event: 3
  • Watch event: 6
  • Push event: 118
  • Fork event: 2
  • Create event: 3
Last Year
  • Release event: 3
  • Watch event: 6
  • Push event: 118
  • Fork event: 2
  • Create event: 3

Packages

  • Total packages: 1
  • Total downloads:
    • cran 794 last-month
  • Total docker downloads: 21,613
  • Total dependent packages: 2
  • Total dependent repositories: 2
  • Total versions: 12
  • Total maintainers: 1
cran.r-project.org: LMMsolver

Linear Mixed Model Solver

  • Versions: 12
  • Dependent Packages: 2
  • Dependent Repositories: 2
  • Downloads: 794 Last month
  • Docker Downloads: 21,613
Rankings
Dependent packages count: 17.7%
Dependent repos count: 19.6%
Average: 21.2%
Downloads: 26.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.6 depends
  • Matrix * imports
  • Rcpp >= 0.10.4 imports
  • agridat * imports
  • ggplot2 * imports
  • maps * imports
  • methods * imports
  • sp * imports
  • spam * imports
  • splines * imports
  • knitr * suggests
  • rmarkdown * suggests
  • tinytest * suggests