getRedundancy
examines which species have an effect on which function
getRedundancy(
vars,
species,
data,
negVars = NA,
method = "lm",
combine = "+",
output = "effect",
...
)
Vector of column names of functions
Vector of column names of species
data frame with species presence/absence of values of functions
Vector of names of species for which a negative coefficient is actually a positive effect.
Fitting function for statistical models. Defaults to lm
.
How are species combined in the model? Defaults to "+" for additive combinations.
Will the output be sign of effect or "coefficient". Defaults to "effect"
Other arguments to be supplied to fitting function.
Returns a matrix of functions and the effect of species on each. 1s, -1s, and 0s for "effect" or coefficients.
getRedundancy takes a matrix of 1s,0s, and -1s, and depending on whether we're interested in positive, negative, or both types of interactions looks for the m-wise overlap between species and returns the overlap index for each combination. For species whose effect is not different from 0 at the alpha=0.05 level, a 0 is returned.
data(all_biodepth)
allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3)
germany <- subset(all_biodepth, all_biodepth$location == "Germany")
vars <- whichVars(germany, allVars)
species <- relevantSp(germany, 26:ncol(germany))
# re-normalize N.Soil so that everything is on the same
# sign-scale (e.g. the maximum level of a function is
# the "best" function)
germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE)
res.list <- lapply(vars, function(x) sAICfun(x, species, germany))
names(res.list) <- vars
getRedundancy(vars, species, germany)
#> ACHMIL1 ALOPRA1 ANTODO1 ARRELA1 BROHOR1 CAMPAT1 CENJAC1 CHRLEU1
#> biomassY3 0 0 0 0 0 -1 0 0
#> root3 1 0 -1 0 1 0 0 0
#> N.g.m2 1 0 0 -1 0 0 0 0
#> N.Soil -1 0 -1 0 1 -1 0 0
#> cotton3 0 1 1 0 -1 1 0 0
#> CREBIE1 CYNCRI1 DACGLO1 FESPRA1 FESRUB1 GERPRA1 HOLLAN1 KNAARV1
#> biomassY3 0 0 1 1 0 0 0 0
#> root3 0 0 0 0 1 0 -1 0
#> N.g.m2 -1 0 0 1 0 0 -1 0
#> N.Soil 1 0 1 -1 0 0 0 0
#> cotton3 0 0 0 0 0 0 0 0
#> LATPRA1 LEOAUT1 LOLPER1 LOTCOR1 LYCFLO1 PHLPRA1 PIMMAJ1 PLALAN1
#> biomassY3 1 0 0 1 0 -1 0 0
#> root3 1 0 1 0 0 0 0 -1
#> N.g.m2 0 0 1 1 0 -1 0 -1
#> N.Soil 1 0 0 1 0 1 0 0
#> cotton3 -1 0 -1 0 0 0 0 1
#> RANACR1 RUMACE1 TAROFF1 TRIPRA1 TRIREP1 VICCRA1 VICSEP1
#> biomassY3 -1 0 0 1 1 0 0
#> root3 -1 0 0 -1 0 0 0
#> N.g.m2 -1 0 0 1 1 0 0
#> N.Soil 1 0 0 -1 -1 0 0
#> cotton3 0 0 0 1 1 0 0
getRedundancy(vars, species, germany, output = "coef")
#> ACHMIL1 ALOPRA1 ANTODO1 ARRELA1 BROHOR1 CAMPAT1
#> biomassY3 0.000000 0.0000000 0.000000 0.00000 0.000000 -391.540481
#> root3 272.991016 0.0000000 -571.150022 0.00000 587.863696 0.000000
#> N.g.m2 4.109668 0.0000000 0.000000 -1.17057 0.000000 0.000000
#> N.Soil -2.959283 0.0000000 -5.617769 0.00000 5.345391 -12.737858
#> cotton3 0.000000 0.1467602 0.731233 0.00000 -1.321429 1.156991
#> CENJAC1 CHRLEU1 CREBIE1 CYNCRI1 DACGLO1 FESPRA1 FESRUB1
#> biomassY3 0 0 0.000000 0 104.6404435 135.673497 0.0000
#> root3 0 0 0.000000 0 0.0000000 0.000000 178.9424
#> N.g.m2 0 0 -6.776658 0 0.0000000 3.756992 0.0000
#> N.Soil 0 0 8.236584 0 0.7453909 -2.443815 0.0000
#> cotton3 0 0 0.000000 0 0.0000000 0.000000 0.0000
#> GERPRA1 HOLLAN1 KNAARV1 LATPRA1 LEOAUT1 LOLPER1
#> biomassY3 0 0.000000 0 248.5566235 0 0.0000000
#> root3 0 -214.696426 0 287.3434785 0 199.2160090
#> N.g.m2 0 -1.698125 0 0.0000000 0 1.2906223
#> N.Soil 0 0.000000 0 4.4593689 0 0.0000000
#> cotton3 0 0.000000 0 -0.5438722 0 -0.1425796
#> LOTCOR1 LYCFLO1 PHLPRA1 PIMMAJ1 PLALAN1 RANACR1
#> biomassY3 375.6694108 0 -297.745234 0 0.0000000 -140.299570
#> root3 0.0000000 0 0.000000 0 -175.4607922 -256.256291
#> N.g.m2 6.4545997 0 -5.848686 0 -2.3781127 -4.241040
#> N.Soil 0.9476914 0 2.961038 0 0.0000000 1.916584
#> cotton3 0.0000000 0 0.000000 0 0.2857972 0.000000
#> RUMACE1 TAROFF1 TRIPRA1 TRIREP1 VICCRA1 VICSEP1 (Intercept)
#> biomassY3 0 0 492.6310845 325.0173186 0 0 335.8381534
#> root3 0 0 -365.4605275 0.0000000 0 0 493.2942339
#> N.g.m2 0 0 9.7848085 5.6081898 0 0 4.4518926
#> N.Soil 0 0 -1.6228624 -1.6007980 0 0 3.0173086
#> cotton3 0 0 0.3061938 0.1633488 0 0 0.4875589
#########
# takes a vector of responses, the species that may cause them
# and returns a table of 1s, -1s, and 0s with regards to the kind of effect
# or a coefficient table, if asked for. Arugments can take the form of the fitting function
# how variables are combined, and additional arguments to the fitting function
#########