Skip to content

The function computes the expected covariances or correations of any community-level properties between communities.

Usage

get_comm_pair_r(comm, VCV_sp, comm_kronecker=NULL, force.PD=FALSE)

Arguments

comm

A data frame describing species (column) abundance / presence-absencene in each site, or sample in general (row).

VCV_sp

A phylogenetic covariance (not correlation!) matrix based on any evolutionary models.

comm_kronecker

For internal calculation only in EcoCoMix.

force.PD

Forcing Positive Definite using nearPD. Defaulted as FALSE.

Details

The function upscales species-level covariance to community-level covariance, which is subsequently converted to a correlation matrix.

Value

corM

Expected correlation between communities.

covM

Expected covariance between communities.

comm_kronecker

For internal uses to speed up the optimization processes.

References

Author

Toby P.N. Tsang

Note

See also

Examples

library(phytools)
library(tidyverse)
library(EcoCoMix)
library(ape)
library(DHARMa)

data(KSR)
data(KSR_MLtree)
data(KSR_EF)

phy_comm_M <- get_comm_pair_r(KSR,vcv(KSR_MLtree))$corM

## if you prefer other evolutionary models
library(geiger)

KSR_tree_ou <- rescale(KSR_MLtree, model = "OU", alpha = 0.1) #alpha can be other values! see the documentations in geiger for details and other models
plot(KSR_tree_ou)
plot(KSR_MLtree) #compare two trees

phy_comm_M_ou <- get_comm_pair_r(KSR,vcv(KSR_tree_ou))$corM