Fits linear regression models to getAlphaMetrics
or getBetaMetrics
outputs
getLinearRegressions(x, divType, pThreshold = 0.05)
(`data.frame`) BioTIME data table in the format of the output of getAlphaMetrics
or getBetaMetrics
functions
(`character`) string specifying the nature of the metrics in the data; either `divType = "alpha"` or `divType = "beta"` are supported
(`numeric`) P-value threshold for statistical significance
Returns a single long `data.frame` with results of linear regressions (slope, p-value, significance, intercept) for each `assemblageID`.
The function `getLinearRegressions` fits simple linear regression models
(see lm
for details) for a given output ('data') of
either getAlphaMetrics
or getBetaMetrics
function.
`divType` needs to be specified in agreement with x.
The typical model has the form `metric ~ year`. Note that assemblages with
less than 3 time points and/or single species time series are removed.
library(BioTIMEr)
x <- data.frame(
resamp = 1L,
YEAR = rep(rep(2010:2015, each = 4), times = 4),
Species = c(replicate(n = 8L * 6L, sample(letters[1L:10L], 4L, replace = FALSE))),
ABUNDANCE = rpois(24 * 8, 10),
assemblageID = rep(LETTERS[1L:8L], each = 24)
)
alpham <- getAlphaMetrics(x, "ABUNDANCE")
getLinearRegressions(x = alpham, divType = "alpha", pThreshold = 0.01)
#> assemblageID metric slope pvalue significance intercept
#> 1 A S -3.107977e-16 0.15830242 0 4.0000000
#> 2 A N 5.142857e-01 0.73574423 0 -996.0000000
#> 3 A maxN 2.857143e-01 0.44309550 0 -562.3333333
#> 4 A Shannon -5.758225e-03 0.30236885 0 12.9422796
#> 5 A expShannon -2.227334e-02 0.30292278 0 48.6981242
#> 6 A Simpson -2.402394e-03 0.35841891 0 5.5693803
#> 7 A invSimpson -3.423477e-02 0.35674727 0 72.6690839
#> 8 A PIE -2.821972e-03 0.23666233 0 6.4333956
#> 9 A DomMc 7.291372e-03 0.47732172 0 -14.0782629
#> 10 B S -3.107977e-16 0.15830242 0 4.0000000
#> 11 B N -2.200000e+00 0.18192692 0 4470.6666667
#> 12 B maxN -6.000000e-01 0.23922039 0 1221.0000000
#> 13 B Shannon 3.840950e-04 0.90030393 0 0.5915529
#> 14 B expShannon 1.513707e-03 0.89976225 0 0.8677931
#> 15 B Simpson 1.480193e-04 0.92235881 0 0.4413485
#> 16 B invSimpson 2.282610e-03 0.91908257 0 -0.7574950
#> 17 B PIE 1.110538e-03 0.53258719 0 -1.4778265
#> 18 B DomMc -3.949643e-03 0.65855030 0 8.5349323
#> 19 C S -3.107977e-16 0.15830242 0 4.0000000
#> 20 C N 1.085714e+00 0.65998015 0 -2144.6666667
#> 21 C maxN 8.571429e-02 0.93219338 0 -159.6666667
#> 22 C Shannon 3.343473e-03 0.61126646 0 -5.3703004
#> 23 C expShannon 1.308534e-02 0.60599779 0 -22.4432399
#> 24 C Simpson 1.605056e-03 0.61541498 0 -2.4936217
#> 25 C invSimpson 2.374582e-02 0.59426732 0 -43.9868363
#> 26 C PIE 1.283113e-03 0.75385886 0 -1.8261521
#> 27 C DomMc -7.875746e-03 0.53776956 0 16.4408940
#> 28 D S -3.107977e-16 0.15830242 0 4.0000000
#> 29 D N -1.657143e+00 0.35893154 0 3376.3333333
#> 30 D maxN -8.000000e-01 0.19109390 0 1622.6666667
#> 31 D Shannon 1.003069e-02 0.38080347 0 -18.8304090
#> 32 D expShannon 3.787758e-02 0.37777015 0 -72.3437232
#> 33 D Simpson 4.069569e-03 0.36702893 0 -7.4529938
#> 34 D invSimpson 5.473941e-02 0.35592173 0 -106.3487716
#> 35 D PIE 4.952343e-03 0.28777093 0 -9.2109258
#> 36 D DomMc -1.343588e-02 0.24354342 0 27.6190238
#> 37 E S -3.107977e-16 0.15830242 0 4.0000000
#> 38 E N -2.885714e+00 0.09328259 0 5844.3333333
#> 39 E maxN -1.200000e+00 0.04850207 0 2427.0000000
#> 40 E Shannon 5.895111e-03 0.66405610 0 -10.5273943
#> 41 E expShannon 2.232176e-02 0.66163592 0 -41.1130975
#> 42 E Simpson 2.653950e-03 0.67376635 0 -4.6146157
#> 43 E invSimpson 3.613205e-02 0.65785939 0 -69.0401107
#> 44 E PIE 4.278170e-03 0.47719905 0 -7.8624809
#> 45 E DomMc -8.254372e-03 0.71181448 0 17.2324562
#> 46 F S -3.107977e-16 0.15830242 0 4.0000000
#> 47 F N -1.457143e+00 0.30520964 0 2970.3333333
#> 48 F maxN -5.428571e-01 0.44166412 0 1106.0000000
#> 49 F Shannon -5.266059e-03 0.30973599 0 11.9368477
#> 50 F expShannon -2.036605e-02 0.30478140 0 44.8021479
#> 51 F Simpson -2.187671e-03 0.39730013 0 5.1291559
#> 52 F invSimpson -3.086145e-02 0.37816110 0 65.7683495
#> 53 F PIE -1.513209e-03 0.58482672 0 3.7918352
#> 54 F DomMc 9.682286e-03 0.31642767 0 -18.8627097
#> 55 G S -3.107977e-16 0.15830242 0 4.0000000
#> 56 G N 1.342857e+00 0.11493484 0 -2662.3333333
#> 57 G maxN 2.000000e-01 0.65604501 0 -389.6666667
#> 58 G Shannon 8.336247e-03 0.21346940 0 -15.4197793
#> 59 G expShannon 3.195469e-02 0.21835832 0 -60.4234994
#> 60 G Simpson 3.942136e-03 0.21415564 0 -7.1976704
#> 61 G invSimpson 5.397041e-02 0.23225069 0 -104.8224376
#> 62 G PIE 3.423890e-03 0.28410666 0 -6.1357958
#> 63 G DomMc -1.549048e-02 0.27141748 0 31.7651030
#> 64 H S -3.107977e-16 0.15830242 0 4.0000000
#> 65 H N 6.571429e-01 0.62774617 0 -1281.0000000
#> 66 H maxN -8.571429e-02 0.83723503 0 186.3333333
#> 67 H Shannon 3.560668e-03 0.70628782 0 -5.8190523
#> 68 H expShannon 1.404620e-02 0.69652273 0 -24.4211123
#> 69 H Simpson 1.701259e-03 0.72066897 0 -2.6935016
#> 70 H invSimpson 2.627942e-02 0.67753410 0 -49.1680220
#> 71 H PIE 1.398106e-03 0.76332879 0 -2.0651628
#> 72 H DomMc -6.990848e-03 0.60026511 0 14.6718733
betam <- getBetaMetrics(x = x, "ABUNDANCE")
getLinearRegressions(x = betam, divType = "beta")
#> assemblageID metric slope pvalue significance
#> 1 A JaccardDiss 1.360544e-03 0.97046305 0
#> 2 A MorisitaHornDiss 9.841470e-03 0.87190107 0
#> 3 A BrayCurtisDiss 6.636539e-03 0.89905959 0
#> 4 B JaccardDiss 5.442177e-03 0.80472616 0
#> 5 B MorisitaHornDiss 2.997411e-02 0.39077069 0
#> 6 B BrayCurtisDiss 2.104152e-02 0.39979325 0
#> 7 C JaccardDiss 4.217687e-02 0.19801121 0
#> 8 C MorisitaHornDiss 5.461290e-02 0.43214146 0
#> 9 C BrayCurtisDiss 5.501330e-02 0.23967321 0
#> 10 D JaccardDiss 2.176871e-02 0.41443008 0
#> 11 D MorisitaHornDiss 6.857852e-03 0.76525585 0
#> 12 D BrayCurtisDiss 6.510857e-03 0.78460721 0
#> 13 E JaccardDiss 4.353741e-02 0.04179468 1
#> 14 E MorisitaHornDiss 3.003240e-02 0.21857868 0
#> 15 E BrayCurtisDiss 2.732037e-02 0.15155042 0
#> 16 F JaccardDiss 2.095238e-02 0.76959776 0
#> 17 F MorisitaHornDiss 1.051040e-02 0.89760269 0
#> 18 F BrayCurtisDiss 9.607321e-03 0.88707127 0
#> 19 G JaccardDiss -3.809524e-02 0.40253179 0
#> 20 G MorisitaHornDiss -6.556932e-03 0.91582065 0
#> 21 G BrayCurtisDiss -1.950260e-02 0.71727617 0
#> 22 H JaccardDiss 1.177686e-15 1.00000000 0
#> 23 H MorisitaHornDiss -3.801627e-02 0.26896508 0
#> 24 H BrayCurtisDiss -2.381045e-02 0.35833029 0
#> intercept
#> 1 -1.9206349
#> 2 -19.1115868
#> 3 -12.6197771
#> 4 -10.2539683
#> 5 -59.7183533
#> 6 -41.6873009
#> 7 -84.0634921
#> 8 -109.2510218
#> 9 -109.9890571
#> 10 -43.0158730
#> 11 -13.1404644
#> 12 -12.3967423
#> 13 -86.8253968
#> 14 -59.7778659
#> 15 -54.2865738
#> 16 -41.4698413
#> 17 -20.5672184
#> 18 -18.6778010
#> 19 77.3523810
#> 20 13.8353773
#> 21 39.8864960
#> 22 0.7301587
#> 23 77.1148378
#> 24 48.5723331