Significance tests between sets of weights
lands.grp.test.Rd
lands.grp.test()
performs a statistical test for whether the optimal adaptive landscape for two subgroups are significantly different from each other. The p-value of the test is the proportion of weight sets that are shared between the two subgroups among their respective top weight sets. multi.lands.grp.test()
performs this test for all pairs of subgroups.
Usage
lands.grp.test(grpa, grpb, method = "chi-squared",
quantile = 0.05)
multi.lands.grp.test(x, method = "chi-squared",
quantile = 0.05)
# S3 method for lands.grp.test
print(x, digits = max(3L, getOption("digits") - 3L), ...)
# S3 method for multi.lands.grp.test
print(x, digits = max(3L, getOption("digits") - 3L),
style = "matrix", ...)
Arguments
- grpa, grpb
for
lands.grp.test()
, the twogrp_Wprime
objects containing the adaptive landscapes to be compared; these are the output of calls tocalcGrpWprime
.- x
for
multi.lands.grp.test()
, aby_Wprime
object, the output of a call tocalcWprimeBy
.for
print()
, the output of a call tolands.grp.test()
ormulti.lands.grp.test()
.- method
the method used to determine which sets of weights are in the "best" sets of weights that are to be comapred between the two groups. Allowable options include
"chi-squared"
and"quantile"
. SeecalcGrpWprime
for details.- quantile
the top quantile used to determine the best sets of weights to be included in the average to compute the optimal set of weights. Should be a number between 0 and 1, with a low value indicating that only the few top sets of weights will be used. See
calcGrpWprime
for details.- digits
the number of significant digits to print.
- style
how to display the results of the pairwise tests; allowable options include
"matrix"
and"table"
. Abbreviations allowed.- ...
passed to
print.default
.
Details
lands.grp.test()
performs pairwise comparisons between two adaptive groups by comparing the number of shared landscapes \(n_{A+B}\) in the top percentile of each group with the total number of landscapes in this top percentile \(n_{total}\). The probability \(P(A=B)\) thus is calculated as:
$$ P(A=B) = n_{A+B}/n_{total} $$
If method = "quantile"
is used, then the top percentile is defined by quantile
. If method = "chi-squared"
is used, then the top percentile is calculated from the chi-squared value \(\chi^2_i\) as: $$\chi^2_i = -2 \log \frac{Z_{max}}{Z_i}$$ where \(Z_{max}\) is the largest \(Z\) among the weights, and a p-value is computed for each \(\chi^2_i\) value using a \(\chi^2\) distribution with 2 d.f.; any set of weights with a p-value less than quantile
is included in the optimal set of weights.
multi.lands.grp.test()
is a wrapper for lands.grp.test()
, applying the function pairwise to all combinations of groups calculated by calcWprimeBy
.
Value
For lands.grp.test()
, a lands.grp.test
object containing the following components:
- n.match
the number of sets of weights that match between the two supplied subgroups
- p.val
the p-value of the test, computed as the number of sets of weights that match divided by the number of sets of weights compared
- matching
a matrix containing the sets of weights that match between the two subgroups
- method
the argument supplied to
method
- quantile
the argument supplied to
quantile
For multi.lands.grp.test()
, a multi.lands.grp.test
object containing the following components:
- res
a data frame containing the results of the tests, with the columns
Group A
andGroup B
indicating the groups involved in the comparison, the columnMatches
containing the number of matching sets of weights in the comparison, and the columnp value
containing the p-value of the test.- method
the argument supplied to
method
- quantile
the argument supplied to
quantile
For print.multi.lands.grp.test()
, setting style = "table"
prints the res
component as-is; setting style = "matrix"
creates a matrix where the p-values of the test are below the diagonal and the number of matches of the test are above the diagonal.
References
Jones, K. E., Dickson, B. V., Angielczyk, K. D., & Pierce, S. E. (2021). Adaptive landscapes challenge the "lateral-to-sagittal"" paradigm for mammalian vertebral evolution. Current Biology, 31(9), 1883-1892.
See also
calcGrpWprime
and calcWprimeBy
for creatign the objects used as inputs to these functions
Examples
data("warps")
data("turtles")
warps_fnc <- as_fnc_df(warps,
func.names = c("hydro", "fea"))
kr_surf <- krige_surf(warps_fnc, new_data = turtles)
#> [using ordinary kriging]
#> [using ordinary kriging]
#> [using ordinary kriging]
#> [using ordinary kriging]
grid_weights <- generate_weights(n = 3, data = kr_surf)
#> 4 rows generated
all_lscps <- calc_all_lscps(kr_surf,
grid_weights = grid_weights)
# Comparing adaptive landscapes of Ecology groups S and M
wprime_S <- calcGrpWprime(all_lscps,
index = Ecology == "S")
wprime_M <- calcGrpWprime(all_lscps,
index = Ecology == "M")
lands.grp.test(wprime_S, wprime_M)
#> Landscape group test
#> - method: chi-squared | quantile: 0.05
#>
#> Number of matches: 0
#> P-value: 0
# Comparing adaptive landscapes of all Group subgroups
wprime_by_Group <- calcWprimeBy(all_lscps, by = ~Group)
tests <- multi.lands.grp.test(wprime_by_Group)
tests
#> Pairwise landscape group tests
#> - method: chi-squared | quantile: 0.05
#>
#> Results:
#> box turtle brackish fathead freshwater sea turtle softshell tortoise
#> box turtle - 1 2 1 1 1 2
#> brackish 0.25 - 1 1 0 1 0
#> fathead 0.5 1 - 1 0 1 0
#> freshwater 0.25 1 0.5 - 0 1 0
#> sea turtle 0.25 0 0 0 - 0 1
#> softshell 0.25 1 0.5 1 0 - 0
#> tortoise 0.5 0 0 0 1 0 -
#> (lower triangle: p-values | upper triangle: number of matches)
print(tests, style = "table")
#> Pairwise landscape group tests
#> - method: chi-squared | quantile: 0.05
#>
#> Results:
#> Group A Group B Matches p value
#> 1 box turtle brackish 1 0.25
#> 2 box turtle fathead 2 0.50
#> 3 box turtle freshwater 1 0.25
#> 4 box turtle sea turtle 1 0.25
#> 5 box turtle softshell 1 0.25
#> 6 box turtle tortoise 2 0.50
#> 7 brackish fathead 1 1.00
#> 8 brackish freshwater 1 1.00
#> 9 brackish sea turtle 0 0.00
#> 10 brackish softshell 1 1.00
#> 11 brackish tortoise 0 0.00
#> 12 fathead freshwater 1 0.50
#> 13 fathead sea turtle 0 0.00
#> 14 fathead softshell 1 0.50
#> 15 fathead tortoise 0 0.00
#> 16 freshwater sea turtle 0 0.00
#> 17 freshwater softshell 1 1.00
#> 18 freshwater tortoise 0 0.00
#> 19 sea turtle softshell 0 0.00
#> 20 sea turtle tortoise 1 1.00
#> 21 softshell tortoise 0 0.00