Just a wrapper for svd() that returns an adequate output when used on blocks of variables. Can deal with phylogenetic data too using ape and phytools functions. Used internally.

svd_block(x, y, tree = NULL)

Arguments

x

First block of variables

y

Second block of variables

tree

An optional "phylo" object containing a phylogenetic tree whose tip.labels match rownames of x and y.

Value

Mimics the svd() output.

Examples

#laod data and packages
library(geomorph)

data("tails")
shapes <- tails$shapes
sizes <- tails$sizes
species <- tails$data$species
tree <- tails$tree
sp_shapes <- expected_shapes(shapes, species)[,,tree$tip.label]
sp_sizes <- cbind(tapply(sizes, species, mean))[tree$tip.label,]

#perform partial svd
svd_block(x = sizes, y = two.d.array(shapes))
#> $d
#> [1] 42.92575
#> 
#> $v
#>                [,1]
#>  [1,] -5.613140e-02
#>  [2,]  1.220262e-01
#>  [3,] -5.613140e-02
#>  [4,] -1.220262e-01
#>  [5,]  2.042085e-02
#>  [6,]  1.341861e-01
#>  [7,]  2.042085e-02
#>  [8,] -1.341861e-01
#>  [9,] -4.132683e-01
#> [10,] -1.266548e-01
#> [11,]  8.369095e-02
#> [12,]  5.318992e-02
#> [13,]  7.305758e-01
#> [14,] -1.136551e-08
#> [15,]  8.369094e-02
#> [16,] -5.318994e-02
#> [17,] -4.132683e-01
#> [18,]  1.266548e-01
#> 
#> $u
#>      [,1]
#> [1,]    1
#> 

#perform partial svd on phylogenetic structure
svd_block(x = sp_sizes, y = two.d.array(sp_shapes), tree = tree)
#> $d
#> [1] 17.05874
#> 
#> $v
#>                [,1]
#>  [1,] -7.089075e-02
#>  [2,]  1.199741e-01
#>  [3,] -7.089075e-02
#>  [4,] -1.199741e-01
#>  [5,]  1.607633e-03
#>  [6,]  1.287336e-01
#>  [7,]  1.607636e-03
#>  [8,] -1.287336e-01
#>  [9,] -3.125015e-01
#> [10,] -1.063445e-01
#> [11,] -3.778528e-02
#> [12,] -3.916476e-02
#> [13,]  8.391398e-01
#> [14,]  1.094144e-08
#> [15,] -3.778528e-02
#> [16,]  3.916475e-02
#> [17,] -3.125015e-01
#> [18,]  1.063445e-01
#> 
#> $u
#>      [,1]
#> [1,]    1
#>