KrzSubspace function

Krzanowski common subspaces analysis

Krzanowski common subspaces analysis

Calculates the subspace most similar across a set of covariance matrices.

KrzSubspace(cov.matrices, k = NULL)

Arguments

  • cov.matrices: list of covariance matrices
  • k: number of dimensions to be retained in calculating the subspace

Returns

H shared space matrix

k_eVals_H eigen values for shared space matrix, maximum value for each is the number of matrices, representing a fully shared direction

k_eVecs_H eigen vectors of shared space matrix

angles between each population subspace and each eigen vector of shared space matrix

Note

can be used to implement the Bayesian comparison from Aguirre et al. 2014

Examples

data(dentus) dentus.matrices = dlply(dentus, .(species), function(x) cov(x[-5])) KrzSubspace(dentus.matrices, k = 2) ## Not run: # The method in Aguirre et al. 2014 can de implemented using this function as follows: #Random input data with dimensions traits x traits x populations x MCMCsamples: cov.matrices = aperm(aaply(1:10, 1, function(x) laply(RandomMatrix(6, 40, variance = runif(6,1, 10)), identity)), c(3, 4, 1, 2)) Hs = alply(cov.matrices, 4, function(x) alply(x, 3)) |> llply(function(x) KrzSubspace(x, 3)$H) avgH = Reduce("+", Hs)/length(Hs) avgH.vec <- eigen(avgH)$vectors MCMC.H.val = laply(Hs, function(mat) diag(t(avgH.vec) %*% mat %*% avgH.vec)) # confidence intervals for variation in shared subspace directions library(coda) HPDinterval(as.mcmc(MCMC.H.val)) ## End(Not run)

References

Aguirre, J. D., E. Hine, K. McGuigan, and M. W. Blows. "Comparing G: multivariate analysis of genetic variation in multiple populations." Heredity 112, no. 1 (2014): 21-29.

  • Maintainer: Diogo Melo
  • License: MIT + file LICENSE
  • Last published: 2023-12-05

Useful links