Genetic covariance models
Prepare covariance summaries
gcorr_covariance() requires a finite labelled continuous-trait covariance matrix, compatible named units and, for model fitting, the full joint sampling covariance of lower-column moments.
library(gcorr)
traits <- c("A", "B", "C")
G <- matrix(c(1, .3, .2, .3, 1, .4, .2, .4, 1), 3,
dimnames = list(traits, traits))
labels <- c("A|A", "B|A", "C|A", "B|B", "C|B", "C|C")
V <- diag(.001, 6)
dimnames(V) <- list(labels, labels)
input <- gcorr_covariance(G, V, continuous = TRUE,
units = setNames(rep("standard deviations", 3), traits))Structural models
gcorr_sem() consumes an explicit recursive model with variables, parameter starts/bounds and directed or disturbance entries. gcorr_sem_test() tests named linear constraints using the fitted joint parameter covariance.
model <- list(
variables = c(traits, "F"),
parameters = data.frame(name = c("lA", "lB", "lC", "vA", "vB", "vC"),
start = c(rep(.5, 3), rep(.7, 3)),
lower = c(rep(-Inf, 3), rep(1e-8, 3)), upper = rep(Inf, 6)),
entries = data.frame(
matrix = c(rep("directed", 3), rep("disturbance", 4)),
row = c(traits, traits, "F"), column = c(rep("F", 3), traits, "F"),
parameter = c("lA", "lB", "lC", "vA", "vB", "vC", ""),
value = c(rep(0, 6), 1)))
sem <- gcorr_sem(input, model)Graphical models
gcorr_ggm_network() reports the descriptive all-trait conditional network. gcorr_ggm() fits an explicitly allowed fixed graph; it performs no graph search. gcorr_ggm_test() tests selected fitted free edges.
edges <- matrix(c("A", "B", "B", "C"), ncol = 2, byrow = TRUE)
network <- gcorr_ggm_network(input)
graph <- gcorr_ggm(input, edges)
edge_test <- gcorr_ggm_test(graph, edges[1, , drop = FALSE])Grouped models
gcorr_grouped_covariance() extracts GNOVA categories, SumHer architecture components or transformed SumHer categories with their full cross-group jackknife covariance. gcorr_grouped_sem() and gcorr_grouped_ggm() apply one prespecified model across groups; their test functions propagate cross-group uncertainty. Marginal standard errors are never substituted for the required joint covariance.