--- title: "Factor analytic and reduced rank models in sommer" author: "Giovanny Covarrubias-Pazaran" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Factor analytic and reduced rank models in sommer} %\VignetteEngine{knitr::knitr} %\VignetteEncoding{UTF-8} --- The sommer package was developed to provide R users with a flexible univariate and multivariate linear mixed-model solver. Multi-environment trial (MET) analyses often need a genetic covariance structure among environments. A fully unstructured covariance (`usm()`) captures every pairwise environment relationship but requires $q(q+1)/2-1$ parameters for $q$ environments, which quickly becomes difficult to estimate reliably as the number of environments grows. Factor-analytic (FA) and reduced-rank (RR) models approximate that same covariance with far fewer parameters by assuming that genotype-by-environment interaction is driven by a small number of latent factors. This vignette focuses on the `fam()` and `rrm()` covariance-shaping factors used inside `vsm()`, and on the `loadings_mmes()`/`scores_mmes()` helper functions used to extract and visualize their fitted quantities. **SECTION 1: Theory** 1) Why reduce the cross-environment covariance 2) The factor-analytic (FA) model 3) The reduced-rank (RR) model 4) Choosing k and comparing to other structures **SECTION 2: Fitting factor-analytic and reduced-rank models** 1) Data 2) Factor-analytic model with `fam()` 3) Reduced-rank model with `rrm()` 4) Comparing FA and RR **SECTION 3: Extracting loadings, scores, and diagnostic plots** 1) Loadings and specific variances 2) Genotype scores 3) Why and how to rotate loadings and scores 4) Percentage of variance explained 5) Loadings plot 6) Genotype scores plot 7) Latent regression plots 8) Heatmap of the fitted genetic correlation matrix ## SECTION 1: Theory ### 1) Why reduce the cross-environment covariance Let $q$ be the number of environments and $G$ the $q\times q$ genetic covariance matrix among them. An unstructured model estimates every variance and covariance directly, $q(q+1)/2-1$ working parameters after removing the single overall scale owned by `vsm()`. As $q$ grows, this saturated model becomes weakly identified relative to the available genotype replication, and its estimates become unstable. Diagonal (`dsm()`) and compound-symmetry (`csm()`) models are far more parsimonious but assume, respectively, no genetic correlation among environments or one common correlation everywhere. Factor-analytic and reduced-rank models sit between these extremes: they estimate genuine environment-specific covariance patterns while controlling the number of parameters through a rank $k \ll q$. ### 2) The factor-analytic (FA) model The FA model represents the environment covariance shape as $$ K = \Lambda\Lambda^{\mathsf T} + \Psi, $$ where $\Lambda$ is a $q\times k$ loading matrix and $\Psi$ is a diagonal matrix of environment-specific variances. Each environment's genetic variance is split into a part explained by the $k$ common latent factors ($\Lambda\Lambda^{\mathsf T}$) and a part unique to that environment ($\Psi$). `vsm()` still owns the single overall variance scale, so `fam(x, k)` reports a normalized shape with $K_{11}=1$; the number of estimated working parameters for $k$ factors and $q$ environments is $$ kq-\frac{k(k-1)}{2} + (q-1), $$ the first term for the (rotationally-constrained, lower-triangular) loadings and the second for the environment-specific variance ratios. ### 3) The reduced-rank (RR) model The RR model uses the same loading structure but fixes every specific variance to zero: $$ K = \Lambda\Lambda^{\mathsf T},\qquad \Lambda_{11}=1. $$ `rrm(x, k)` therefore has $$ kq-\frac{k(k-1)}{2}-1 $$ free shape parameters, plus the overall scale supplied by `vsm()`: exactly $q$ fewer parameters than heterogeneous `fam(x, k)`. The covariance has rank $k$, with no diagonal remainder, matching ASReml's default `rr()` covariance family. The Henderson engine works with latent factors rather than inverting the singular environment covariance; direct inversion is also supported. For an estimated common nonzero specific variance, use `fam(x, k, variance="homogeneous")`. This is the covariance family previously fitted by `rrm()`; the default `fam()` remains heterogeneous. ### 4) Choosing k and comparing to other structures Increasing $k$ enlarges the latent subspace, but RR remains singular while $k. Gilmour AR, Thompson R, Cullis BR. 1995. Average Information REML: An efficient algorithm for variance parameter estimation in linear mixed models. Biometrics 51:1440-1450.