Learn R Programming

selection.index (version 2.0.0)

lpsi: Combinatorial Linear Phenotypic Selection Index

Description

Build all possible Smith-Hazel selection indices from trait combinations, with optional exclusion of specific traits.

This function systematically evaluates indices for all combinations of ncomb traits, which is useful for identifying the most efficient subset of traits for selection.

Usage

lpsi(ncomb, pmat, gmat, wmat, wcol = 1, GAY, excluding_trait = NULL)

Value

Data frame of all possible selection indices with metrics (GA, PRE, Delta_G, rHI, hI2)

Arguments

ncomb

Number of traits per combination

pmat

Phenotypic variance-covariance matrix

gmat

Genotypic variance-covariance matrix

wmat

Weight matrix

wcol

Weight column number if more than one weight set (default: 1)

GAY

Genetic advance of comparative trait (optional)

excluding_trait

Optional. Traits to exclude from combinations. Can be: (1) numeric vector of trait indices (e.g., c(1, 3)), (2) character vector of trait names (e.g., c("sypp", "dtf")), (3) data frame/matrix columns with trait data (trait names extracted from column names). When specified, only combinations that do NOT contain any of these traits are returned.

Examples

Run this code
if (FALSE) {
gmat <- gen_varcov(seldata[, 3:9], seldata[, 2], seldata[, 1])
pmat <- phen_varcov(seldata[, 3:9], seldata[, 2], seldata[, 1])
wmat <- weight_mat(weight)

# Build all 3-trait indices
result <- lpsi(ncomb = 3, pmat = pmat, gmat = gmat, wmat = wmat, wcol = 1)

# Exclude specific traits
result <- lpsi(
  ncomb = 3, pmat = pmat, gmat = gmat, wmat = wmat,
  excluding_trait = c(1, 3)
)
}

Run the code above in your browser using DataLab