| Title: | Connectivity-Weighted Allocation and Comparison of Field-Plot Designs |
|---|---|
| Description: | A reproducible mixed-model toolkit for plant-breeding trial design. It evaluates any replication allocation under a known genetic relationship (kinship) matrix using one common linear-mixed-model engine on genotype means. Crucially, allocation and analysis model are crossed rather than confounded: every allocation can be scored both with and without kinship, so the precision gain attributable to a design can be separated from the gain attributable to the kinship-based analysis adopted alongside it. It computes A-optimal, connectivity-aware allocations via rank-1 Sherman-Morrison updates, and provides Monte-Carlo stress tests for outlier shrinkage and kinship mis-specification, each with a matched control arm. |
| Authors: | Praveen Kumar [aut, cre] |
| Maintainer: | Praveen Kumar <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.0 |
| Built: | 2026-09-27 14:33:49 UTC |
| Source: | https://github.com/bkpraveenars-del/cwad |
Balanced allocation summing to B: every genotype gets
floor(B/N) plots and the surplus is placed at random. Averaging the
criterion over several draws gives the control against which an optimised
allocation should be judged when B/N is not an integer; comparing an
integer allocation against a fractional "uniform r = B/N" is not a feasible
comparison and inflates the apparent gain.
balanced_control(B, N, reps = 25L, seed = 11L)balanced_control(B, N, reps = 25L, seed = 11L)
B |
total plot budget. |
N |
number of genotypes. |
reps |
number of random draws to return. |
seed |
RNG seed. |
list of reps replication vectors.
BLUP of genotype effects from the reduced (means) model
blup(ybar, r, Ginv, alpha)blup(ybar, r, Ginv, alpha)
ybar |
genotype phenotypic means. |
r |
numeric vector of replications per genotype. |
Ginv |
inverse relationship matrix (use |
alpha |
variance ratio |
numeric vector of predicted genotype effects.
where
. The genotype-mean reduction is exact
for the model ,
.
build_mme(r, Ginv, alpha)build_mme(r, Ginv, alpha)
r |
numeric vector of replications per genotype. |
Ginv |
inverse relationship matrix (use |
alpha |
variance ratio |
the coefficient matrix.
Replaces the v0.1.0 compare_designs(). Every allocation is evaluated
under BOTH analysis models – kinship-free () and kinship
() – so that the allocation contrast and the analysis-model contrast
are crossed rather than confounded. In v0.1.0 the caller supplied one
analysis matrix per design, which made it easy (and, in the shipped example,
actual) to change allocation and analysis model in the same step and then
attribute the whole difference to the allocation.
compare_designs(G, alpha, sig2e, r_list, idx = NULL)compare_designs(G, alpha, sig2e, r_list, idx = NULL)
G |
relationship (kinship) matrix, |
alpha |
variance ratio |
sig2e |
residual variance. |
r_list |
named list of replication vectors, each of length |
idx |
optional 1-based indices of the evaluation set. |
a data.frame with one row per allocation and columns
PEV_noG, rel_noG, PEV_kin, rel_kin,
plus gain_analysis_pp and gain_allocation_pp, the
decomposition of the naive gain relative to the first allocation in
r_list analysed without kinship.
g <- make_fs_G(c(12, 12, 4, 4, 1, 1)) Ginv <- solve(g$G); N <- nrow(g$G) r_unif <- rep(2, N) r_cwad <- greedy_alloc(Ginv, B = 2 * N, alpha = 2) compare_designs(g$G, alpha = 2, sig2e = 2, list(Uniform = r_unif, CWAD = r_cwad))g <- make_fs_G(c(12, 12, 4, 4, 1, 1)) Ginv <- solve(g$G); N <- nrow(g$G) r_unif <- rep(2, N) r_cwad <- greedy_alloc(Ginv, B = 2 * N, alpha = 2) compare_designs(g$G, alpha = 2, sig2e = 2, list(Uniform = r_unif, CWAD = r_cwad))
Allocates a plot budget one plot at a time to the genotype whose extra
replicate most reduces the mean pairwise PEV, using rank-1
Sherman-Morrison updates of the inverse MME (adding a plot to genotype
is the rank-1 update , ). When the
relationship matrix carries genetic connectivity, the optimiser
spontaneously concentrates replication on genetically isolated genotypes.
greedy_alloc( Ginv, B, alpha, sig2e = 1, floor = 1L, r_start = NULL, idx_eval = NULL, check = TRUE )greedy_alloc( Ginv, B, alpha, sig2e = 1, floor = 1L, r_start = NULL, idx_eval = NULL, check = TRUE )
Ginv |
inverse relationship matrix. |
B |
total plot budget (>= floor * N). |
alpha |
variance ratio. |
sig2e |
residual variance. |
floor |
minimum replication per genotype (default 1). |
r_start |
optional starting allocation (overrides |
idx_eval |
evaluation set for the criterion (default all). |
check |
logical; if TRUE, validate the first Sherman-Morrison score against a brute-force re-inversion (correctness self-test). |
numeric vector of replications summing to B.
g <- make_fs_G(c(12, 12, 4, 4, 1, 1)); Ginv <- solve(g$G) N <- nrow(Ginv) # 34 genotypes r <- greedy_alloc(Ginv, B = 2 * N, alpha = 2) tapply(r, g$connectivity, mean) # isolated genotypes get more plotsg <- make_fs_G(c(12, 12, 4, 4, 1, 1)); Ginv <- solve(g$G) N <- nrow(Ginv) # 34 genotypes r <- greedy_alloc(Ginv, B = 2 * N, alpha = 2) tapply(r, g$connectivity, mean) # isolated genotypes get more plots
Builds a block-diagonal numerator relationship matrix for a set of full-sib
families (diagonal 1, within-family off-diagonal within).
make_fs_G(fam_sizes, within = 0.5)make_fs_G(fam_sizes, within = 0.5)
fam_sizes |
integer vector of family sizes. |
within |
within-family additive relationship (default 0.5 for full sibs). |
list with G (relationship matrix), fam_id (0-based family
index per genotype) and connectivity (row-sum of off-diagonals).
g <- make_fs_G(c(12, 12, 4, 4, 1, 1)) range(g$connectivity)g <- make_fs_G(c(12, 12, 4, 4, 1, 1)) range(g$connectivity)
u-block of the inverse MME (unit-variance scale)
Muu_inv(r, Ginv, alpha)Muu_inv(r, Ginv, alpha)
r |
numeric vector of replications per genotype. |
Ginv |
inverse relationship matrix (use |
alpha |
variance ratio |
the genotype block of .
Mean pairwise prediction-error variance (A-optimality criterion)
pev_pairwise(r, Ginv, alpha, sig2e, idx = NULL)pev_pairwise(r, Ginv, alpha, sig2e, idx = NULL)
r |
replications. |
Ginv |
inverse relationship. |
alpha |
ratio. |
sig2e |
residual variance. |
idx |
optional 1-based indices of the evaluation set (default: all genotypes). |
mean variance of a difference between two genotype predictions.
Mean genotype reliability
reliability(r, Ginv, alpha, idx = NULL)reliability(r, Ginv, alpha, idx = NULL)
r |
replications. |
Ginv |
inverse relationship. |
alpha |
ratio. |
idx |
optional 1-based indices of the evaluation set (default: all genotypes). |
mean of over the evaluation set.
Plants one genotype with a genetic value spike genetic standard
deviations above its family mean and measures, by Monte Carlo over residual
noise, how far each arm's BLUP is pulled toward the family mean.
sim_transgressive( G, alpha, sig2e, sig2g, fam_id, t, r_list, spike = 3, reps = 3000, seed = 7 )sim_transgressive( G, alpha, sig2e, sig2g, fam_id, t, r_list, spike = 3, reps = 3000, seed = 7 )
G |
relationship matrix. |
alpha |
variance ratio. |
sig2e |
residual variance. |
sig2g |
genetic variance. |
fam_id |
0-based family index per genotype. |
t |
1-based index of the transgressive genotype. |
r_list |
named list of replication vectors. |
spike |
deviation added to genotype |
reps |
Monte Carlo replications. |
seed |
RNG seed. |
Unlike v0.1.0, every allocation in r_list is run under BOTH analysis
models, so the shrinkage attributable to borrowing from relatives is
separated from the shrinkage attributable to reduced replication. In v0.1.0
the uniform arm was analysed without kinship and the CWAD arm with it, and
the whole difference was reported as a property of CWAD; on the shipped
example 58 percent of it is the analysis model.
list with true_val, fam_mean, the raw estimates
matrix and a data.frame summary carrying one row per
(allocation, analysis model) cell.
Generates truth under but analyses with
the assumed kinship G, and reports RMSE of the BLUP for every
(allocation, analysis model) cell across .
sim_wrongG( G, alpha, sig2e, sig2g, r_list, split_by_r = TRUE, deltas = seq(0, 1, by = 0.1), reps = 500, seed = 7 )sim_wrongG( G, alpha, sig2e, sig2g, r_list, split_by_r = TRUE, deltas = seq(0, 1, by = 0.1), reps = 500, seed = 7 )
G |
assumed relationship matrix. |
alpha |
variance ratio. |
sig2e |
residual variance. |
sig2g |
genetic variance. |
r_list |
named list of replication vectors; the first is the reference. |
split_by_r |
logical; if TRUE, additionally report each allocation's
|
deltas |
sequence of mis-specification levels. |
reps |
Monte Carlo replications per delta. |
seed |
RNG seed. |
The matched control is the reference allocation analysed with the SAME wrong kinship. Comparing an aggressive allocation analysed with kinship against a uniform allocation analysed WITHOUT kinship – as v0.1.0 did – measures the cost of using kinship at all, because a kinship-free analysis cannot be harmed by a wrong kinship matrix; its curve is flat by construction and any crossing with it is an artefact of the mismatch, not a breaking point.
long-format data.frame: delta, allocation, analysis, subset, RMSE.