Determine habitat-species associations with code developed by Sabrina Russo, Daniel Zuleta, Matteo Detto, and Kyle Harms.

tt_test(tree, habitat, sp = NULL, plotdim = NULL, gridsize = NULL)

## Arguments

tree A dataframe; a ForestGEO tree table (see details). Object giving the habitat designation for each plot partition defined by gridsize. See fgeo_habitat(). Character sting giving any number of species-names. Plot dimensions and gridsize. If NULL (default) they will be guessed, and a message will inform you of the chosen values. If the guess is wrong, you should provide the correct values manually (and check that your habitat data is correct).

## Value

A list of matrices.

## Details

This test only makes sense at the population level. We are interested in knowing whether or not individuals of a species are aggregated on a habitat. Multiple stems of an individual do not represent population level processes but individual level processes. Thus, you should use data of individual trees -- i.e. use a tree table, and not a stem table with potentially multiple stems per tree.

You should only try to determine the habitat association for sufficiently abundant species. In a 50-ha plot, a minimum abundance of 50 trees/species has been used.

## Acknowledgments

Nestor Engone Obiang, David Kenfack, Jennifer Baltzer, and Rutuja Chitra-Tarak provided feedback. Daniel Zuleta provided guidance.

## Interpretation of Output

• N.Hab.1: Count of stems of the focal species in habitat 1.

• Gr.Hab.1: Count of instances the observed relative density of the focal species on habitat 1 was greater than the relative density based on the TT habitat map.

• Ls.Hab.1: Count of instances the observed relative density of the focal species on habitat 1 was less than the relative density based on the TT habitat map.

• Eq.Hab.1: Count of instances the observed relative density of the focal species on habitat 1 was equal to the relative density based on the TT habitat map. The sum of the Gr.Hab.x, Ls.Hab.x, and Eq.Hab.x columns for one habitat equals the number of 20 x20 quads in the plot. The Rep.Agg.Neut columns for each habitat indicate whether the species is significantly repelled (-1), aggregated (1), or neutrally distributed (0) on the habitat in question.

The probabilities associated with the test for whether these patterns are statistically significant are in the Obs.Quantile columns for each habitat. Note that to calculate the probability for repelled, it is the value given, but to calculate the probability for aggregated, it is one minus the value given.

Values of the Obs.Quantile < 0.025 means that the species is repelled from that habitat, while values of the Obs.Quantile > 0.975 means that the species is aggregated on that habitat.

## References

Zuleta, D., Russo, S.E., Barona, A. et al. Plant Soil (2018). https://doi.org/10.1007/s11104-018-3878-0.

summary.tt_lst(), summary.tt_df(), as_tibble(), fgeo_habitat().

Other habitat functions: fgeo_habitat(), fgeo_topography()

## Author

Sabrina Russo, Daniel Zuleta, Matteo Detto, and Kyle Harms.

## Examples

library(fgeo.tool)
assert_is_installed("fgeo.x")

# Example data
tree <- fgeo.x::tree6_3species
elevation <- fgeo.x::elevation

# Pick alive trees, of 10 mm or more
census <- filter(tree, status == "A", dbh >= 10)

# Pick sufficiently abundant species
pick <- filter(dplyr::add_count(census, sp), n > 50)

# Use your habitat data or create it from elevation data
habitat <- fgeo_habitat(elevation, gridsize = 20, n = 4)

# Defaults to using all species
as_tibble(
tt_test(census, habitat)
)
#> Using plotdim = c(320, 500). To change this value see ?tt_test().#> Using gridsize = 20. To change this value see ?tt_test().#> # A tibble: 12 x 8
#>    habitat sp     N.Hab Gr.Hab Ls.Hab Eq.Hab Rep.Agg.Neut Obs.Quantile
#>  * <chr>   <chr>  <dbl>  <dbl>  <dbl>  <dbl>        <dbl>        <dbl>
#>  1 1       CASARB    29   1242    356      2            0        0.776
#>  2 2       CASARB    20    390   1206      4            0        0.244
#>  3 3       CASARB    12    778    817      5            0        0.486
#>  4 4       CASARB     5    932    658     10            0        0.582
#>  5 1       PREMON    91   1093    504      3            0        0.683
#>  6 2       PREMON    89   1254    344      2            0        0.784
#>  7 3       PREMON    40    305   1292      3            0        0.191
#>  8 4       PREMON    14    270   1322      8            0        0.169
#>  9 1       SLOBER    18    273   1324      3            0        0.171
#> 10 2       SLOBER    24    810    788      2            0        0.506
#> 11 3       SLOBER    17   1155    440      5            0        0.722
#> 12 4       SLOBER     7   1292    303      5            0        0.808
Reduce(rbind, tt_test(census, habitat))
#> Using plotdim = c(320, 500). To change this value see ?tt_test().#> Using gridsize = 20. To change this value see ?tt_test().#>        N.Hab.1 Gr.Hab.1 Ls.Hab.1 Eq.Hab.1 Rep.Agg.Neut.1 Obs.Quantile.1 N.Hab.2
#> CASARB      29     1242      356        2              0       0.776250      20
#> PREMON      91     1093      504        3              0       0.683125      89
#> SLOBER      18      273     1324        3              0       0.170625      24
#>        Gr.Hab.2 Ls.Hab.2 Eq.Hab.2 Rep.Agg.Neut.2 Obs.Quantile.2 N.Hab.3
#> CASARB      390     1206        4              0        0.24375      12
#> PREMON     1254      344        2              0        0.78375      40
#> SLOBER      810      788        2              0        0.50625      17
#>        Gr.Hab.3 Ls.Hab.3 Eq.Hab.3 Rep.Agg.Neut.3 Obs.Quantile.3 N.Hab.4
#> CASARB      778      817        5              0       0.486250       5
#> PREMON      305     1292        3              0       0.190625      14
#> SLOBER     1155      440        5              0       0.721875       7
#>        Gr.Hab.4 Ls.Hab.4 Eq.Hab.4 Rep.Agg.Neut.4 Obs.Quantile.4
#> CASARB      932      658       10              0        0.58250
#> PREMON      270     1322        8              0        0.16875
#> SLOBER     1292      303        5              0        0.80750
some_species <- c("CASARB", "PREMON")
result <- tt_test(census, habitat, sp = some_species)
#> Using plotdim = c(320, 500). To change this value see ?tt_test().#> Using gridsize = 20. To change this value see ?tt_test().summary(result)
#> # A tibble: 8 x 3
#>   sp     habitat association
#>   <chr>  <chr>   <chr>
#> 1 CASARB 1       neutral
#> 2 CASARB 2       neutral
#> 3 CASARB 3       neutral
#> 4 CASARB 4       neutral
#> 5 PREMON 1       neutral
#> 6 PREMON 2       neutral
#> 7 PREMON 3       neutral
#> 8 PREMON 4       neutral