This function computes the standard effect size of PD by correcting for changes in species richness. The novelty of this function is its ability to utilize sparse community matrix making it possible to efficiently randomize very large community matrices spanning thousands of taxa and sites.

`PD_ses(x, phy, model = c("tipshuffle", "rowwise", "colwise"), reps = 10, ...)`

- x
a (sparse) community matrix, i.e. an object of class matrix or Matrix.

- phy
a phylogenetic tree (object of class phylo).

- model
The null model for separating patterns from processes and for contrasting against alternative hypotheses. Available null models include:

“tipshuffle”: shuffles tip labels multiple times.

“rowwise”: shuffles sites (i.e., varying richness) and keeping species occurrence frequency constant.

“colwise”: shuffles species occurrence frequency and keeping site richness constant.

- reps
Number of replications.

- ...
Further arguments passed to or from other methods.

A data frame of results for each community or grid cell

grids: Site identity

richness: Number of taxa in community

PD_obs: Observed PD in community

pd_rand_mean: Mean PD in null communities

pd_rand_sd: Standard deviation of PD in null communities

pd_obs_rank: Rank of observed PD vs. null communities

pd_obs_z: Standardized effect size of PD vs. null communities \(= (PD_obs - pd_rand_mean) / pd_rand_sd\)

pd_obs_p: P-value (quantile) of observed PD vs. null communities \(= mpd_obs_rank / iter + 1\)

reps: Number of replicates

Proches, S., Wilson, J.R.U. & Cowling, R.M. (2006) How much evolutionary
history in a 10 x 10m plot? *Proceedings of Royal Society B*
**273**: 1143-1148.

```
library(ape)
library(Matrix)
tree <- read.tree(text ="((t1:1,t2:1)N2:1,(t3:1,t4:1)N3:1)N1;")
com <- sparseMatrix(c(1,3,4,1,4,5,1,2,3,4,5,6,3,4,6),
c(1,1,1,2,2,2,3,3,3,3,3,3,4,4,4),x=1,
dimnames = list(paste0("g", 1:6), tree$tip.label))
PD_ses(com, tree, model="rowwise")
#> grids richness PD_obs pd_rand_mean pd_rand_sd pd_obs_rank zscore
#> 1 g1 3 5 4.1 2.100000 8.0 0.6210590
#> 2 g2 1 2 4.4 2.044444 1.5 -1.6785087
#> 3 g3 3 5 4.2 1.955556 7.5 0.5720776
#> 4 g4 4 6 4.4 1.377778 10.5 1.3631084
#> 5 g5 2 4 4.0 2.444444 5.0 0.0000000
#> 6 g6 2 3 3.9 1.877778 4.0 -0.6567807
#> pd_obs_p reps
#> 1 0.7272727 10
#> 2 0.1363636 10
#> 3 0.6818182 10
#> 4 0.9545455 10
#> 5 0.4545455 10
#> 6 0.3636364 10
```