#clear environment
rm(list = ls())
#Set working directory and CRAN mirror
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir = "C:/Users/aliso/OneDrive/Documents/SUNY/THESIS/R/Second Round/Shiny")
options(repos = "https://cloud.r-project.org")

#Data
NestedMatrix <- read.csv("Data/NestedMatrixCSV.csv")
#Omit Site names (not numeric)
original_data <- NestedMatrix[, -1]

Data cleaning & preparation

Normality tests

#Shapiro-Wilks to test for normality of distribution for all variables

shapiro.test(original_data$Allicin)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Allicin
## W = 0.85567, p-value = 0.002261
shapiro.test(original_data$Fresh)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Fresh
## W = 0.91851, p-value = 0.04738
shapiro.test(original_data$Dry)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Dry
## W = 0.95257, p-value = 0.2863
shapiro.test(original_data$Bulb)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Bulb
## W = 0.95496, p-value = 0.3233
shapiro.test(original_data$BulbWidth)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$BulbWidth
## W = 0.95509, p-value = 0.3254
shapiro.test(original_data$SLA)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$SLA
## W = 0.94682, p-value = 0.2124
shapiro.test(original_data$N)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$N
## W = 0.78958, p-value = 0.0001531
shapiro.test(original_data$C)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$C
## W = 0.68324, p-value = 4.372e-06
shapiro.test(original_data$OM)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$OM
## W = 0.89172, p-value = 0.01217
shapiro.test(original_data$pH)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$pH
## W = 0.85499, p-value = 0.002194
shapiro.test(original_data$Mg)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Mg
## W = 0.80089, p-value = 0.0002352
shapiro.test(original_data$Ca)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Ca
## W = 0.84834, p-value = 0.001638
shapiro.test(original_data$Al)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Al
## W = 0.83346, p-value = 0.0008686
shapiro.test(original_data$Fe)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Fe
## W = 0.85574, p-value = 0.002268
shapiro.test(original_data$Mn)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Mn
## W = 0.83814, p-value = 0.001058
shapiro.test(original_data$P)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$P
## W = 0.86403, p-value = 0.00329
shapiro.test(original_data$S)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$S
## W = 0.75602, p-value = 4.567e-05
shapiro.test(original_data$Slope)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Slope
## W = 0.80783, p-value = 0.000308
shapiro.test(original_data$Aspect)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$Aspect
## W = 0.84866, p-value = 0.001661
shapiro.test(original_data$PPFD1)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFD1
## W = 0.85326, p-value = 0.002032
shapiro.test(original_data$PPFD2)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFD2
## W = 0.77704, p-value = 9.64e-05
shapiro.test(original_data$PPFD3)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFD3
## W = 0.73994, p-value = 2.639e-05
shapiro.test(original_data$PPFD4)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFD4
## W = 0.82091, p-value = 0.0005182
shapiro.test(original_data$PPFD5)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFD5
## W = 0.82775, p-value = 0.0006853
shapiro.test(original_data$PPFD6)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFD6
## W = 0.75279, p-value = 4.085e-05
shapiro.test(original_data$PPFDROC)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$PPFDROC
## W = 0.79205, p-value = 0.000168
shapiro.test(original_data$WeeklyTempROC)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$WeeklyTempROC
## W = 0.71646, p-value = 1.224e-05
shapiro.test(original_data$TempMax)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$TempMax
## W = 0.87007, p-value = 0.00434
shapiro.test(original_data$TempMin)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$TempMin
## W = 0.81974, p-value = 0.0004945
shapiro.test(original_data$TempMean)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$TempMean
## W = 0.7736, p-value = 8.509e-05
shapiro.test(original_data$TempROC)
## 
##  Shapiro-Wilk normality test
## 
## data:  original_data$TempROC
## W = 0.87582, p-value = 0.005673

Multiple variables reject the null hypothesis of normally distributed data.

Visualization of distribution

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(tidyr)
#Gathered data into long format for simultaneous visualization.
gathered_data <- original_data %>%
  pivot_longer(
  cols = everything(),
  names_to = "variable",
  values_to = "value")
ggplot(gathered_data, aes(x = variable, y = value, fill = variable)) + geom_violin(trim = FALSE, alpha = 0.7) + labs(title = "Original Distributions of Variables", x = "Variable", y = "Value") + facet_wrap(~variable, scales = "free") + theme_minimal()

For analyses that assume normality, opted to first log-transform data to account for majority right-skewed distribution, followed by standardization to a mean of 0 and a standard deviation of 1 to account for differences in scales of each variable. Otherwise, ordination will just use standardized data.

Transformation and Standardization

#Log transformation and subsequent z-score standardization
original_data_log <- original_data
original_data_log[, sapply(original_data_log, is.numeric)] <- log(original_data_log[, sapply(original_data_log, is.numeric)] + 1)
logzdata <- as.data.frame(scale(original_data_log))


#Plot all transformed/standardized variables
gathered_logzdata <- gather(logzdata, key = "variable", value = "value")
ggplot(gathered_logzdata, aes(x = variable, y = value, fill = variable)) + geom_violin(trim = FALSE, alpha = 0.7) + labs(title = "Transformed Distributions of Variables", x = "Variable", y = "Value") + facet_wrap(~variable, scales = "free") + theme_minimal()

#Create data frame - only z-score standardization
zdata <- as.data.frame(scale(original_data))

Data exploration - Addressing multicollinearity

Using Pearson correlation coefficients in a heat map

library(heatmaply)
library(dplyr)
cor_matrix <- cor(zdata, method = "pearson")
heatmaply(cor_matrix, symm = TRUE, scale_fill_gradient_fun = "viridis", plot_method = "plotly", width = 800, height = 600, main = "Interactive Pearson Correlation Coefficient HeatMap", limits = c(-1, 1))
# Get the absolute values of the correlation matrix
abs_cor_matrix <- abs(cor_matrix)

# Get only the upper triangle of the absolute correlation matrix (excluding the diagonal) to avoid duplication
upper_tri <- upper.tri(abs_cor_matrix, diag = FALSE)

# Get the indices of the highest absolute correlation values
indices <- which(upper_tri, arr.ind = TRUE)

# Data frame to store variable pairs and their correlation coefficients
variable_pairs <- data.frame(var1 = rownames(abs_cor_matrix)[indices[, 1]],
                              var2 = colnames(abs_cor_matrix)[indices[, 2]],
                              correlation = abs_cor_matrix[upper_tri])

# Remove duplicate pairs (e.g., var1-var2 and var2-var1)
variable_pairs <- variable_pairs[!duplicated(t(apply(variable_pairs[, 1:2], 1, sort))), ]

# Sort by correlation coefficient in descending order
variable_pairs <- variable_pairs[order(-variable_pairs$correlation), ]

# Print the variable pairs with the highest absolute correlation values
print(variable_pairs)
##              var1          var2 correlation
## 105            Al            Fe 0.993670396
## 76             pH            Ca 0.985890070
## 332             N       PPFDROC 0.985629388
## 343             S       PPFDROC 0.982663640
## 333             C       PPFDROC 0.974902207
## 101            pH            Fe 0.974320926
## 88             pH            Al 0.972929724
## 144             C             S 0.971883720
## 28              N             C 0.966496438
## 143             N             S 0.966088131
## 136            Mn             P 0.965931604
## 35              N            OM 0.963033288
## 389            Mg       TempMax 0.944750729
## 55             pH            Mg 0.934428214
## 104            Ca            Fe 0.933963076
## 346         PPFD1       PPFDROC 0.932268309
## 276         PPFD3         PPFD4 0.928408293
## 91             Ca            Al 0.928098025
## 77             Mg            Ca 0.924520233
## 219            OM         PPFD2 0.916584580
## 334            OM       PPFDROC 0.915490240
## 312             K         PPFD6 0.915293137
## 226            Mn         PPFD2 0.913180209
## 251        Aspect         PPFD3 0.909833702
## 320        Aspect         PPFD6 0.908862148
## 208             S         PPFD1 0.907696330
## 145            OM             S 0.900556470
## 197             N         PPFD1 0.890044975
## 217             N         PPFD2 0.876258644
## 89             Mg            Al 0.875804231
## 36              C            OM 0.870381763
## 392            Al       TempMax 0.869873403
## 388            pH       TempMax 0.862041805
## 477             K       TempROC 0.854937969
## 210        Aspect         PPFD1 0.852347647
## 228             S         PPFD2 0.852227448
## 102            Mg            Fe 0.851511523
## 464       TempMax      TempMean 0.847998744
## 199            OM         PPFD1 0.845972660
## 157          Bulb         Slope 0.843384478
## 218             C         PPFD2 0.836119841
## 198             C         PPFD1 0.834057122
## 292            Mn         PPFD5 0.833081341
## 393            Fe       TempMax 0.822998531
## 298         PPFD2         PPFD5 0.817003490
## 243             K         PPFD3 0.815636107
## 347         PPFD2       PPFDROC 0.808145589
## 391            Ca       TempMax 0.804541734
## 323         PPFD3         PPFD6 0.794929233
## 293             P         PPFD5 0.789373532
## 227             P         PPFD2 0.777873799
## 461         PPFD6      TempMean 0.777726876
## 495       TempMin       TempROC 0.774787377
## 183             K        Aspect 0.772714726
## 446            Mg      TempMean 0.768515525
## 6             Dry          Bulb 0.765053708
## 273        Aspect         PPFD4 0.763470099
## 289            Ca         PPFD5 0.761717800
## 284             C         PPFD5 0.761476310
## 281     BulbWidth         PPFD5 0.760630832
## 418             K       TempMin 0.757698844
## 434 WeeklyTempROC       TempMin 0.756404113
## 491         PPFD6       TempROC 0.743033154
## 353         Fresh WeeklyTempROC 0.739608129
## 494       TempMax       TempROC 0.733031548
## 132             K             P 0.730431911
## 345        Aspect       PPFDROC 0.725081812
## 31            Dry            OM 0.719938826
## 380         Fresh       TempMax 0.718291454
## 274         PPFD1         PPFD4 0.716973854
## 8           Fresh     BulbWidth 0.712091636
## 252         PPFD1         PPFD3 0.709266248
## 283             N         PPFD5 0.708507196
## 191       Allicin         PPFD1 0.706904443
## 213           Dry         PPFD2 0.677144644
## 481            Mn       TempROC 0.676259523
## 156           Dry         Slope 0.675162422
## 114            OM            Mn 0.674058150
## 280          Bulb         PPFD5 0.670789098
## 482             P       TempROC 0.664678110
## 285            OM         PPFD5 0.664671625
## 437         Fresh      TempMean 0.664354933
## 172       Allicin        Aspect 0.657956908
## 113             C            Mn 0.656592080
## 152            Mn             S 0.655016018
## 26      BulbWidth             C 0.649550607
## 71      BulbWidth            Ca 0.646949529
## 286            pH         PPFD5 0.645426164
## 231         PPFD1         PPFD2 0.644116903
## 255         Fresh         PPFD4 0.643301310
## 294             S         PPFD5 0.641467638
## 110     BulbWidth            Mn 0.639630634
## 455        Aspect      TempMean 0.639320694
## 125     BulbWidth             P 0.638022516
## 189             S        Aspect 0.636950158
## 112             N            Mn 0.636743489
## 80          Fresh            Al 0.636148341
## 178             N        Aspect 0.634187475
## 404         PPFD6       TempMax 0.632282555
## 350         PPFD5       PPFDROC 0.632067983
## 50      BulbWidth            Mg 0.628360484
## 287            Mg         PPFD5 0.626579694
## 476            Mg       TempROC 0.615583990
## 248             P         PPFD3 0.613942437
## 179             C        Aspect 0.611200338
## 47          Fresh            Mg 0.610342345
## 117             K            Mn 0.608256316
## 443             C      TempMean 0.604745369
## 479            Al       TempROC 0.603660797
## 311            Mg         PPFD6 0.600950437
## 18            Dry             N 0.600511888
## 480            Fe       TempROC 0.595822405
## 279           Dry         PPFD5 0.594531276
## 321         PPFD1         PPFD6 0.593086072
## 265             K         PPFD4 0.587815147
## 232       Allicin         PPFD3 0.585456352
## 41      BulbWidth            pH 0.583086471
## 423             P       TempMin 0.582631157
## 53              C            Mg 0.572399728
## 215     BulbWidth         PPFD2 0.569499028
## 38          Fresh            pH 0.567943075
## 487         PPFD2       TempROC 0.566869065
## 254       Allicin         PPFD4 0.561723057
## 93          Fresh            Fe 0.560989855
## 475            pH       TempROC 0.560593707
## 341            Mn       PPFDROC 0.558781339
## 262            OM         PPFD4 0.555961001
## 326       Allicin       PPFDROC 0.554611821
## 463 WeeklyTempROC      TempMean 0.552982007
## 137       Allicin             S 0.551966983
## 141     BulbWidth             S 0.551183728
## 422            Mn       TempMin 0.550520050
## 454         Slope      TempMean 0.549550252
## 462       PPFDROC      TempMean 0.544149052
## 496      TempMean       TempROC 0.541050318
## 295         Slope         PPFD5 0.540086066
## 375         PPFD4 WeeklyTempROC 0.534083927
## 68          Fresh            Ca 0.533542367
## 324         PPFD4         PPFD6 0.533302075
## 368             P WeeklyTempROC 0.532007038
## 70           Bulb            Ca 0.531854852
## 421            Fe       TempMin 0.531334284
## 453             S      TempMean 0.530318978
## 351         PPFD6       PPFDROC 0.524890367
## 383     BulbWidth       TempMax 0.523782447
## 20      BulbWidth             N 0.521701014
## 108           Dry            Mn 0.519402464
## 445            pH      TempMean 0.517906055
## 180            OM        Aspect 0.516786383
## 330     BulbWidth       PPFDROC 0.512455572
## 83      BulbWidth            Al 0.511538273
## 291            Fe         PPFD5 0.510032052
## 370         Slope WeeklyTempROC 0.509124429
## 356     BulbWidth WeeklyTempROC 0.505934297
## 447             K      TempMean 0.505831722
## 267            Al         PPFD4 0.504413801
## 349         PPFD4       PPFDROC 0.503772494
## 290            Al         PPFD5 0.502739972
## 390             K       TempMax 0.501911458
## 317             P         PPFD6 0.499212716
## 348         PPFD3       PPFDROC 0.498740873
## 416            pH       TempMin 0.498681989
## 109          Bulb            Mn 0.498634563
## 440     BulbWidth      TempMean 0.497053634
## 260             N         PPFD4 0.492924488
## 124          Bulb             P 0.491940674
## 449            Al      TempMean 0.490186028
## 128             C             P 0.489017338
## 259           SLA         PPFD4 0.488848326
## 16        Allicin             N 0.486592930
## 448            Ca      TempMean 0.485139225
## 328           Dry       PPFDROC 0.482955466
## 432         PPFD6       TempMin 0.481527906
## 214          Bulb         PPFD2 0.479760565
## 96      BulbWidth            Fe 0.477360866
## 154       Allicin         Slope 0.474606286
## 190         Slope        Aspect 0.472459911
## 66             Mg             K 0.472268895
## 268            Fe         PPFD4 0.471572987
## 456         PPFD1      TempMean 0.470377148
## 153             P             S 0.467587307
## 420            Al       TempMin 0.467494511
## 308             C         PPFD6 0.466250078
## 74              C            Ca 0.464603199
## 367            Mn WeeklyTempROC 0.464252926
## 129            OM             P 0.462381303
## 24            Dry             C 0.460967328
## 319         Slope         PPFD6 0.460395138
## 270             P         PPFD4 0.454708852
## 237           SLA         PPFD3 0.454546956
## 29        Allicin            OM 0.453970161
## 301       Allicin         PPFD6 0.451415040
## 336            Mg       PPFDROC 0.445037769
## 22        Allicin             C 0.444398278
## 92        Allicin            Fe 0.443446087
## 40           Bulb            pH 0.442353413
## 478            Ca       TempROC 0.440253091
## 419            Ca       TempMin 0.436965803
## 238             N         PPFD3 0.436316862
## 166            Ca         Slope 0.435537331
## 139           Dry             S 0.433195470
## 196           SLA         PPFD1 0.432484330
## 127             N             P 0.432205858
## 429         PPFD3       TempMin 0.428347595
## 417            Mg       TempMin 0.423269762
## 442             N      TempMean 0.422945058
## 10           Bulb     BulbWidth 0.420987593
## 307             N         PPFD6 0.418093246
## 52              N            Mg 0.415254347
## 485        Aspect       TempROC 0.413859862
## 233         Fresh         PPFD3 0.413301260
## 177           SLA        Aspect 0.412306116
## 318             S         PPFD6 0.412107545
## 170             P         Slope 0.410429174
## 374         PPFD3 WeeklyTempROC 0.409002588
## 450            Fe      TempMean 0.408498547
## 363             K WeeklyTempROC 0.408337817
## 79        Allicin            Al 0.406978325
## 95           Bulb            Fe 0.405821932
## 488         PPFD3       TempROC 0.404437802
## 33      BulbWidth            OM 0.404431030
## 240            OM         PPFD3 0.403085843
## 271             S         PPFD4 0.396113126
## 247            Mn         PPFD3 0.392382910
## 9             Dry     BulbWidth 0.389947507
## 123           Dry             P 0.388708432
## 256           Dry         PPFD4 0.387009632
## 386             C       TempMax 0.385907449
## 354           Dry WeeklyTempROC 0.385169269
## 369             S WeeklyTempROC 0.384458361
## 169            Mn         Slope 0.384383323
## 403         PPFD5       TempMax 0.383477570
## 32           Bulb            OM 0.383354016
## 147            Mg             S 0.377984643
## 188             P        Aspect 0.377371235
## 249             S         PPFD3 0.375997233
## 168            Fe         Slope 0.372556365
## 428         PPFD2       TempMin 0.372360059
## 435       TempMax       TempMin 0.369012358
## 193           Dry         PPFD1 0.366853462
## 474            OM       TempROC 0.363564867
## 122         Fresh             P 0.358403717
## 163            pH         Slope 0.356892259
## 182            Mg        Aspect 0.356824914
## 44              C            pH 0.355445281
## 202             K         PPFD1 0.354845932
## 316            Mn         PPFD6 0.354409531
## 278         Fresh         PPFD5 0.353570979
## 359             C WeeklyTempROC 0.352057860
## 342             P       PPFDROC 0.351864894
## 263            pH         PPFD4 0.347326756
## 4         Allicin          Bulb 0.346866663
## 133            Ca             P 0.345351578
## 425         Slope       TempMin 0.342172967
## 82           Bulb            Al 0.338707676
## 250         Slope         PPFD3 0.337565346
## 310            pH         PPFD6 0.336702258
## 73              N            Ca 0.335223166
## 3           Fresh           Dry 0.334231846
## 436       Allicin      TempMean 0.333717452
## 229         Slope         PPFD2 0.333296657
## 84            SLA            Al 0.330496389
## 97            SLA            Fe 0.329299745
## 239             C         PPFD3 0.326449659
## 206            Mn         PPFD1 0.325955724
## 468           Dry       TempROC 0.325691610
## 398        Aspect       TempMax 0.325585880
## 406 WeeklyTempROC       TempMax 0.324527370
## 205            Fe         PPFD1 0.320416808
## 430         PPFD4       TempMin 0.319460158
## 297         PPFD1         PPFD5 0.316216711
## 34            SLA            OM 0.315692868
## 118            Ca            Mn 0.313535668
## 37        Allicin            pH 0.312387753
## 331           SLA       PPFDROC 0.311022118
## 261             C         PPFD4 0.309377051
## 222             K         PPFD2 0.307006634
## 266            Ca         PPFD4 0.304565255
## 65             pH             K 0.304060153
## 338            Ca       PPFDROC 0.303703758
## 19           Bulb             N 0.302795381
## 355          Bulb WeeklyTempROC 0.302596379
## 458         PPFD3      TempMean 0.301187655
## 258     BulbWidth         PPFD4 0.300398722
## 204            Al         PPFD1 0.292639283
## 313            Ca         PPFD6 0.292442938
## 424             S       TempMin 0.291524610
## 21            SLA             N 0.291426243
## 209         Slope         PPFD1 0.289317691
## 245            Al         PPFD3 0.289006293
## 246            Fe         PPFD3 0.282162710
## 142           SLA             S 0.281801330
## 56        Allicin             K 0.280348520
## 167            Al         Slope 0.279843619
## 439          Bulb      TempMean 0.278865519
## 67        Allicin            Ca 0.277084962
## 460         PPFD5      TempMean 0.274802012
## 304          Bulb         PPFD6 0.273692365
## 211       Allicin         PPFD2 0.273236018
## 165             K         Slope 0.272476186
## 223            Ca         PPFD2 0.272144100
## 175          Bulb        Aspect 0.271068407
## 438           Dry      TempMean 0.270918435
## 402         PPFD4       TempMax 0.270140427
## 23          Fresh             C 0.267154585
## 373         PPFD2 WeeklyTempROC 0.262392649
## 49           Bulb            Mg 0.261696718
## 155         Fresh         Slope 0.259274382
## 314            Al         PPFD6 0.259266955
## 306           SLA         PPFD6 0.259244127
## 405       PPFDROC       TempMax 0.257220539
## 69            Dry            Ca 0.256471029
## 103             K            Fe 0.253504161
## 195     BulbWidth         PPFD1 0.253443850
## 42            SLA            pH 0.252951716
## 410          Bulb       TempMin 0.252944980
## 337             K       PPFDROC 0.251193480
## 90              K            Al 0.249903622
## 426        Aspect       TempMin 0.249631943
## 235          Bulb         PPFD3 0.247803334
## 25           Bulb             C 0.247338400
## 13            Dry           SLA 0.245843369
## 107         Fresh            Mn 0.245559717
## 493 WeeklyTempROC       TempROC 0.245066447
## 149            Ca             S 0.244683401
## 376         PPFD5 WeeklyTempROC 0.243832418
## 14           Bulb           SLA 0.242736810
## 236     BulbWidth         PPFD3 0.241233492
## 378       PPFDROC WeeklyTempROC 0.237855070
## 78              K            Ca 0.233832043
## 467         Fresh       TempROC 0.233387133
## 309            OM         PPFD6 0.230846720
## 162            OM         Slope 0.230808475
## 61            SLA             K 0.228490767
## 483             S       TempROC 0.228077381
## 408         Fresh       TempMin 0.226917536
## 484         Slope       TempROC 0.226215743
## 315            Fe         PPFD6 0.225820494
## 72            SLA            Ca 0.224803226
## 130            pH             P 0.222376818
## 1         Allicin         Fresh 0.220153619
## 299         PPFD3         PPFD5 0.219248224
## 11        Allicin           SLA 0.216454209
## 381           Dry       TempMax 0.215797493
## 269            Mn         PPFD4 0.213868290
## 27            SLA             C 0.211339155
## 43              N            pH 0.208306770
## 396             S       TempMax 0.206322981
## 362            Mg WeeklyTempROC 0.206289363
## 201            Mg         PPFD1 0.200966071
## 54             OM            Mg 0.200719976
## 221            Mg         PPFD2 0.198723232
## 230        Aspect         PPFD2 0.198671814
## 59           Bulb             K 0.197925820
## 407       Allicin       TempMin 0.197710230
## 335            pH       PPFDROC 0.193640728
## 275         PPFD2         PPFD4 0.191002653
## 490         PPFD5       TempROC 0.190520267
## 469          Bulb       TempROC 0.188076970
## 75             OM            Ca 0.187368877
## 385             N       TempMax 0.184562396
## 87             OM            Al 0.183758852
## 288             K         PPFD5 0.183738649
## 472             N       TempROC 0.178004449
## 411     BulbWidth       TempMin 0.177099972
## 62              N             K 0.173342758
## 30          Fresh            OM 0.172147113
## 100            OM            Fe 0.172034260
## 329          Bulb       PPFDROC 0.170309435
## 86              C            Al 0.169748869
## 159           SLA         Slope 0.169249743
## 126           SLA             P 0.169150398
## 115            pH            Mn 0.168272401
## 244            Ca         PPFD3 0.168028398
## 409           Dry       TempMin 0.167211619
## 63              C             K 0.166665732
## 444            OM      TempMean 0.165917099
## 138         Fresh             S 0.165256640
## 241            pH         PPFD3 0.164870197
## 397         Slope       TempMax 0.164308368
## 116            Mg            Mn 0.163012079
## 187            Mn        Aspect 0.161345747
## 384           SLA       TempMax 0.160138161
## 358             N WeeklyTempROC 0.158127204
## 134            Al             P 0.156793388
## 300         PPFD4         PPFD5 0.156521653
## 234           Dry         PPFD3 0.156474010
## 131            Mg             P 0.152847790
## 216           SLA         PPFD2 0.151545984
## 15      BulbWidth           SLA 0.151493866
## 352       Allicin WeeklyTempROC 0.150326628
## 264            Mg         PPFD4 0.149336150
## 158     BulbWidth         Slope 0.148676073
## 302         Fresh         PPFD6 0.147286865
## 135            Fe             P 0.144242442
## 414             C       TempMin 0.139434857
## 372         PPFD1 WeeklyTempROC 0.139428414
## 99              C            Fe 0.138770797
## 60      BulbWidth             K 0.133253969
## 140          Bulb             S 0.133191348
## 427         PPFD1       TempMin 0.132694616
## 415            OM       TempMin 0.132099296
## 357           SLA WeeklyTempROC 0.129259328
## 39            Dry            pH 0.129258193
## 121       Allicin             P 0.128253723
## 146            pH             S 0.127521087
## 365            Al WeeklyTempROC 0.126001116
## 186            Fe        Aspect 0.125629652
## 171             S         Slope 0.117486534
## 51            SLA            Mg 0.115978341
## 433       PPFDROC       TempMin 0.113421519
## 305     BulbWidth         PPFD6 0.113153231
## 220            pH         PPFD2 0.112324634
## 272         Slope         PPFD4 0.111284956
## 7         Allicin     BulbWidth 0.108882161
## 457         PPFD2      TempMean 0.108827215
## 200            pH         PPFD1 0.105242134
## 192         Fresh         PPFD1 0.103141944
## 327         Fresh       PPFDROC 0.098190387
## 492       PPFDROC       TempROC 0.096258667
## 174           Dry        Aspect 0.095965848
## 185            Al        Aspect 0.095660395
## 151            Fe             S 0.094944975
## 148             K             S 0.093856154
## 413             N       TempMin 0.092731882
## 489         PPFD4       TempROC 0.092034360
## 160             N         Slope 0.091445599
## 486         PPFD1       TempROC 0.090031991
## 57          Fresh             K 0.089700300
## 303           Dry         PPFD6 0.089471304
## 242            Mg         PPFD3 0.086717367
## 207             P         PPFD1 0.086592772
## 164            Mg         Slope 0.086547521
## 5           Fresh          Bulb 0.085341249
## 282           SLA         PPFD5 0.084852331
## 473             C       TempROC 0.084488449
## 364            Ca WeeklyTempROC 0.083582990
## 48            Dry            Mg 0.082714502
## 257          Bulb         PPFD4 0.076842325
## 224            Al         PPFD2 0.074867298
## 225            Fe         PPFD2 0.073629273
## 361            pH WeeklyTempROC 0.072925584
## 176     BulbWidth        Aspect 0.072015222
## 344         Slope       PPFDROC 0.070518750
## 194          Bulb         PPFD1 0.068198612
## 387            OM       TempMax 0.068093215
## 173         Fresh        Aspect 0.067121118
## 399         PPFD1       TempMax 0.066328833
## 322         PPFD2         PPFD6 0.063842640
## 400         PPFD2       TempMax 0.063098606
## 277       Allicin         PPFD5 0.062732099
## 58            Dry             K 0.061170266
## 150            Al             S 0.058270474
## 379       Allicin       TempMax 0.058054273
## 466       Allicin       TempROC 0.056340340
## 81            Dry            Al 0.051491448
## 441           SLA      TempMean 0.050537583
## 119            Al            Mn 0.050449225
## 470     BulbWidth       TempROC 0.047557127
## 394            Mn       TempMax 0.047498829
## 46        Allicin            Mg 0.046680722
## 184            Ca        Aspect 0.046635768
## 377         PPFD6 WeeklyTempROC 0.046023898
## 401         PPFD3       TempMax 0.045890696
## 431         PPFD5       TempMin 0.042485778
## 111           SLA            Mn 0.042484889
## 120            Fe            Mn 0.041219969
## 64             OM             K 0.040400766
## 45             OM            pH 0.040112508
## 106       Allicin            Mn 0.039883708
## 371        Aspect WeeklyTempROC 0.039815297
## 471           SLA       TempROC 0.039037528
## 465       TempMin      TempMean 0.038918893
## 212         Fresh         PPFD2 0.038735123
## 181            pH        Aspect 0.037774953
## 12          Fresh           SLA 0.032502691
## 17          Fresh             N 0.032199269
## 340            Fe       PPFDROC 0.032093475
## 451            Mn      TempMean 0.029673137
## 296        Aspect         PPFD5 0.025746113
## 366            Fe WeeklyTempROC 0.025512240
## 2         Allicin           Dry 0.025336826
## 452             P      TempMean 0.020455559
## 360            OM WeeklyTempROC 0.017034720
## 203            Ca         PPFD1 0.015169927
## 98              N            Fe 0.015125215
## 94            Dry            Fe 0.014821113
## 395             P       TempMax 0.012522711
## 382          Bulb       TempMax 0.010978103
## 253         PPFD2         PPFD3 0.010371619
## 412           SLA       TempMin 0.007534375
## 339            Al       PPFDROC 0.006978314
## 459         PPFD4      TempMean 0.006930279
## 85              N            Al 0.005573191
## 161             C         Slope 0.004323980
## 325         PPFD5         PPFD6 0.001670669

Intersite and Intrasite Variability of Responding Biological Variables

Intersite Variability:

#Load and read data
Response_Raw <- read_csv("Data/Response_Raw.csv")
R_data <- Response_Raw

response_columns <- names(R_data)[-1]  # Exclude the first column (Site)

# Loop through each response variable
for (col in response_columns) {
  # Subset data for the current response variable
  response_data <- R_data[, c("Site", col)]
  
  # Residual histogram
  hist(residuals(lm(as.formula(paste(col, "~ Site")), data = response_data)), 
       xlab = "Residuals", main = paste("Residual Distribution for", col))
  
  # Boxplot
  boxplot(response_data[[col]] ~ response_data$Site, 
          xlab = "Site", ylab = "Residuals", 
          main = paste("Boxplot of", col, "by Site"))
  
  # Intrasite Variability
  variance_within <- tapply(response_data[[col]], response_data$Site, var)
  cat("Intrasite Variation of", col, ":\n")
  print(variance_within)
  
  #Bartlett's test
  bartlett_result <- bartlett.test(response_data[[col]], response_data$Site)
cat("\nBartlett's Test of Homogeneity:\n")
print(bartlett_result)

  # Intersite Variability (ANOVA F-test)
  anova_result <- aov(as.formula(paste(col, "~ Site")), data = response_data)
  anova_table <- anova(anova_result)
  print(anova_table)
  
  # Protected LSD test
  lsd_result <- LSD.test(anova_result, "Site", console = TRUE)
}

## Intrasite Variation of Allicin :
##        CF      CFUA        PF        RT      SQAP 
## 3049469.7  740432.2  855250.0  376154.4 6638922.2 
## 
## Bartlett's Test of Homogeneity:
## 
##  Bartlett test of homogeneity of variances
## 
## data:  response_data[[col]] and response_data$Site
## Bartlett's K-squared = 22.925, df = 4, p-value = 0.0001311
## 
## Analysis of Variance Table
## 
## Response: Allicin
##           Df    Sum Sq  Mean Sq F value    Pr(>F)    
## Site       4  72446429 18111607  7.7664 7.563e-05 ***
## Residuals 45 104942056  2332046                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Study: anova_result ~ "Site"
## 
## LSD t Test for Allicin 
## 
## Mean Square Error:  2332046 
## 
## Site,  means and individual ( 95 %) CI
## 
##       Allicin       std  r       se        LCL      UCL     Min      Max
## CF   3259.098 1746.2731 10 482.9126 2286.46212 4231.734 1602.50  7245.05
## CFUA 1491.579  860.4837 10 482.9126  518.94312 2464.215  322.05  2997.45
## PF   1302.571  924.7973 10 482.9126  329.93512 2275.207  103.23  2631.26
## RT   1035.749  613.3143 10 482.9126   63.11312 2008.385  151.45  2192.45
## SQAP 4061.386 2576.6106 10 482.9126 3088.75012 5034.022 1272.61 10675.37
##           Q25      Q50      Q75
## CF   2149.470 2908.835 3069.265
## CFUA  803.655 1363.415 2104.235
## PF    459.255 1249.825 2103.580
## RT    586.295  897.365 1474.963
## SQAP 3403.092 3551.625 3971.457
## 
## Alpha: 0.05 ; DF Error: 45
## Critical Value of t: 2.014103 
## 
## least Significant Difference: 1375.515 
## 
## Treatments with the same letter are not significantly different.
## 
##       Allicin groups
## SQAP 4061.386      a
## CF   3259.098      a
## CFUA 1491.579      b
## PF   1302.571      b
## RT   1035.749      b

## Intrasite Variation of Dry :
##         CF       CFUA         PF         RT       SQAP 
## 0.34742738 0.11831551 0.08875573 0.52768693 0.08082427 
## 
## Bartlett's Test of Homogeneity:
## 
##  Bartlett test of homogeneity of variances
## 
## data:  response_data[[col]] and response_data$Site
## Bartlett's K-squared = 12.719, df = 4, p-value = 0.01273
## 
## Analysis of Variance Table
## 
## Response: Dry
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Site       4  8.7325  2.1831  9.3857 1.326e-05 ***
## Residuals 45 10.4671  0.2326                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Study: anova_result ~ "Site"
## 
## LSD t Test for Dry 
## 
## Mean Square Error:  0.232602 
## 
## Site,  means and individual ( 95 %) CI
## 
##         Dry       std  r        se       LCL      UCL   Min   Max     Q25
## CF   2.0204 0.5894297 10 0.1525129 1.7132232 2.327577 0.953 2.902 1.63775
## CFUA 1.6052 0.3439702 10 0.1525129 1.2980232 1.912377 1.133 2.234 1.36450
## PF   1.2828 0.2979190 10 0.1525129 0.9756232 1.589977 0.773 1.715 1.09750
## RT   2.4516 0.7264206 10 0.1525129 2.1444232 2.758777 1.490 3.732 1.88200
## SQAP 1.4846 0.2842961 10 0.1525129 1.1774232 1.791777 1.004 1.990 1.30050
##         Q50     Q75
## CF   2.2795 2.33675
## CFUA 1.5965 1.75800
## PF   1.2375 1.54600
## RT   2.2980 2.98325
## SQAP 1.5460 1.60750
## 
## Alpha: 0.05 ; DF Error: 45
## Critical Value of t: 2.014103 
## 
## least Significant Difference: 0.4344136 
## 
## Treatments with the same letter are not significantly different.
## 
##         Dry groups
## RT   2.4516      a
## CF   2.0204     ab
## CFUA 1.6052     bc
## SQAP 1.4846      c
## PF   1.2828      c

## Intrasite Variation of Fresh :
##        CF      CFUA        PF        RT      SQAP 
## 7.0200046 1.2247817 0.9915282 1.5601178 1.3174586 
## 
## Bartlett's Test of Homogeneity:
## 
##  Bartlett test of homogeneity of variances
## 
## data:  response_data[[col]] and response_data$Site
## Bartlett's K-squared = 13.452, df = 4, p-value = 0.009266
## 
## Analysis of Variance Table
## 
## Response: Fresh
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## Site       4 217.98  54.495  22.493 2.957e-10 ***
## Residuals 45 109.03   2.423                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Study: anova_result ~ "Site"
## 
## LSD t Test for Fresh 
## 
## Mean Square Error:  2.422778 
## 
## Site,  means and individual ( 95 %) CI
## 
##        Fresh       std  r        se       LCL       UCL   Min    Max     Q25
## CF   10.9958 2.6495291 10 0.4922172 10.004424 11.987176 5.877 13.834 9.67800
## CFUA 10.2629 1.1066985 10 0.4922172  9.271524 11.254276 9.087 12.256 9.51725
## PF    6.0617 0.9957551 10 0.4922172  5.070324  7.053076 4.262  7.283 5.40675
## RT   10.6124 1.2490468 10 0.4922172  9.621024 11.603776 8.057 11.959 9.95625
## SQAP  6.7628 1.1478060 10 0.4922172  5.771424  7.754176 4.471  8.549 6.19525
##          Q50      Q75
## CF   11.8665 12.84225
## CFUA  9.7710 10.86525
## PF    5.9895  6.89100
## RT   10.9805 11.61650
## SQAP  6.9345  7.45975
## 
## Alpha: 0.05 ; DF Error: 45
## Critical Value of t: 2.014103 
## 
## least Significant Difference: 1.402018 
## 
## Treatments with the same letter are not significantly different.
## 
##        Fresh groups
## CF   10.9958      a
## RT   10.6124      a
## CFUA 10.2629      a
## SQAP  6.7628      b
## PF    6.0617      b

## Intrasite Variation of Bulb :
##         CF       CFUA         PF         RT       SQAP 
## 0.22481112 0.11644966 0.07365538 0.50808356 0.05966588 
## 
## Bartlett's Test of Homogeneity:
## 
##  Bartlett test of homogeneity of variances
## 
## data:  response_data[[col]] and response_data$Site
## Bartlett's K-squared = 13.896, df = 4, p-value = 0.007634
## 
## Analysis of Variance Table
## 
## Response: Bulb
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## Site       4 7.2085 1.80212  9.1696 1.661e-05 ***
## Residuals 45 8.8440 0.19653                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Study: anova_result ~ "Site"
## 
## LSD t Test for Bulb 
## 
## Mean Square Error:  0.1965331 
## 
## Site,  means and individual ( 95 %) CI
## 
##        Bulb       std  r        se       LCL      UCL   Min   Max     Q25
## CF   1.4163 0.4741425 10 0.1401903 1.1339423 1.698658 0.609 2.094 1.03500
## CFUA 1.0959 0.3412472 10 0.1401903 0.8135423 1.378258 0.685 1.727 0.83975
## PF   0.9736 0.2713952 10 0.1401903 0.6912423 1.255958 0.538 1.375 0.81100
## RT   2.0100 0.7127998 10 0.1401903 1.7276423 2.292358 1.157 3.311 1.48050
## SQAP 1.0639 0.2442660 10 0.1401903 0.7815423 1.346258 0.685 1.552 0.94025
##         Q50     Q75
## CF   1.6315 1.73125
## CFUA 1.0540 1.30325
## PF   0.9015 1.20425
## RT   1.7550 2.52175
## SQAP 1.0295 1.20025
## 
## Alpha: 0.05 ; DF Error: 45
## Critical Value of t: 2.014103 
## 
## least Significant Difference: 0.3993141 
## 
## Treatments with the same letter are not significantly different.
## 
##        Bulb groups
## RT   2.0100      a
## CF   1.4163      b
## CFUA 1.0959     bc
## SQAP 1.0639     bc
## PF   0.9736      c

## Intrasite Variation of BulbWidth :
##       CF     CFUA       PF       RT     SQAP 
## 4.980072 1.580668 3.841982 1.403912 2.583716 
## 
## Bartlett's Test of Homogeneity:
## 
##  Bartlett test of homogeneity of variances
## 
## data:  response_data[[col]] and response_data$Site
## Bartlett's K-squared = 5.0653, df = 4, p-value = 0.2807
## 
## Analysis of Variance Table
## 
## Response: BulbWidth
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Site       4  98.037 24.5092  8.5159 3.326e-05 ***
## Residuals 45 129.513  2.8781                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Study: anova_result ~ "Site"
## 
## LSD t Test for BulbWidth 
## 
## Mean Square Error:  2.87807 
## 
## Site,  means and individual ( 95 %) CI
## 
##      BulbWidth      std  r        se      LCL      UCL   Min   Max     Q25
## CF      15.345 2.231608 10 0.5364765 14.26448 16.42552 11.05 17.54 13.5400
## CFUA    13.627 1.257246 10 0.5364765 12.54648 14.70752 11.60 15.30 12.8725
## PF      12.574 1.960098 10 0.5364765 11.49348 13.65452  8.87 15.17 11.5975
## RT      16.603 1.184868 10 0.5364765 15.52248 17.68352 14.69 17.90 15.9100
## SQAP    14.036 1.607394 10 0.5364765 12.95548 15.11652 12.18 17.24 12.8025
##         Q50     Q75
## CF   16.535 16.9525
## CFUA 13.830 14.5850
## PF   12.390 14.0325
## RT   16.540 17.7225
## SQAP 13.785 14.5750
## 
## Alpha: 0.05 ; DF Error: 45
## Critical Value of t: 2.014103 
## 
## least Significant Difference: 1.528085 
## 
## Treatments with the same letter are not significantly different.
## 
##      BulbWidth groups
## RT      16.603      a
## CF      15.345     ab
## SQAP    14.036     bc
## CFUA    13.627      c
## PF      12.574      c

## Intrasite Variation of SLA :
##        CF      CFUA        PF        RT      SQAP 
## 10489.724  1173.429  3888.297  5612.422  4198.925 
## 
## Bartlett's Test of Homogeneity:
## 
##  Bartlett test of homogeneity of variances
## 
## data:  response_data[[col]] and response_data$Site
## Bartlett's K-squared = 9.4022, df = 4, p-value = 0.0518
## 
## Analysis of Variance Table
## 
## Response: SLA
##           Df Sum Sq Mean Sq F value  Pr(>F)  
## Site       4  44752 11188.0  2.2056 0.08349 .
## Residuals 45 228265  5072.6                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Study: anova_result ~ "Site"
## 
## LSD t Test for SLA 
## 
## Mean Square Error:  5072.559 
## 
## Site,  means and individual ( 95 %) CI
## 
##           SLA       std  r       se      LCL      UCL      Min      Max
## CF   255.3110 102.41935 10 22.52234 209.9487 300.6733 125.1610 495.7558
## CFUA 299.5497  34.25535 10 22.52234 254.1873 344.9120 243.6891 363.5793
## PF   266.6448  62.35621 10 22.52234 221.2824 312.0071 165.8875 368.7149
## RT   301.3490  74.91610 10 22.52234 255.9866 346.7113 184.2044 443.6877
## SQAP 221.0126  64.79911 10 22.52234 175.6502 266.3749 153.8707 338.2848
##           Q25      Q50      Q75
## CF   207.0494 226.8085 288.0627
## CFUA 280.8863 300.0421 316.2148
## PF   239.0989 252.7509 287.2056
## RT   274.2705 297.5297 332.6769
## SQAP 172.7952 198.9615 270.9622
## 
## Alpha: 0.05 ; DF Error: 45
## Critical Value of t: 2.014103 
## 
## least Significant Difference: 64.15202 
## 
## Treatments with the same letter are not significantly different.
## 
##           SLA groups
## RT   301.3490      a
## CFUA 299.5497      a
## PF   266.6448     ab
## CF   255.3110     ab
## SQAP 221.0126      b
#SLA - rt/cfua/pf vs pf/cf/sqap, not significantly different between sites
#bulbwidth - rt/cf, cf/sqap, sqap/cfua/pf, significant
#bulbmass - rt, cf/cfua/sqap, cfua/sqap/pf, sig
#fresh - cf/rt/cfua, sqap/pf, significant
#dry - rt/cf, cf/cfua, cfua/sqap/pf,sig
#allicin - sqap/cf, cfua/pf/rt, sig

Principal Component Analysis

The purpose of this analysis is to ultimately reduce overall dimensionality of known highly correlated variables, as well as revealing basic relationships among environmental predictor variables in a PCA ordination biplot.

#Calculate PCA loadings of environmental predictors with standardized data, removing response variables
pca_data <- zdata[, -c(1:6)]
pca_matrix <- cor(pca_data)
pca_result <- prcomp(pca_matrix)
summary(pca_result)
## Importance of components:
##                           PC1    PC2    PC3     PC4       PC5       PC6
## Standard deviation     1.8463 1.4349 1.2683 0.47112 3.041e-16 1.677e-16
## Proportion of Variance 0.4671 0.2821 0.2204 0.03041 0.000e+00 0.000e+00
## Cumulative Proportion  0.4671 0.7492 0.9696 1.00000 1.000e+00 1.000e+00
##                              PC7       PC8       PC9      PC10      PC11
## Standard deviation     1.677e-16 1.677e-16 1.677e-16 1.677e-16 1.677e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
##                             PC12      PC13      PC14      PC15      PC16
## Standard deviation     1.677e-16 1.677e-16 1.677e-16 1.677e-16 1.677e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
##                             PC17      PC18      PC19      PC20      PC21
## Standard deviation     1.677e-16 1.677e-16 1.677e-16 1.677e-16 1.677e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
##                             PC22      PC23      PC24      PC25      PC26
## Standard deviation     1.677e-16 1.677e-16 1.677e-16 1.255e-16 4.877e-17
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
#PC1 and PC2 contribute 74.92% of total variance.

#Loading matrix of PC1 & PC2 - relative contributions to PC1 and PC2 by each variable
pca_result$rotation[,1:2]
##                       PC1          PC2
## N             -0.27620707  0.143540689
## C             -0.30395909  0.115898556
## OM            -0.22314355  0.198260100
## pH            -0.19403326 -0.178827455
## Mg            -0.26061747 -0.173744459
## K             -0.12234306 -0.288743516
## Ca            -0.21529719 -0.128207880
## Al             0.14395782  0.207851340
## Fe             0.13243925  0.210188574
## Mn            -0.15127988  0.291389151
## P             -0.10783380  0.272973470
## S             -0.27466667  0.167709563
## Slope          0.01373727  0.056121947
## Aspect        -0.21007410 -0.087043046
## PPFD1          0.23069797 -0.109212103
## PPFD2          0.20512032 -0.267290287
## PPFD3         -0.11078834 -0.112347790
## PPFD4         -0.06990439 -0.007353378
## PPFD5         -0.23768177  0.121392913
## PPFD6         -0.20829999 -0.217543450
## PPFDROC        0.28617753 -0.118903311
## WeeklyTempROC  0.10506158 -0.133672107
## TempMax        0.21559411  0.225346436
## TempMin       -0.02955143 -0.300953292
## TempMean       0.25216078  0.128504445
## TempROC        0.07669602  0.361996451
#Scree plot of principal components
fviz_eig(pca_result, addlabels = TRUE)

#Individual total contributions to both PC1 & PC2
fviz_cos2(pca_result, choice = "var", axes = 1:2, title = "Combined contribution by variable")

#PCA biplot with color ramp scaled by variable contribution
fviz_pca_var(pca_result, col.var = "cos2", 
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE, title = "PCA Biplot of Scaled Environmental Predictor Variables")

omit_columns <- c(1:7, 9:10, 12:13, 16, 21, 25:26, 29, 32)
pca_data2 <- zdata[, -omit_columns]# Explanatory variables

pca_matrix2 <- cor(pca_data2)
pca_result2 <- prcomp(pca_matrix2)
summary(pca_result2)
## Importance of components:
##                           PC1    PC2    PC3    PC4       PC5       PC6
## Standard deviation     1.4390 0.9944 0.8991 0.5138 1.887e-16 1.629e-16
## Proportion of Variance 0.5011 0.2393 0.1956 0.0639 0.000e+00 0.000e+00
## Cumulative Proportion  0.5011 0.7405 0.9361 1.0000 1.000e+00 1.000e+00
##                              PC7       PC8       PC9      PC10      PC11
## Standard deviation     1.005e-16 8.629e-17 6.549e-17 6.229e-17 4.348e-17
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
##                             PC12      PC13      PC14      PC15
## Standard deviation     2.133e-17 2.113e-17 1.069e-17 4.101e-19
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00
#PC1 and PC2 contribute 74.05% of total variance.

#Loading matrix of PC1 & PC2 - relative contributions to PC1 and PC2 by each variable
pca_result2$rotation[,1:2]
##                       PC1         PC2
## C             -0.41939890  0.05557060
## Mg            -0.25999215  0.28008464
## Al             0.07484553 -0.40185252
## Fe             0.05419942 -0.40325981
## P             -0.14946043  0.32146732
## S             -0.41044489 -0.03448430
## Slope          0.08805081  0.27066783
## Aspect        -0.31020765 -0.28011968
## PPFD2          0.30503974 -0.09957897
## PPFD3         -0.17868943 -0.37844465
## PPFD4         -0.14145786 -0.39540503
## PPFDROC        0.41312538  0.05346627
## WeeklyTempROC  0.17949980 -0.15020777
## TempMin        0.05532232  0.01141326
## TempMean       0.31975186 -0.05540160
#Scree plot of principal components
fviz_eig(pca_result2, addlabels = TRUE)

#Individual total contributions to both PC1 & PC2
fviz_cos2(pca_result2, choice = "var", axes = 1:2, title = "Combined contribution by variable")

#PCA biplot with color ramp scaled by variable contribution
fviz_pca_var(pca_result2, col.var = "cos2", 
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE, title = "PCA Biplot of Reduced Scaled Environmental Predictor Variables")

Univariate Regression Analysis

library(ggplot2)
#*Using log transformed and standardized data, univariate regression analyses are used to understand individual relationships between biological response variables and each environmental parameter.*

# Define response and predictor variables
response_var <- colnames(logzdata)[1:6]
env_var <- colnames(logzdata)[7:32]

# Empty data frame to store results
results_table <- data.frame(Response_Variable = character(),
                            Predictor_Variable = character(),
                            Coefficient = numeric(),
                            Std_Error = numeric(),
                            t_value = numeric(),
                            p_value = numeric(),
                            RSquared = numeric(),  # Add a column for R^2
                            stringsAsFactors = FALSE)

# Perform regression analysis for each response variable and predictor variable
for (response in response_var) {
  for (env in env_var) {
    model <- lm(logzdata[[response]] ~ logzdata[[env]])
    
    # Results stored in the table
    results_table <- rbind(results_table, data.frame(Response_Variable = response,
                                                     Predictor_Variable = env,
                                                     Coefficient = coef(model)[2],
                                                     Std_Error = summary(model)$coefficients[2, 2],
                                                     t_value = summary(model)$coefficients[2, 3],
                                                     p_value = summary(model)$coefficients[2, 4],
                                                     RSquared = summary(model)$r.squared))
  }
}
significant_results <- results_table[results_table$p_value < 0.05, ]
# Highlighting the table based on conditions
library(DT)
#Hide column names
rownames(results_table) <- NULL
# Highlight R^2 > 0.3 and p-values < 0.05
datatable(results_table, options = list(
  columnDefs = list(
    list(
      targets = 7,  # R_squared column index
      render = JS("function(data, type, row, meta) {",
                  "if (parseFloat(data) > 0.3) {",
                  "return '<span style=\"color: red;\">' + data + '</span>';",
                  "} else {",
                  "return data;",
                  "}",
                  "}")
    ),
    list(
      targets = 6,  # p_value column index
      render = JS("function(data, type, row, meta) {",
                  "if (parseFloat(data) < 0.05) {",
                  "return '<span style=\"color: blue;\">' + data + '</span>';",
                  "} else {",
                  "return data;",
                  "}",
                  "}")
    )
  ),
  dom = 'tip',
  pageLength = 10,
  lengthMenu = c(10, 20, 50),
  scrollX = TRUE,
  width = "80%"  
))
# Print the new table
print(significant_results)
##                    Response_Variable Predictor_Variable Coefficient Std_Error
## logzdata[[env]]              Allicin                  N   0.4246413 0.1887810
## logzdata[[env]]8             Allicin                 Fe   0.4213353 0.1891028
## logzdata[[env]]11            Allicin                  S   0.4718604 0.1838416
## logzdata[[env]]12            Allicin              Slope  -0.4530981 0.1858824
## logzdata[[env]]13            Allicin             Aspect   0.6555867 0.1574534
## logzdata[[env]]14            Allicin              PPFD1  -0.7026116 0.1483733
## logzdata[[env]]16            Allicin              PPFD3   0.6311119 0.1617429
## logzdata[[env]]17            Allicin              PPFD4   0.5279073 0.1770917
## logzdata[[env]]19            Allicin              PPFD6   0.5408952 0.1753794
## logzdata[[env]]20            Allicin            PPFDROC  -0.5433948 0.1750431
## logzdata[[env]]29              Fresh                 pH   0.5399799 0.1755020
## logzdata[[env]]30              Fresh                 Mg   0.5576997 0.1730759
## logzdata[[env]]32              Fresh                 Ca   0.4796472 0.1829634
## logzdata[[env]]33              Fresh                 Al  -0.6416423 0.1599314
## logzdata[[env]]34              Fresh                 Fe  -0.5604341 0.1726914
## logzdata[[env]]36              Fresh                  P   0.4502532 0.1861827
## logzdata[[env]]38              Fresh              Slope  -0.4161540 0.1896009
## logzdata[[env]]42              Fresh              PPFD3  -0.4865454 0.1821697
## logzdata[[env]]43              Fresh              PPFD4  -0.5734027 0.1708304
## logzdata[[env]]47              Fresh      WeeklyTempROC  -0.7691628 0.1332517
## logzdata[[env]]48              Fresh            TempMax  -0.6958627 0.1497498
## logzdata[[env]]50              Fresh           TempMean  -0.6516016 0.1581710
## logzdata[[env]]52                Dry                  N   0.6058873 0.1658837
## logzdata[[env]]53                Dry                  C   0.4705167 0.1839913
## logzdata[[env]]54                Dry                 OM   0.7331609 0.1418013
## logzdata[[env]]61                Dry                 Mn   0.4719690 0.1838295
## logzdata[[env]]63                Dry                  S   0.4324705 0.1880066
## logzdata[[env]]64                Dry              Slope   0.7026226 0.1483711
## logzdata[[env]]67                Dry              PPFD2  -0.6782940 0.1532144
## logzdata[[env]]69                Dry              PPFD4   0.4920207 0.1815292
## logzdata[[env]]70                Dry              PPFD5   0.6902655 0.1508719
## logzdata[[env]]72                Dry            PPFDROC  -0.4497712 0.1862334
## logzdata[[env]]73                Dry      WeeklyTempROC   0.4026668 0.1908630
## logzdata[[env]]80               Bulb                 OM   0.4093261 0.1902461
## logzdata[[env]]81               Bulb                 pH   0.4244042 0.1888041
## logzdata[[env]]84               Bulb                 Ca   0.4888542 0.1819008
## logzdata[[env]]86               Bulb                 Fe  -0.4698469 0.1840657
## logzdata[[env]]87               Bulb                 Mn   0.4293479 0.1883175
## logzdata[[env]]90               Bulb              Slope   0.7926278 0.1271324
## logzdata[[env]]93               Bulb              PPFD2  -0.4913084 0.1816131
## logzdata[[env]]96               Bulb              PPFD5   0.5928851 0.1679140
## logzdata[[env]]104         BulbWidth                  N   0.5283751 0.1770310
## logzdata[[env]]105         BulbWidth                  C   0.6542419 0.1576964
## logzdata[[env]]106         BulbWidth                 OM   0.4165032 0.1895676
## logzdata[[env]]107         BulbWidth                 pH   0.5390573 0.1756252
## logzdata[[env]]108         BulbWidth                 Mg   0.5894608 0.1684373
## logzdata[[env]]110         BulbWidth                 Ca   0.5435427 0.1750232
## logzdata[[env]]111         BulbWidth                 Al  -0.6064347 0.1657968
## logzdata[[env]]112         BulbWidth                 Fe  -0.5593188 0.1728486
## logzdata[[env]]113         BulbWidth                 Mn   0.6394049 0.1603205
## logzdata[[env]]114         BulbWidth                  P   0.6151322 0.1643978
## logzdata[[env]]115         BulbWidth                  S   0.5854400 0.1690459
## logzdata[[env]]119         BulbWidth              PPFD2  -0.5574052 0.1731171
## logzdata[[env]]122         BulbWidth              PPFD5   0.6474067 0.1589182
## logzdata[[env]]124         BulbWidth            PPFDROC  -0.4970249 0.1809355
## logzdata[[env]]125         BulbWidth      WeeklyTempROC  -0.5155645 0.1786657
## logzdata[[env]]126         BulbWidth            TempMax  -0.5203055 0.1780672
## logzdata[[env]]128         BulbWidth           TempMean  -0.5051074 0.1799597
## logzdata[[env]]143               SLA             Aspect  -0.4565214 0.1855179
## logzdata[[env]]144               SLA              PPFD1   0.4704450 0.1839992
## logzdata[[env]]146               SLA              PPFD3  -0.4602045 0.1851218
## logzdata[[env]]147               SLA              PPFD4  -0.4604280 0.1850976
##                      t_value      p_value  RSquared
## logzdata[[env]]     2.249386 3.436035e-02 0.1803202
## logzdata[[env]]8    2.228076 3.593963e-02 0.1775234
## logzdata[[env]]11   2.566669 1.724709e-02 0.2226523
## logzdata[[env]]12  -2.437553 2.293133e-02 0.2052979
## logzdata[[env]]13   4.163687 3.744138e-04 0.4297939
## logzdata[[env]]14  -4.735431 9.001413e-05 0.4936631
## logzdata[[env]]16   3.901945 7.174347e-04 0.3983023
## logzdata[[env]]17   2.980983 6.681815e-03 0.2786862
## logzdata[[env]]19   3.084144 5.240706e-03 0.2925676
## logzdata[[env]]20  -3.104349 4.995833e-03 0.2952780
## logzdata[[env]]29   3.076774 5.332866e-03 0.2915783
## logzdata[[env]]30   3.222284 3.772196e-03 0.3110289
## logzdata[[env]]32   2.621548 1.525483e-02 0.2300614
## logzdata[[env]]33  -4.011985 5.460443e-04 0.4117049
## logzdata[[env]]34  -3.245292 3.569908e-03 0.3140863
## logzdata[[env]]36   2.418340 2.391239e-02 0.2027279
## logzdata[[env]]38  -2.194894 3.853029e-02 0.1731841
## logzdata[[env]]42  -2.670835 1.365155e-02 0.2367264
## logzdata[[env]]43  -3.356562 2.731026e-03 0.3287906
## logzdata[[env]]47  -5.772253 7.020578e-06 0.5916113
## logzdata[[env]]48  -4.646835 1.122434e-04 0.4842248
## logzdata[[env]]50  -4.119603 4.178458e-04 0.4245846
## logzdata[[env]]52   3.652481 1.327660e-03 0.3670994
## logzdata[[env]]53   2.557278 1.761148e-02 0.2213860
## logzdata[[env]]54   5.170339 3.060253e-05 0.5375249
## logzdata[[env]]61   2.567428 1.721793e-02 0.2227547
## logzdata[[env]]63   2.300294 3.084038e-02 0.1870307
## logzdata[[env]]64   4.735576 8.998145e-05 0.4936785
## logzdata[[env]]67  -4.427089 1.941579e-04 0.4600827
## logzdata[[env]]69   2.710422 1.248010e-02 0.2420844
## logzdata[[env]]70   4.575176 1.341968e-04 0.4764665
## logzdata[[env]]72  -2.415095 2.408191e-02 0.2022941
## logzdata[[env]]73   2.109717 4.597134e-02 0.1621406
## logzdata[[env]]80   2.151561 4.216783e-02 0.1675478
## logzdata[[env]]81   2.247855 3.447172e-02 0.1801190
## logzdata[[env]]84   2.687477 1.314700e-02 0.2389784
## logzdata[[env]]86  -2.552605 1.779546e-02 0.2207561
## logzdata[[env]]87   2.279915 3.220793e-02 0.1843396
## logzdata[[env]]90   6.234662 2.318897e-06 0.6282589
## logzdata[[env]]93  -2.705248 1.262762e-02 0.2413840
## logzdata[[env]]96   3.530886 1.788130e-03 0.3515127
## logzdata[[env]]104  2.984647 6.624687e-03 0.2791802
## logzdata[[env]]105  4.148743 3.886086e-04 0.4280325
## logzdata[[env]]106  2.197122 3.835116e-02 0.1734749
## logzdata[[env]]107  3.069361 5.427132e-03 0.2905828
## logzdata[[env]]108  3.499585 1.930010e-03 0.3474640
## logzdata[[env]]110  3.105547 4.981659e-03 0.2954386
## logzdata[[env]]111 -3.657699 1.310755e-03 0.3677630
## logzdata[[env]]112 -3.235889 3.651272e-03 0.3128376
## logzdata[[env]]113  3.988291 5.791367e-04 0.4088386
## logzdata[[env]]114  3.741731 1.065933e-03 0.3783876
## logzdata[[env]]115  3.463201 2.108793e-03 0.3427400
## logzdata[[env]]119 -3.219815 3.794549e-03 0.3107006
## logzdata[[env]]122  4.073837 4.682346e-04 0.4191355
## logzdata[[env]]124 -2.746973 1.148325e-02 0.2470338
## logzdata[[env]]125 -2.885637 8.345453e-03 0.2658068
## logzdata[[env]]126 -2.921962 7.669692e-03 0.2707179
## logzdata[[env]]128 -2.806781 1.001277e-02 0.2551335
## logzdata[[env]]143 -2.460795 2.179431e-02 0.2084118
## logzdata[[env]]144  2.556777 1.763110e-02 0.2213185
## logzdata[[env]]146 -2.485955 2.062251e-02 0.2117882
## logzdata[[env]]147 -2.487487 2.055308e-02 0.2119939
# Convert p-value to -log10 scale for better visualization
results_table$log_p_value <- -log10(results_table$p_value)

# Scatter plot
ggplot(results_table, aes(x = Coefficient, y = log_p_value, color = Response_Variable)) +
  geom_point() +
  facet_wrap(~Predictor_Variable, scales = "free") +
  labs(
    title = "Regression Coefficients vs. -log10(p-value)",
    x = "Coefficient",
    y = "-log10(p-value)",
    color = "Response Variable"
  ) +
  scale_x_continuous(labels = scales::number_format(accuracy = 0.1))

ggsave("scatterplot.png", width = 9, height = 6, units = "in")

Despite there being individual significances of individual coefficients, due to known multicollinearity, the overall model is not significant. This requires an approach that can handle both multicollinearity and micronumerosity. The ideal test for this situation is Elastic Net Regression.

Elastic Net Regression

A form of regularization, elastic net regression combines the penalty techniques of ridge regression and lasso regression, respectively encouraging the reduction of the coefficient values of variables to reduce impact on the model, as well as reducing the total dimensionality of the model and selecting the most impactful variables.

Allicin

#Remove other response variables from data set
a_zdata <- zdata[,-c(2:6)]
#*Train model*

#Set random number generator
set.seed(123)
#Set training and test set - 80% for training and 20% for test due to small data set
ind <- sample(2, nrow(a_zdata), replace = TRUE, prob = c(0.8, 0.2))
#Create training data frame
train <- a_zdata[ind==1]
#Create testing data frame
test <- a_zdata[ind==2,]
#Mean validation score
mean(en_a$resample$RMSE)
## [1] 0.6378428
#Plots
plot(en_a, main = "Elastic Net Regression - Allicin")

plot(varImp(en_a,scale=TRUE))

#Obtain coefficients
options(scipen=99)
coefs <- coef(en_a$finalModel,en_a$bestTune$lambda)
coefs.zero <- coefs[which(coefs==0),]
length(coefs.zero)
## [1] 7
# Rank order the predictors based on the magnitude of the coefficients

ind   <- order(abs(coefs),decreasing=T)

# The first 10 predictors with the largest absolute coefficient (excluding the intercept)

head(as.matrix(coefs[ind,]),10)
##                [,1]
## Slope   -0.18802399
## Aspect   0.16819737
## S        0.12830510
## Fe       0.12824881
## PPFDROC -0.10028944
## Al       0.08467609
## PPFD3    0.08386826
## PPFD4    0.05832401
## N        0.03366103
## C        0.02103633

Fresh Biomass

## Warning in rm(coefs, var_importance, var_coefs): object 'var_importance' not
## found
## Warning in rm(coefs, var_importance, var_coefs): object 'var_coefs' not found
#Mean validation score
mean(en_f$resample$RMSE)
## [1] 0.4363486
#Plots
plot(en_f, main = "Elastic Net Regression - Fresh Biomass")

plot(varImp(en_f,scale=TRUE))

#Obtain coefficients
options(scipen=99)
coefs <- coef(en_f$finalModel,en_f$bestTune$lambda)
coefs.zero <- coefs[which(coefs==0),]
length(coefs.zero)
## [1] 12
# Rank order the predictors based on the magnitude of the coefficients

ind   <- order(abs(coefs),decreasing=T)

# The first 10 predictors with the largest absolute coefficient (excluding the intercept)

head(as.matrix(coefs[ind,]),10)
##                                    [,1]
## TempMean      -0.3553890517957313810449
## PPFD4         -0.3369390147357060882882
## WeeklyTempROC -0.3282369936684477185196
## Al            -0.2469585794673070378025
## TempROC       -0.0001027861751287968825
## Slope         -0.0000769575950157651224
## (Intercept)   -0.0000000000000007344024
## N              0.0000000000000000000000
## C              0.0000000000000000000000
## Mg             0.0000000000000000000000

Dry Biomass

## Warning in rm(coefs, var_importance, var_coefs): object 'var_importance' not
## found
## Warning in rm(coefs, var_importance, var_coefs): object 'var_coefs' not found
#Mean validation score
mean(en_d$resample$RMSE)
## [1] 0.4823345
#Plots
plot(en_d, main = "Elastic Net Regression - Dry Biomass")

plot(varImp(en_d,scale=TRUE))

#Obtain coefficients
options(scipen=99)
coefs <- coef(en_d$finalModel,en_d$bestTune$lambda)
coefs.zero <- coefs[which(coefs==0),]
length(coefs.zero)
## [1] 6
# Rank order the predictors based on the magnitude of the coefficients

ind   <- order(abs(coefs),decreasing=T)

# The first 10 predictors with the largest absolute coefficient (excluding the intercept)

head(as.matrix(coefs[ind,]),10)
##                      [,1]
## Slope          0.32783256
## PPFD2         -0.21048624
## WeeklyTempROC  0.19060721
## N              0.15774754
## TempMean       0.11077504
## PPFD4          0.10217859
## PPFDROC       -0.07951649
## C              0.06205896
## P              0.05268823
## TempROC        0.04296690

Bulb Biomass

## Warning in rm(coefs, var_importance, var_coefs): object 'var_importance' not
## found
## Warning in rm(coefs, var_importance, var_coefs): object 'var_coefs' not found
#Mean validation score
mean(en_b$resample$RMSE)
## [1] 0.5009502
#Plots
plot(en_b, main = "Elastic Net Regression - Bulb Biomass")

plot(varImp(en_b,scale=TRUE))

#Obtain coefficients
options(scipen=99)
coefs <- coef(en_b$finalModel,en_b$bestTune$lambda)
coefs.zero <- coefs[which(coefs==0),]
length(coefs.zero)
## [1] 13
# Rank order the predictors based on the magnitude of the coefficients

ind   <- order(abs(coefs),decreasing=T)

# The first 10 predictors with the largest absolute coefficient (excluding the intercept)

head(as.matrix(coefs[ind,]),10)
##                                  [,1]
## Slope        0.6581927381943623034388
## PPFD2       -0.1861603845788756261825
## Fe          -0.0882701372980989329431
## Mg           0.0299687114570114480905
## N            0.0109470556796699199781
## (Intercept)  0.0000000000000003676139
## C            0.0000000000000000000000
## K            0.0000000000000000000000
## Al           0.0000000000000000000000
## P            0.0000000000000000000000

Bulb Width

## Warning in rm(coefs, var_importance, var_coefs): object 'var_importance' not
## found
## Warning in rm(coefs, var_importance, var_coefs): object 'var_coefs' not found
#Mean validation score
mean(en_bw$resample$RMSE)
## [1] 0.6320366
#Plots
plot(en_bw, main = "Elastic Net Regression - Bulb Width")

plot(varImp(en_bw,scale=TRUE))

#Obtain coefficients
options(scipen=99)
coefs <- coef(en_bw$finalModel,en_bw$bestTune$lambda)
coefs.zero <- coefs[which(coefs==0),]
length(coefs.zero)
## [1] 0
# Rank order the predictors based on the magnitude of the coefficients

ind   <- order(abs(coefs),decreasing=T)

# The first 10 predictors with the largest absolute coefficient (excluding the intercept)

head(as.matrix(coefs[ind,]),10)
##                      [,1]
## Mg             0.13001819
## P              0.12861587
## Al            -0.12157658
## Fe            -0.11484187
## C              0.10931685
## WeeklyTempROC -0.10098296
## PPFD2         -0.09483397
## TempMean      -0.09206807
## PPFD4         -0.08701797
## S              0.08461941

Specific Leaf Area

## Warning in rm(coefs, var_importance, var_coefs): object 'var_importance' not
## found
## Warning in rm(coefs, var_importance, var_coefs): object 'var_coefs' not found
#Mean validation score
mean(en_sla$resample$RMSE)
## [1] 0.875287
#Plots
plot(en_sla, main = "Elastic Net Regression - Specific Leaf Area")

plot(varImp(en_sla,scale=TRUE))

#Obtain coefficients
options(scipen=99)
coefs <- coef(en_sla$finalModel,en_sla$bestTune$lambda)
coefs.zero <- coefs[which(coefs==0),]
length(coefs.zero)
## [1] 17
# Rank order the predictors based on the magnitude of the coefficients

ind   <- order(abs(coefs),decreasing=T)

# The first 10 predictors with the largest absolute coefficient (excluding the intercept)

head(as.matrix(coefs[ind,]),10)
##                                   [,1]
## PPFD4       -0.28472418109904484850858
## (Intercept)  0.00000000000000002780367
## N            0.00000000000000000000000
## C            0.00000000000000000000000
## Mg           0.00000000000000000000000
## K            0.00000000000000000000000
## Al           0.00000000000000000000000
## Fe           0.00000000000000000000000
## P            0.00000000000000000000000
## S            0.00000000000000000000000
Comparing elastic net results to the univariate results, the following variables should be retained for best model predictions of all response variables: Aspect, Slope, Al, S, C, P, Fe, Mg, PPFD2, PPFD3, PPFD4, PPFDROC, TempMean, WeeklyTempROC, and TempMin.

Redundancy Analysis

#Using standardized data

library(psych)
library(vegan)
library(packfor)
## packfor: R Package for Forward Selection (Canoco Manual p.49)
## version0.0-8
NestedMatrix <- read.csv("Data/NestedMatrixCSV.csv")
#Omit Site names (not numeric)
original_data <- NestedMatrix[, -1]
zdata <- as.data.frame(scale(original_data))

#Select columns based on elastic net regression analysis
omit_columns <- c(1:7, 9:10, 12:13, 16, 21, 25:26, 29, 32)
env <- zdata[, -omit_columns]# Explanatory variables
rda_env <- as.data.frame(env)
rda_res <- zdata[, -c(7:32)]
pairs.panels(rda_env)

#Collinearity is still strong between several variables.

site_names<- c("CFUA", "RT", "PF", "CF", "SQAP")
rda_env$Site <- rep(site_names, each = 5)
rda_env1 <- rda_env[, !names(rda_env) %in% "Site", drop = FALSE]
rda_result <- rda(rda_res ~ PPFDROC + Slope + TempMean + PPFD4 + S + Al + Aspect + Mg + P + Fe + C + PPFD2 + PPFD3 + TempMin + WeeklyTempROC, data = rda_env1, grouping = rda_env$Site)
summary(rda_result)
## 
## Call:
## rda(formula = rda_res ~ PPFDROC + Slope + TempMean + PPFD4 +      S + Al + Aspect + Mg + P + Fe + C + PPFD2 + PPFD3 + TempMin +      WeeklyTempROC, data = rda_env1, grouping = rda_env$Site) 
## 
## Partitioning of variance:
##               Inertia Proportion
## Total           6.000     1.0000
## Constrained     4.043     0.6738
## Unconstrained   1.957     0.3262
## 
## Eigenvalues, and their contribution to the variance 
## 
## Importance of components:
##                         RDA1   RDA2   RDA3    RDA4    PC1    PC2    PC3     PC4
## Eigenvalue            1.6589 1.5369 0.8408 0.00582 1.0572 0.4536 0.3072 0.08627
## Proportion Explained  0.2765 0.2562 0.1401 0.00097 0.1762 0.0756 0.0512 0.01438
## Cumulative Proportion 0.2765 0.5326 0.6728 0.67375 0.8500 0.9256 0.9768 0.99114
##                            PC5      PC6
## Eigenvalue            0.043231 0.009934
## Proportion Explained  0.007205 0.001656
## Cumulative Proportion 0.998344 1.000000
## 
## Accumulated constrained eigenvalues
## Importance of components:
##                         RDA1   RDA2   RDA3    RDA4
## Eigenvalue            1.6589 1.5369 0.8408 0.00582
## Proportion Explained  0.4104 0.3802 0.2080 0.00144
## Cumulative Proportion 0.4104 0.7906 0.9986 1.00000
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  3.464102 
## 
## 
## Species scores
## 
##              RDA1     RDA2    RDA3      RDA4     PC1       PC2
## Allicin    0.3339  0.42030  0.9605  0.008543  0.4390  0.371046
## Fresh      0.1655 -1.27521  0.2450 -0.043273 -0.4463 -0.008032
## Dry       -1.1455  0.48636  0.2836  0.022151 -0.3010 -0.397882
## Bulb      -1.2277 -0.05517 -0.2147 -0.047823  0.0397 -0.576947
## BulbWidth -0.5927 -0.86323  0.5803  0.037655 -0.5987 -0.332158
## SLA       -0.0905 -0.53511 -0.4856  0.074155  1.1278 -0.409821
## 
## 
## Site scores (weighted sums of species scores)
## 
##           RDA1    RDA2     RDA3     RDA4      PC1      PC2
## row1   0.58633 -0.7666 -0.82623  -1.9195 -0.29576 -0.74608
## row2   0.57303 -0.6864 -0.57344  -1.4160 -0.46945 -0.60957
## row3   0.88831 -0.4239 -0.65159   0.7083  0.09391 -0.06912
## row4   2.02511 -0.1484 -0.86543   5.1651  0.77360  1.79717
## row5   0.57426 -0.3400 -0.20708   0.7865 -0.10229 -0.37239
## row6  -1.54265 -0.8293 -0.05494   2.0885 -0.34262 -0.71602
## row7  -1.18017 -0.6337  0.17972  -3.5069 -0.43783  0.21426
## row8  -1.27997 -0.7657  0.83225  -5.5668 -0.91902  0.31259
## row9  -0.96937 -0.6473 -0.85497   9.8930  1.43065 -0.34697
## row10 -0.70953 -0.8246 -0.43997  -1.5260  0.26882  0.53614
## row11 -0.38381  0.8360 -1.29329   1.9065  0.49823 -0.55133
## row12 -0.12794  0.9900 -0.98778  -1.3485  0.11173  0.21333
## row13 -0.17904  0.8232 -0.16957  -7.4714 -0.87705  0.58715
## row14 -0.04492  0.8560 -1.36588   5.9092  0.73520 -0.08680
## row15 -0.33715  0.5297 -0.57214  -2.3586 -0.46811 -0.16235
## row16 -0.26021 -0.9180  0.90222  -2.4403 -0.53415 -1.32556
## row17  1.04296 -0.6054  0.92516 -13.1521 -0.83195  1.35595
## row18  0.46153 -0.5114  0.42938  -0.2973 -0.18773 -0.08923
## row19  0.79842  0.1386  1.06788  10.2401  1.58100  0.62276
## row20  0.18398 -0.4325  0.43669   0.8048 -0.02717 -0.56392
## row21  0.01105  1.0708  0.37662  -2.0053 -0.46802  0.15379
## row22 -0.12875  0.5997  1.31878  -0.7956 -0.86147  0.00880
## row23 -0.10760  0.9063  0.35935   2.3651  0.40488 -0.38533
## row24 -0.07349  0.7432  0.11456   7.3144  1.15026 -0.72521
## row25  0.17962  1.0398  1.91970  -3.3776 -0.22565  0.94795
## 
## 
## Site constraints (linear combinations of constraining variables)
## 
##           RDA1    RDA2     RDA3    RDA4      PC1      PC2
## row1   0.92941 -0.4731 -0.62475  0.6649 -0.29576 -0.74608
## row2   0.92941 -0.4731 -0.62475  0.6649 -0.46945 -0.60957
## row3   0.92941 -0.4731 -0.62475  0.6649  0.09391 -0.06912
## row4   0.92941 -0.4731 -0.62475  0.6649  0.77360  1.79717
## row5   0.92941 -0.4731 -0.62475  0.6649 -0.10229 -0.37239
## row6  -1.13634 -0.7401 -0.06758  0.2764 -0.34262 -0.71602
## row7  -1.13634 -0.7401 -0.06758  0.2764 -0.43783  0.21426
## row8  -1.13634 -0.7401 -0.06758  0.2764 -0.91902  0.31259
## row9  -1.13634 -0.7401 -0.06758  0.2764  1.43065 -0.34697
## row10 -1.13634 -0.7401 -0.06758  0.2764  0.26882  0.53614
## row11 -0.21457  0.8070 -0.87773 -0.6726  0.49823 -0.55133
## row12 -0.21457  0.8070 -0.87773 -0.6726  0.11173  0.21333
## row13 -0.21457  0.8070 -0.87773 -0.6726 -0.87705  0.58715
## row14 -0.21457  0.8070 -0.87773 -0.6726  0.73520 -0.08680
## row15 -0.21457  0.8070 -0.87773 -0.6726 -0.46811 -0.16235
## row16  0.44533 -0.4657  0.75226 -0.9689 -0.53415 -1.32556
## row17  0.44533 -0.4657  0.75226 -0.9689 -0.83195  1.35595
## row18  0.44533 -0.4657  0.75226 -0.9689 -0.18773 -0.08923
## row19  0.44533 -0.4657  0.75226 -0.9689  1.58100  0.62276
## row20  0.44533 -0.4657  0.75226 -0.9689 -0.02717 -0.56392
## row21 -0.02383  0.8720  0.81780  0.7002 -0.46802  0.15379
## row22 -0.02383  0.8720  0.81780  0.7002 -0.86147  0.00880
## row23 -0.02383  0.8720  0.81780  0.7002  0.40488 -0.38533
## row24 -0.02383  0.8720  0.81780  0.7002  1.15026 -0.72521
## row25 -0.02383  0.8720  0.81780  0.7002 -0.22565  0.94795
## 
## 
## Biplot scores for constraining variables
## 
##              RDA1     RDA2    RDA3      RDA4 PC1 PC2
## PPFDROC   0.35654 -0.02643 -0.9297  0.088120   0   0
## Slope    -0.90093  0.08930 -0.4246 -0.007655   0   0
## TempMean -0.24894  0.56374 -0.6554  0.436703   0   0
## PPFD4    -0.01943  0.81424  0.4804 -0.325345   0   0
sqrt(vif.cca(rda_result)) 
##       PPFDROC         Slope      TempMean         PPFD4             S 
##      1.751286      1.413839      1.816629      1.402437            NA 
##            Al        Aspect            Mg             P            Fe 
##            NA            NA            NA            NA            NA 
##             C         PPFD2         PPFD3       TempMin WeeklyTempROC 
##            NA            NA            NA            NA            NA
anova.cca(rda_result)#global RDA significance
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(formula = rda_res ~ PPFDROC + Slope + TempMean + PPFD4 + S + Al + Aspect + Mg + P + Fe + C + PPFD2 + PPFD3 + TempMin + WeeklyTempROC, data = rda_env1, grouping = rda_env$Site)
##          Df Variance      F Pr(>F)    
## Model     4   4.0425 10.326  0.001 ***
## Residual 20   1.9575                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova.cca(rda_result, by = "axis") # significance of axes
## Permutation test for rda under reduced model
## Forward tests for axes
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(formula = rda_res ~ PPFDROC + Slope + TempMean + PPFD4 + S + Al + Aspect + Mg + P + Fe + C + PPFD2 + PPFD3 + TempMin + WeeklyTempROC, data = rda_env1, grouping = rda_env$Site)
##          Df Variance       F Pr(>F)    
## RDA1      1  1.65893 16.9498  0.001 ***
## RDA2      1  1.53694 15.7034  0.001 ***
## RDA3      1  0.84083  8.5910  0.001 ***
## RDA4      1  0.00582  0.0595  0.991    
## Residual 20  1.95747                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova.cca(rda_result, by = "terms") #significance of terms
## Permutation test for rda under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(formula = rda_res ~ PPFDROC + Slope + TempMean + PPFD4 + S + Al + Aspect + Mg + P + Fe + C + PPFD2 + PPFD3 + TempMin + WeeklyTempROC, data = rda_env1, grouping = rda_env$Site)
##          Df Variance       F Pr(>F)    
## PPFDROC   1  0.93883  9.5923  0.001 ***
## Slope     1  1.55160 15.8531  0.001 ***
## TempMean  1  0.99155 10.1310  0.001 ***
## PPFD4     1  0.56054  5.7272  0.001 ***
## Residual 20  1.95747                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Trying forward selection with stopping criterion of R^2 value
R2 <- RsquareAdj(rda_result)
forward.sel(rda_res, rda_env1, adjR2thresh = R2)
## Testing variable 1
## Testing variable 2
## Testing variable 3
## Testing variable 4
## Procedure stopped (alpha criteria): pvalue for variable 4 is 0.159000 (superior to 0.050000)
##   variables order        R2     R2Cum  AdjR2Cum         F  pval
## 1     Slope     7 0.2517277 0.2517277 0.2191941  7.737473 0.001
## 2     PPFD4    11 0.2069176 0.4586453 0.4094312  8.408882 0.001
## 3         C     1 0.1880873 0.6467326 0.5962659 11.180862 0.001
#Trying ordistep() which uses p-value as a stopping criterion

step.forward <- ordistep(rda(rda_res ~ 1, data=rda_env1), scope=formula(rda_result), direction="forward", pstep=1000)
## 
## Start: rda_res ~ 1 
## 
##                 Df    AIC      F Pr(>F)   
## + Slope          1 40.524 7.7375  0.005 **
## + PPFD4          1 42.120 5.8357  0.005 **
## + PPFD2          1 42.648 5.2333  0.005 **
## + WeeklyTempROC  1 42.801 5.0614  0.005 **
## + Al             1 42.921 4.9272  0.005 **
## + Fe             1 43.152 4.6696  0.005 **
## + P              1 43.347 4.4555  0.005 **
## + TempMean       1 43.447 4.3458  0.005 **
## + PPFDROC        1 43.519 4.2664  0.005 **
## + PPFD3          1 43.885 3.8706  0.005 **
## + C              1 43.170 4.6504  0.010 **
## + S              1 43.609 4.1685  0.015 * 
## + Mg             1 43.914 3.8394  0.015 * 
## + Aspect         1 44.694 3.0146  0.030 * 
## + TempMin        1 46.866 0.8504  0.525   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Step: rda_res ~ Slope 
## 
##                 Df    AIC      F Pr(>F)   
## + PPFD4          1 34.431 8.4089  0.005 **
## + WeeklyTempROC  1 35.842 6.7405  0.005 **
## + C              1 36.140 6.4000  0.005 **
## + S              1 36.320 6.1961  0.005 **
## + Fe             1 36.590 5.8930  0.005 **
## + PPFD3          1 37.105 5.3248  0.005 **
## + PPFD2          1 37.248 5.1687  0.005 **
## + Mg             1 37.400 5.0041  0.005 **
## + P              1 38.167 4.1882  0.005 **
## + Al             1 36.029 6.5269  0.010 **
## + PPFDROC        1 36.367 6.1437  0.010 **
## + Aspect         1 38.291 4.0587  0.010 **
## + TempMean       1 36.626 5.8532  0.015 * 
## + TempMin        1 42.002 0.4644  0.750   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Step: rda_res ~ Slope + PPFD4 
## 
##                 Df    AIC       F Pr(>F)   
## + C              1 25.760 11.1809  0.005 **
## + PPFDROC        1 25.952 10.9343  0.005 **
## + S              1 26.734  9.9510  0.005 **
## + Aspect         1 28.611  7.7129  0.005 **
## + TempMean       1 28.647  7.6712  0.005 **
## + WeeklyTempROC  1 28.678  7.6362  0.005 **
## + PPFD2          1 29.141  7.1104  0.005 **
## + Mg             1 30.470  5.6549  0.005 **
## + P              1 30.608  5.5087  0.010 **
## + Al             1 33.147  2.9483  0.045 * 
## + Fe             1 33.541  2.5741  0.090 . 
## + PPFD3          1 34.622  1.5767  0.150   
## + TempMin        1 34.947  1.2844  0.290   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Step: rda_res ~ Slope + PPFD4 + C 
## 
##                 Df    AIC      F Pr(>F)
## + S              1 25.771 1.6565  0.135
## + PPFD3          1 25.771 1.6565  0.135
## + WeeklyTempROC  1 25.771 1.6565  0.135
## + Mg             1 25.771 1.6565  0.140
## + Aspect         1 25.771 1.6565  0.140
## + TempMean       1 25.771 1.6565  0.155
## + Fe             1 25.771 1.6565  0.155
## + PPFDROC        1 25.771 1.6565  0.155
## + P              1 25.771 1.6565  0.175
## + PPFD2          1 25.771 1.6565  0.175
## + Al             1 25.771 1.6565  0.215
## + TempMin        1 25.771 1.6565  0.225
#Results of forward selection indicate that C, PPFD4, and Slope are the most parsimonious contributors.Considering that forward selection does overfit data, the results are ecologically logical as they each represent a category of interacting environmental abiotic factors. The only category missing is temperature effect. When analyzing all prior tests, the temperature variable that explains the most variance is WeeklyTempROC. Rerun RDA with just these four variables.

rda_res <- zdata[, -c(5,7:32)]
rda_result <- rda(rda_res ~ WeeklyTempROC + C + PPFD4 + Slope,  data = rda_env1, grouping = rda_env$Site)
summary(rda_result)
## 
## Call:
## rda(formula = rda_res ~ WeeklyTempROC + C + PPFD4 + Slope, data = rda_env1,      grouping = rda_env$Site) 
## 
## Partitioning of variance:
##               Inertia Proportion
## Total           5.000      1.000
## Constrained     3.325      0.665
## Unconstrained   1.675      0.335
## 
## Eigenvalues, and their contribution to the variance 
## 
## Importance of components:
##                         RDA1   RDA2    RDA3      RDA4    PC1     PC2     PC3
## Eigenvalue            1.6263 1.1964 0.49821 0.0042429 0.9071 0.40342 0.25288
## Proportion Explained  0.3253 0.2393 0.09964 0.0008486 0.1814 0.08068 0.05058
## Cumulative Proportion 0.3253 0.5645 0.66419 0.6650396 0.8465 0.92714 0.97771
##                           PC4     PC5
## Eigenvalue            0.08619 0.02525
## Proportion Explained  0.01724 0.00505
## Cumulative Proportion 0.99495 1.00000
## 
## Accumulated constrained eigenvalues
## Importance of components:
##                         RDA1   RDA2   RDA3     RDA4
## Eigenvalue            1.6263 1.1964 0.4982 0.004243
## Proportion Explained  0.4891 0.3598 0.1498 0.001276
## Cumulative Proportion 0.4891 0.8489 0.9987 1.000000
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  3.309751 
## 
## 
## Species scores
## 
##            RDA1     RDA2    RDA3      RDA4     PC1      PC2
## Allicin  0.1380  0.97792  0.5920  0.022510  0.4522  0.67355
## Fresh    0.7882 -0.83775  0.7456 -0.008949 -0.4517 -0.06453
## Dry     -1.2860  0.07298  0.3529  0.037758 -0.2134 -0.34779
## Bulb    -1.1149 -0.65980  0.1674 -0.035911  0.1633 -0.48286
## SLA      0.1610 -0.72281 -0.1804  0.077418  1.2274 -0.26818
## 
## 
## Site scores (weighted sums of species scores)
## 
##          RDA1     RDA2      RDA3     RDA4        PC1      PC2
## row1   0.8082 -0.75292 -0.469453  -2.0632 -0.1988825 -0.81976
## row2   0.7736 -0.54487 -0.424039  -2.6889 -0.3329122 -0.59553
## row3   0.9168 -0.28971 -0.595877   0.8392  0.0975660 -0.02942
## row4   1.7447  0.23984 -1.180386   6.5485  0.3851940  1.46368
## row5   0.6312 -0.12013 -0.237783   0.4382  0.0490346 -0.01897
## row6  -0.9281 -1.19396  0.587412   1.9314 -0.2082981 -0.69758
## row7  -0.7026 -0.80566  0.627100  -5.2746 -0.4545611  0.15302
## row8  -0.7062 -0.63893  1.281806  -7.6088 -0.8268689  0.46965
## row9  -0.5576 -1.25848 -0.162171  13.3917  1.3995872 -0.18286
## row10 -0.2467 -1.11063  0.254203  -0.9650  0.0901409  0.25777
## row11 -0.7475 -0.18217 -1.147783   4.0493  0.5041209 -0.52177
## row12 -0.5878  0.19434 -1.107672  -1.0554  0.0124791  0.10021
## row13 -0.5248  0.46920 -0.460840 -10.1345 -0.8766167  0.56946
## row14 -0.4682 -0.03189 -1.476033   7.6130  0.6927658 -0.09176
## row15 -0.5390  0.01311 -0.683185  -3.8801 -0.3327491 -0.05614
## row16  0.2264 -0.31824  1.070477  -4.2475 -0.1809668 -1.01785
## row17  1.1777  0.34265  0.914570 -15.6819 -1.1154086  0.77741
## row18  0.6365  0.02823  0.329143  -1.5134 -0.2231260 -0.36235
## row19  0.6402  0.84639  0.877606  15.8666  1.5204522  1.28556
## row20  0.3639 -0.04318  0.490874   1.0759 -0.0009508 -0.68277
## row21 -0.4504  1.03854 -0.380685  -5.0976 -0.6203031 -0.39376
## row22 -0.3235  1.09670  0.582883  -3.8735 -0.7088599  0.04742
## row23 -0.4858  0.79134 -0.006191   3.4593  0.3809274 -0.44420
## row24 -0.3966  0.53064 -0.005813  11.3537  1.1845016 -0.54759
## row25 -0.2547  1.69978  1.321836  -2.4826 -0.2362659  1.33813
## 
## 
## Site constraints (linear combinations of constraining variables)
## 
##          RDA1     RDA2    RDA3    RDA4        PC1      PC2
## row1   0.9749 -0.29356 -0.5815  0.6148 -0.1988825 -0.81976
## row2   0.9749 -0.29356 -0.5815  0.6148 -0.3329122 -0.59553
## row3   0.9749 -0.29356 -0.5815  0.6148  0.0975660 -0.02942
## row4   0.9749 -0.29356 -0.5815  0.6148  0.3851940  1.46368
## row5   0.9749 -0.29356 -0.5815  0.6148  0.0490346 -0.01897
## row6  -0.6282 -1.00153  0.5177  0.2949 -0.2082981 -0.69758
## row7  -0.6282 -1.00153  0.5177  0.2949 -0.4545611  0.15302
## row8  -0.6282 -1.00153  0.5177  0.2949 -0.8268689  0.46965
## row9  -0.6282 -1.00153  0.5177  0.2949  1.3995872 -0.18286
## row10 -0.6282 -1.00153  0.5177  0.2949  0.0901409  0.25777
## row11 -0.5735  0.09252 -0.9751 -0.6815  0.5041209 -0.52177
## row12 -0.5735  0.09252 -0.9751 -0.6815  0.0124791  0.10021
## row13 -0.5735  0.09252 -0.9751 -0.6815 -0.8766167  0.56946
## row14 -0.5735  0.09252 -0.9751 -0.6815  0.6927658 -0.09176
## row15 -0.5735  0.09252 -0.9751 -0.6815 -0.3327491 -0.05614
## row16  0.6090  0.17117  0.7365 -0.9000 -0.1809668 -1.01785
## row17  0.6090  0.17117  0.7365 -0.9000 -1.1154086  0.77741
## row18  0.6090  0.17117  0.7365 -0.9000 -0.2231260 -0.36235
## row19  0.6090  0.17117  0.7365 -0.9000  1.5204522  1.28556
## row20  0.6090  0.17117  0.7365 -0.9000 -0.0009508 -0.68277
## row21 -0.3822  1.03140  0.3024  0.6719 -0.6203031 -0.39376
## row22 -0.3822  1.03140  0.3024  0.6719 -0.7088599  0.04742
## row23 -0.3822  1.03140  0.3024  0.6719  0.3809274 -0.44420
## row24 -0.3822  1.03140  0.3024  0.6719  1.1845016 -0.54759
## row25 -0.3822  1.03140  0.3024  0.6719 -0.2362659  1.33813
## 
## 
## Biplot scores for constraining variables
## 
##                  RDA1    RDA2     RDA3      RDA4 PC1 PC2
## WeeklyTempROC -0.6054  0.2228 -0.58391 -0.492913   0   0
## C             -0.2620  0.1321  0.95531 -0.035954   0   0
## PPFD4         -0.3823  0.8586  0.08783 -0.330036   0   0
## Slope         -0.8521 -0.4949 -0.17009 -0.008573   0   0
sqrt(vif.cca(rda_result)) #check multicollinearity after selection
## WeeklyTempROC             C         PPFD4         Slope 
##      3.751730      2.456980      3.123435      2.444459
anova.cca(rda_result)#global RDA significance
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(formula = rda_res ~ WeeklyTempROC + C + PPFD4 + Slope, data = rda_env1, grouping = rda_env$Site)
##          Df Variance      F Pr(>F)    
## Model     4   3.3252 9.9271  0.001 ***
## Residual 20   1.6748                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova.cca(rda_result, by = "axis") # significance of axes
## Permutation test for rda under reduced model
## Forward tests for axes
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(formula = rda_res ~ WeeklyTempROC + C + PPFD4 + Slope, data = rda_env1, grouping = rda_env$Site)
##          Df Variance       F Pr(>F)    
## RDA1      1  1.62631 19.4209  0.001 ***
## RDA2      1  1.19644 14.2876  0.001 ***
## RDA3      1  0.49821  5.9495  0.002 ** 
## RDA4      1  0.00424  0.0507  0.997    
## Residual 20  1.67480                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova.cca(rda_result, by = "terms") #significance of terms
## Permutation test for rda under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(formula = rda_res ~ WeeklyTempROC + C + PPFD4 + Slope, data = rda_env1, grouping = rda_env$Site)
##               Df Variance       F Pr(>F)    
## WeeklyTempROC  1  0.82625  9.8668  0.001 ***
## C              1  0.79948  9.5471  0.001 ***
## PPFD4          1  1.23202 14.7124  0.001 ***
## Slope          1  0.46746  5.5822  0.001 ***
## Residual      20  1.67480                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(eigenvals(rda_result, model = "constrained"))
## Importance of components:
##                         RDA1   RDA2   RDA3     RDA4
## Eigenvalue            1.6263 1.1964 0.4982 0.004243
## Proportion Explained  0.4891 0.3598 0.1498 0.001276
## Cumulative Proportion 0.4891 0.8489 0.9987 1.000000
screeplot(rda_result)

site_colors <- c("CFUA" = "darkorange3", "RT" = "darkolivegreen4", "PF" = "slateblue3", "CF" = "gold3", "SQAP" = "darkcyan")
colors <- sapply(rda_env$Site, function(site) site_colors[site])# Vector of colors/site
plot(rda_result, scaling = 2, main = "RDA - Scaling = 2", type = "n") #Data is already z-standardized, so default scaling is used. Scaling 2 displays effects of explanatory variables
# Plot circles with different colors and labels based on the 'Site' column
text(rda_result, display="species", col="firebrick3", cex=1)
points(rda_result, display="sites", cex=1.3, pch=20, col=colors)
text(rda_result, scaling = 2, display="bp", col="darkblue", cex=1)
# Add a legend
legend("topright", legend = unique(rda_env$Site), col = site_colors, pch = 19, title = "Site")

plot(rda_result, scaling = 1, main = "RDA - Scaling = 1", type = "n") #Using scaling 1 to look at relationships between objects
# Plot circles with different colors and labels based on the 'Site' column
text(rda_result, display="species", col="firebrick3", cex=1)
points(rda_result, display="sites", cex=1.3, pch=20, col=colors)
text(rda_result, scaling = 1, display="bp", col="darkblue", cex=1)
# Add a legend
legend("topright", legend = unique(rda_env$Site), col = site_colors, pch = 19, title = "Site")

Having double the response variables may be convoluting the data. Reducing the model even more by retaining original variable interests: Allicin, Dry biomass, and Specific Leaf Area.

Does partitioning the explanatory variable types explain interactions?

## Warning: collinearity detected in X1: mm = 12, m = 4
## Warning: collinearity detected in X2: mm = 7, m = 4
## Warning: collinearity detected in X3: mm = 5, m = 4
## Warning: collinearity detected in cbind(X1,X2): mm = 19, m = 4
## Warning: collinearity detected in cbind(X1,X3: mm = 17, m = 4
## Warning: collinearity detected in cbind(X1,X4): mm = 13, m = 4
## Warning: collinearity detected in cbind(X2,X3): mm = 12, m = 4
## Warning: collinearity detected in cbind(X2,X4): mm = 8, m = 4
## Warning: collinearity detected in cbind(X3,X4): mm = 6, m = 4
## Warning: collinearity detected in cbind(X1,X2,X3): mm = 24, m = 4
## Warning: collinearity detected in c(X1,X2,X4): mm = 20, m = 4
## Warning: collinearity detected in cbind(X1,X3,X4): mm = 18, m = 4
## Warning: collinearity detected in cbind(X2,X3,X4): mm = 13, m = 4
## Warning: collinearity detected in cbind(X1,X2,X3,X4): mm = 25, m = 4
## No. of explanatory tables: 4 
## Total variation (SS): 72 
##             Variance: 3 
## No. of observations: 25 
## 
## Partition table:
##                             Df R.square Adj.R.square Testable
## [aeghklno] = X1              4  0.56270      0.47524     TRUE
## [befiklmo] = X2              4  0.56270      0.47524     TRUE
## [cfgjlmno] = X3              4  0.56270      0.47524     TRUE
## [dhijkmno] = X4              1  0.23658      0.20339     TRUE
## [abefghiklmno] = X1+X2       4  0.56270      0.47524     TRUE
## [acefghjklmno] = X1+X3       4  0.56270      0.47524     TRUE
## [adeghijklmno] = X1+X4       4  0.56270      0.47524     TRUE
## [bcefgijklmno] = X2+X3       4  0.56270      0.47524     TRUE
## [bdefhijklmno] = X2+X4       4  0.56270      0.47524     TRUE
## [cdfghijklmno] = X3+X4       4  0.56270      0.47524     TRUE
## [abcefghijklmno] = X1+X2+X3  4  0.56270      0.47524     TRUE
## [abdefghijklmno] = X1+X2+X4  4  0.56270      0.47524     TRUE
## [acdefghijklmno] = X1+X3+X4  4  0.56270      0.47524     TRUE
## [bcdefghijklmno] = X2+X3+X4  4  0.56270      0.47524     TRUE
## [abcdefghijklmno] = All      4  0.56270      0.47524     TRUE
## Individual fractions                                         
## [a] = X1 | X2+X3+X4          0               0.00000     TRUE
## [b] = X2 | X1+X3+X4          0               0.00000     TRUE
## [c] = X3 | X1+X2+X4          0               0.00000     TRUE
## [d] = X4 | X1+X2+X3          0               0.00000     TRUE
## [e]                          0               0.00000    FALSE
## [f]                          0               0.00000    FALSE
## [g]                          0               0.00000    FALSE
## [h]                          0               0.00000    FALSE
## [i]                          0               0.00000    FALSE
## [j]                          0               0.00000    FALSE
## [k]                          0               0.00000    FALSE
## [l]                          0               0.27185    FALSE
## [m]                          0               0.00000    FALSE
## [n]                          0               0.00000    FALSE
## [o]                          0               0.20339    FALSE
## [p] = Residuals              0               0.52476    FALSE
## Controlling 2 tables X                                       
## [ae] = X1 | X3+X4            0               0.00000    FALSE
## [ag] = X1 | X2+X4            0               0.00000    FALSE
## [ah] = X1 | X2+X3            0               0.00000    FALSE
## [be] = X2 | X3+X4            0               0.00000    FALSE
## [bf] = X2 | X1+X4            0               0.00000    FALSE
## [bi] = X2 | X1+X3            0               0.00000    FALSE
## [cf] = X3 | X1+X4            0               0.00000    FALSE
## [cg] = X3 | X2+X4            0               0.00000    FALSE
## [cj] = X3 | X1+X2            0               0.00000    FALSE
## [dh] = X4 | X2+X3            0               0.00000    FALSE
## [di] = X4 | X1+X3            0               0.00000    FALSE
## [dj] = X4 | X1+X2            0               0.00000    FALSE
## Controlling 1 table X                                        
## [aghn] = X1 | X2             0               0.00000    FALSE
## [aehk] = X1 | X3             0               0.00000    FALSE
## [aegl] = X1 | X4             3               0.27185     TRUE
## [bfim] = X2 | X1             0               0.00000    FALSE
## [beik] = X2 | X3             0               0.00000    FALSE
## [befl] = X2 | X4             3               0.27185     TRUE
## [cfjm] = X3 | X1             0               0.00000    FALSE
## [cgjn] = X3 | X2             0               0.00000    FALSE
## [cfgl] = X3 | X4             3               0.27185     TRUE
## [dijm] = X4 | X1             0               0.00000    FALSE
## [dhjn] = X4 | X2             0               0.00000    FALSE
## [dhik] = X4 | X3             0               0.00000    FALSE
## ---
## Use function 'rda' to test significance of fractions of interest
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X3
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X2, X3
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X2, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2, X3
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X2, X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2, X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis

## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.chem)
##          Df Variance      F Pr(>F)    
## Model     4   1.6881 6.4337  0.001 ***
## Residual 20   1.3119                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.light)
##          Df Variance      F Pr(>F)    
## Model     4   1.6881 6.4337  0.001 ***
## Residual 20   1.3119                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.temp)
##          Df Variance      F Pr(>F)    
## Model     4   1.6881 6.4337  0.001 ***
## Residual 20   1.3119                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.topo)
##          Df Variance      F Pr(>F)    
## Model     1  0.70974 7.1276  0.001 ***
## Residual 23  2.29026                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Warning: collinearity detected in X1: mm = 12, m = 4
## Warning: collinearity detected in X2: mm = 7, m = 4
## Warning: collinearity detected in X3: mm = 5, m = 4
## Warning: collinearity detected in cbind(X1,X2): mm = 19, m = 4
## Warning: collinearity detected in cbind(X1,X3: mm = 17, m = 4
## Warning: collinearity detected in cbind(X1,X4): mm = 13, m = 4
## Warning: collinearity detected in cbind(X2,X3): mm = 12, m = 4
## Warning: collinearity detected in cbind(X2,X4): mm = 8, m = 4
## Warning: collinearity detected in cbind(X3,X4): mm = 6, m = 4
## Warning: collinearity detected in cbind(X1,X2,X3): mm = 24, m = 4
## Warning: collinearity detected in c(X1,X2,X4): mm = 20, m = 4
## Warning: collinearity detected in cbind(X1,X3,X4): mm = 18, m = 4
## Warning: collinearity detected in cbind(X2,X3,X4): mm = 13, m = 4
## Warning: collinearity detected in cbind(X1,X2,X3,X4): mm = 25, m = 4
## No. of explanatory tables: 4 
## Total variation (SS): 120 
##             Variance: 5 
## No. of observations: 25 
## 
## Partition table:
##                             Df R.square Adj.R.square Testable
## [aeghklno] = X1              4  0.66504      0.59805     TRUE
## [befiklmo] = X2              4  0.66504      0.59805     TRUE
## [cfgjlmno] = X3              4  0.66504      0.59805     TRUE
## [dhijkmno] = X4              1  0.29765      0.26712     TRUE
## [abefghiklmno] = X1+X2       4  0.66504      0.59805     TRUE
## [acefghjklmno] = X1+X3       4  0.66504      0.59805     TRUE
## [adeghijklmno] = X1+X4       4  0.66504      0.59805     TRUE
## [bcefgijklmno] = X2+X3       4  0.66504      0.59805     TRUE
## [bdefhijklmno] = X2+X4       4  0.66504      0.59805     TRUE
## [cdfghijklmno] = X3+X4       4  0.66504      0.59805     TRUE
## [abcefghijklmno] = X1+X2+X3  4  0.66504      0.59805     TRUE
## [abdefghijklmno] = X1+X2+X4  4  0.66504      0.59805     TRUE
## [acdefghijklmno] = X1+X3+X4  4  0.66504      0.59805     TRUE
## [bcdefghijklmno] = X2+X3+X4  4  0.66504      0.59805     TRUE
## [abcdefghijklmno] = All      4  0.66504      0.59805     TRUE
## Individual fractions                                         
## [a] = X1 | X2+X3+X4          0               0.00000     TRUE
## [b] = X2 | X1+X3+X4          0               0.00000     TRUE
## [c] = X3 | X1+X2+X4          0               0.00000     TRUE
## [d] = X4 | X1+X2+X3          0               0.00000     TRUE
## [e]                          0               0.00000    FALSE
## [f]                          0               0.00000    FALSE
## [g]                          0               0.00000    FALSE
## [h]                          0               0.00000    FALSE
## [i]                          0               0.00000    FALSE
## [j]                          0               0.00000    FALSE
## [k]                          0               0.00000    FALSE
## [l]                          0               0.33093    FALSE
## [m]                          0               0.00000    FALSE
## [n]                          0               0.00000    FALSE
## [o]                          0               0.26712    FALSE
## [p] = Residuals              0               0.40195    FALSE
## Controlling 2 tables X                                       
## [ae] = X1 | X3+X4            0               0.00000    FALSE
## [ag] = X1 | X2+X4            0               0.00000    FALSE
## [ah] = X1 | X2+X3            0               0.00000    FALSE
## [be] = X2 | X3+X4            0               0.00000    FALSE
## [bf] = X2 | X1+X4            0               0.00000    FALSE
## [bi] = X2 | X1+X3            0               0.00000    FALSE
## [cf] = X3 | X1+X4            0               0.00000    FALSE
## [cg] = X3 | X2+X4            0               0.00000    FALSE
## [cj] = X3 | X1+X2            0               0.00000    FALSE
## [dh] = X4 | X2+X3            0               0.00000    FALSE
## [di] = X4 | X1+X3            0               0.00000    FALSE
## [dj] = X4 | X1+X2            0               0.00000    FALSE
## Controlling 1 table X                                        
## [aghn] = X1 | X2             0               0.00000    FALSE
## [aehk] = X1 | X3             0               0.00000    FALSE
## [aegl] = X1 | X4             3               0.33093     TRUE
## [bfim] = X2 | X1             0               0.00000    FALSE
## [beik] = X2 | X3             0               0.00000    FALSE
## [befl] = X2 | X4             3               0.33093     TRUE
## [cfjm] = X3 | X1             0               0.00000    FALSE
## [cgjn] = X3 | X2             0               0.00000    FALSE
## [cfgl] = X3 | X4             3               0.33093     TRUE
## [dijm] = X4 | X1             0               0.00000    FALSE
## [dhjn] = X4 | X2             0               0.00000    FALSE
## [dhik] = X4 | X3             0               0.00000    FALSE
## ---
## Use function 'rda' to test significance of fractions of interest
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X3
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X2, X3
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X2, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2, X3
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X2, X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis
## Warning: collinearity detected: redundant variable(s)  between tables X1, X2, X3, X4
## results are probably incorrect: remove redundant variable(s) and repeat the analysis

## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.chem)
##          Df Variance      F Pr(>F)    
## Model     4   3.3252 9.9271  0.001 ***
## Residual 20   1.6748                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.light)
##          Df Variance      F Pr(>F)    
## Model     4   3.3252 9.9271  0.001 ***
## Residual 20   1.6748                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.temp)
##          Df Variance      F Pr(>F)    
## Model     4   3.3252 9.9271  0.001 ***
## Residual 20   1.6748                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 999
## 
## Model: rda(X = env.res, Y = env.topo)
##          Df Variance      F Pr(>F)    
## Model     1   1.4883 9.7473  0.001 ***
## Residual 23   3.5117                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Indicator Species Analysis

Used to determine what understory species are associated with each site and across all sites, where Allium tricoccum is found.

library(readr)
library(indicspecies)
library(vegan)
library(knitr)
## Warning: package 'knitr' was built under R version 4.3.3
#Load data
herb_data <- read.csv("Data/herb_data.csv")
herb_data <- herb_data[,-29]

#define data and grouping vector
abund = herb_data[,2:ncol(herb_data)]

site = herb_data$Site

#Standard ISA(for determining the predictive values of species as indicators of site conditions - always positive)
inv = multipatt(abund, site, func = "IndVal.g", control = how(nperm=999))

summary(inv, alpha=0.05)
## 
##  Multilevel pattern analysis
##  ---------------------------
## 
##  Association function: IndVal.g
##  Significance level (alpha): 0.05
## 
##  Total number of species: 27
##  Selected number of species: 7 
##  Number of species associated to 1 group: 5 
##  Number of species associated to 2 groups: 1 
##  Number of species associated to 3 groups: 1 
##  Number of species associated to 4 groups: 0 
## 
##  List of species associated to each combination: 
## 
##  Group CFUA  #sps.  3 
##       stat p.value    
## DC   1.000   0.001 ***
## CLAY 0.982   0.001 ***
## CAR  0.775   0.021 *  
## 
##  Group PF  #sps.  2 
##      stat p.value   
## FA  0.894   0.003 **
## SOL 0.775   0.014 * 
## 
##  Group CF+PF  #sps.  1 
##     stat p.value  
## TG 0.775   0.017 *
## 
##  Group PF+RT+SQAP  #sps.  1 
##     stat p.value   
## EA 0.894   0.005 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Dividing inv into specificity and fidelity values - exclusivity and faithfulness to group

summary(inv, indvalcomp = TRUE)
## 
##  Multilevel pattern analysis
##  ---------------------------
## 
##  Association function: IndVal.g
##  Significance level (alpha): 0.05
## 
##  Total number of species: 27
##  Selected number of species: 7 
##  Number of species associated to 1 group: 5 
##  Number of species associated to 2 groups: 1 
##  Number of species associated to 3 groups: 1 
##  Number of species associated to 4 groups: 0 
## 
##  List of species associated to each combination: 
## 
##  Group CFUA  #sps.  3 
##           A      B  stat p.value    
## DC   1.0000 1.0000 1.000   0.001 ***
## CLAY 0.9649 1.0000 0.982   0.001 ***
## CAR  1.0000 0.6000 0.775   0.021 *  
## 
##  Group PF  #sps.  2 
##       A   B  stat p.value   
## FA  1.0 0.8 0.894   0.003 **
## SOL 1.0 0.6 0.775   0.014 * 
## 
##  Group CF+PF  #sps.  1 
##      A   B  stat p.value  
## TG 1.0 0.6 0.775   0.017 *
## 
##  Group PF+RT+SQAP  #sps.  1 
##      A   B  stat p.value   
## EA 1.0 0.8 0.894   0.005 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#all species indicator values, regardless of significance
inv$sign
##      s.CF s.CFUA s.PF s.RT s.SQAP index      stat p.value
## AT      1      1    1    1      1    31 1.0000000      NA
## TG      1      0    1    0      0     7 0.7745967   0.017
## TE      1      1    0    0      0     6 0.4472136   1.000
## EA      0      0    1    1      1    25 0.8944272   0.005
## MR      0      1    0    0      0     2 0.6324555   0.164
## SC      0      0    0    1      0     4 0.6324555   0.201
## CORD    0      1    0    0      0     2 0.4472136   1.000
## CLAY    0      1    0    0      0     2 0.9822995   0.001
## CT      0      1    0    0      0     2 0.6324555   0.181
## CAR     0      1    0    0      0     2 0.7745967   0.021
## DC      0      1    0    0      0     2 1.0000000   0.001
## PA      1      0    1    0      0     7 0.5477226   0.464
## CP      0      0    1    0      0     3 0.6324555   0.156
## PP      0      0    0    1      1    15 0.5477226   0.444
## PV      0      0    1    0      0     3 0.6324555   0.156
## AS      0      1    0    1      0    11 0.6988362   0.081
## PS      0      1    0    0      0     2 0.4472136   1.000
## FG      0      1    0    0      0     2 0.6324555   0.164
## SF      0      0    0    0      1     5 0.4472136   1.000
## NAB     0      0    0    0      1     5 0.6324555   0.152
## RO      0      0    1    0      0     3 0.4472136   1.000
## FA      0      0    1    0      0     3 0.8944272   0.003
## TO      0      0    1    0      0     3 0.4472136   1.000
## SOL     0      0    1    0      0     3 0.7745967   0.014
## MC      0      0    1    0      0     3 0.4472136   1.000
## OV      0      0    1    0      0     3 0.6324555   0.156
## TA      0      0    1    0      0     3 0.4472136   1.000
#Simper() function examines relative contributions to differences at each site via Bray-Curtis (dis)similarity
sim <- simper(abund, site)
summary(sim)
## 
## Contrast: CFUA_RT 
## 
##       average       sd    ratio      ava      avb cumsum     p    
## DC    0.13393  0.07683  1.74330 23.20000  0.00000  0.205 0.001 ***
## CAR   0.13145  0.14650  0.89730 23.20000  0.00000  0.406 0.001 ***
## AT    0.10586  0.07500  1.41140 46.20000 29.20000  0.568 0.942    
## CT    0.08384  0.11070  0.75730 13.00000  0.00000  0.696 0.001 ***
## EA    0.08226  0.08212  1.00170  0.00000 14.40000  0.822 0.981    
## CLAY  0.06249  0.05248  1.19080 11.00000  0.00000  0.918 0.001 ***
## AS    0.03576  0.04120  0.86810  2.60000  5.80000  0.973 0.057 .  
## SC    0.00571  0.00730  0.78280  0.00000  1.00000  0.981 0.059 .  
## MR    0.00450  0.00666  0.67600  0.80000  0.00000  0.988 0.001 ***
## FG    0.00227  0.00284  0.79820  0.40000  0.00000  0.992 0.001 ***
## PP    0.00222  0.00280  0.79370  0.00000  0.40000  0.995 0.062 .  
## TE    0.00120  0.00244  0.48910  0.20000  0.00000  0.997 0.383    
## CORD  0.00104  0.00212  0.48930  0.20000  0.00000  0.998 0.001 ***
## PS    0.00104  0.00212  0.48930  0.20000  0.00000  1.000 0.001 ***
## TG    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.972    
## PA    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.797    
## CP    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.671    
## PV    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.646    
## SF    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.447    
## NAB   0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.664    
## RO    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.405    
## FA    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.902    
## TO    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.436    
## SOL   0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.813    
## MC    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.385    
## OV    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.671    
## TA    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.425    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: CFUA_PF 
## 
##       average       sd    ratio      ava      avb cumsum     p    
## EA    0.12617  0.14403  0.87600  0.00000 30.20000  0.198 0.952    
## DC    0.10833  0.06362  1.70290 23.20000  0.00000  0.369 0.001 ***
## CAR   0.10675  0.11918  0.89570 23.20000  0.00000  0.537 0.003 ** 
## AT    0.08910  0.05995  1.48640 46.20000 48.00000  0.677 0.984    
## CT    0.06639  0.08782  0.75600 13.00000  0.00000  0.781 0.017 *  
## CLAY  0.05070  0.04318  1.17430 11.00000  0.00000  0.861 0.001 ***
## FA    0.01881  0.01239  1.51790  0.00000  4.00000  0.890 0.001 ***
## TG    0.01274  0.00514  2.48120  0.00000  2.80000  0.910 0.265    
## MC    0.01181  0.02417  0.48860  0.00000  3.00000  0.929 0.271    
## AS    0.01164  0.01666  0.69840  2.60000  0.20000  0.947 0.500    
## SOL   0.00555  0.00652  0.85010  0.00000  1.20000  0.956 0.024 *  
## CP    0.00552  0.00732  0.75500  0.00000  1.20000  0.965 0.058 .  
## MR    0.00366  0.00545  0.67110  0.80000  0.00000  0.970 0.011 *  
## OV    0.00363  0.00523  0.69390  0.00000  0.80000  0.976 0.068 .  
## PV    0.00362  0.00461  0.78510  0.00000  0.80000  0.982 0.049 *  
## PA    0.00311  0.00427  0.72750  0.00000  0.60000  0.987 0.156    
## RO    0.00204  0.00419  0.48770  0.00000  0.40000  0.990 0.251    
## FG    0.00184  0.00233  0.79270  0.40000  0.00000  0.993 0.011 *  
## TO    0.00102  0.00210  0.48770  0.00000  0.20000  0.994 0.254    
## TE    0.00096  0.00198  0.48640  0.20000  0.00000  0.996 0.454    
## TA    0.00087  0.00178  0.48830  0.00000  0.20000  0.997 0.243    
## CORD  0.00086  0.00176  0.48700  0.20000  0.00000  0.999 0.072 .  
## PS    0.00086  0.00176  0.48700  0.20000  0.00000  1.000 0.072 .  
## SC    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.655    
## PP    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.812    
## SF    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.410    
## NAB   0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.654    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: CFUA_CF 
## 
##        average        sd     ratio       ava       avb cumsum     p   
## AT     0.35220   0.09674   3.64000  46.20000 139.40000  0.541 0.004 **
## DC     0.08720   0.05065   1.72200  23.20000   0.00000  0.674 0.004 **
## CAR    0.08620   0.09502   0.90700  23.20000   0.00000  0.807 0.047 * 
## CT     0.05240   0.06846   0.76600  13.00000   0.00000  0.887 0.093 . 
## CLAY   0.04090   0.03462   1.18200  11.00000   0.00000  0.950 0.016 * 
## TG     0.01010   0.02074   0.48800   0.00000   2.40000  0.966 0.364   
## AS     0.00930   0.01395   0.66900   2.60000   0.00000  0.980 0.610   
## TE     0.00550   0.00984   0.55800   0.20000   1.20000  0.988 0.184   
## MR     0.00300   0.00439   0.67400   0.80000   0.00000  0.993 0.129   
## PA     0.00170   0.00346   0.48800   0.00000   0.40000  0.996 0.561   
## FG     0.00150   0.00187   0.79800   0.40000   0.00000  0.998 0.066 . 
## CORD   0.00070   0.00144   0.48900   0.20000   0.00000  0.999 0.372   
## PS     0.00070   0.00144   0.48900   0.20000   0.00000  1.000 0.372   
## EA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 1.000   
## SC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.648   
## CP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.650   
## PP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.808   
## PV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.640   
## SF     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.401   
## NAB    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.649   
## RO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.373   
## FA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.886   
## TO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.407   
## SOL    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.792   
## MC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.381   
## OV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.650   
## TA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.420   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: CFUA_SQAP 
## 
##        average        sd     ratio       ava       avb cumsum     p    
## EA     0.50250   0.07280   6.90300   0.00000 165.00000  0.617 0.001 ***
## DC     0.06990   0.04075   1.71600  23.20000   0.00000  0.703 0.040 *  
## CAR    0.06930   0.07604   0.91200  23.20000   0.00000  0.788 0.137    
## AT     0.06900   0.04092   1.68600  46.20000  37.80000  0.872 0.998    
## CT     0.04150   0.05387   0.77000  13.00000   0.00000  0.923 0.185    
## CLAY   0.03200   0.02784   1.15000  11.00000   0.40000  0.962 0.103    
## NAB    0.01530   0.02662   0.57300   0.00000   5.00000  0.981 0.078 .  
## AS     0.00760   0.01134   0.66700   2.60000   0.00000  0.990 0.694    
## MR     0.00240   0.00354   0.67400   0.80000   0.00000  0.993 0.291    
## SF     0.00180   0.00377   0.48900   0.00000   0.60000  0.996 0.290    
## FG     0.00120   0.00150   0.79800   0.40000   0.00000  0.997 0.123    
## TE     0.00060   0.00126   0.48900   0.20000   0.00000  0.998 0.666    
## PP     0.00060   0.00126   0.48900   0.00000   0.20000  0.999 0.746    
## CORD   0.00060   0.00117   0.48900   0.20000   0.00000  0.999 0.385    
## PS     0.00060   0.00117   0.48900   0.20000   0.00000  1.000 0.385    
## TG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.979    
## SC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.652    
## PA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.800    
## CP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.663    
## PV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.643    
## RO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.412    
## FA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.895    
## TO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.385    
## SOL    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.807    
## MC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.397    
## OV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.663    
## TA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.389    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: RT_PF 
## 
##       average       sd    ratio      ava      avb cumsum     p    
## EA    0.19784  0.15184  1.30300 14.40000 30.20000  0.379 0.702    
## AT    0.17316  0.12399  1.39660 29.20000 48.00000  0.711 0.698    
## AS    0.03998  0.05550  0.72040  5.80000  0.20000  0.788 0.016 *  
## FA    0.02819  0.01929  1.46150  0.00000  4.00000  0.842 0.001 ***
## TG    0.01883  0.00702  2.68300  0.00000  2.80000  0.878 0.008 ** 
## MC    0.01627  0.03326  0.48920  0.00000  3.00000  0.909 0.001 ***
## SOL   0.00821  0.00933  0.88040  0.00000  1.20000  0.925 0.001 ***
## CP    0.00816  0.01064  0.76660  0.00000  1.20000  0.940 0.001 ***
## SC    0.00688  0.00886  0.77690  1.00000  0.00000  0.954 0.006 ** 
## PV    0.00534  0.00689  0.77510  0.00000  0.80000  0.964 0.001 ***
## OV    0.00533  0.00753  0.70720  0.00000  0.80000  0.974 0.001 ***
## PA    0.00486  0.00668  0.72710  0.00000  0.60000  0.983 0.009 ** 
## RO    0.00317  0.00649  0.48850  0.00000  0.40000  0.990 0.001 ***
## PP    0.00266  0.00339  0.78540  0.40000  0.00000  0.995 0.022 *  
## TO    0.00158  0.00324  0.48850  0.00000  0.20000  0.998 0.001 ***
## TA    0.00125  0.00255  0.48900  0.00000  0.20000  1.000 0.001 ***
## TE    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.668    
## MR    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.645    
## CORD  0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.387    
## CLAY  0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.972    
## CT    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.633    
## CAR   0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.796    
## DC    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.940    
## PS    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.387    
## FG    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.645    
## SF    0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.384    
## NAB   0.00000  0.00000      NaN  0.00000  0.00000  1.000 0.646    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: RT_CF 
## 
##        average        sd     ratio       ava       avb cumsum     p    
## AT     0.56250   0.09033   6.22800  29.20000 139.40000  0.809 0.001 ***
## EA     0.07270   0.07243   1.00400  14.40000   0.00000  0.913 0.990    
## AS     0.02950   0.04053   0.72700   5.80000   0.00000  0.956 0.230    
## TG     0.01430   0.02933   0.48900   0.00000   2.40000  0.976 0.156    
## TE     0.00720   0.01466   0.48900   0.00000   1.20000  0.987 0.004 ** 
## SC     0.00500   0.00644   0.78400   1.00000   0.00000  0.994 0.098 .  
## PA     0.00240   0.00489   0.48900   0.00000   0.40000  0.997 0.360    
## PP     0.00200   0.00248   0.79600   0.40000   0.00000  1.000 0.120    
## MR     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.656    
## CORD   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.411    
## CLAY   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.973    
## CT     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.643    
## CAR    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.809    
## DC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.948    
## CP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.649    
## PV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.663    
## PS     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.411    
## FG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.656    
## SF     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.405    
## NAB    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.652    
## RO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.395    
## FA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.896    
## TO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.410    
## SOL    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.800    
## MC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.402    
## OV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.649    
## TA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.407    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: RT_SQAP 
## 
##        average        sd     ratio       ava       avb cumsum     p    
## EA     0.58400   0.11286   5.17400  14.40000 165.00000  0.826 0.001 ***
## AT     0.07210   0.05167   1.39500  29.20000  37.80000  0.928 0.995    
## AS     0.02210   0.03038   0.72700   5.80000   0.00000  0.960 0.382    
## NAB    0.01940   0.03374   0.57500   0.00000   5.00000  0.987 0.001 ***
## SC     0.00380   0.00485   0.78200   1.00000   0.00000  0.992 0.205    
## SF     0.00230   0.00480   0.49000   0.00000   0.60000  0.996 0.001 ***
## PP     0.00170   0.00193   0.86500   0.40000   0.20000  0.998 0.192    
## CLAY   0.00140   0.00280   0.49000   0.00000   0.40000  1.000 0.924    
## TG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.964    
## TE     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.667    
## MR     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.644    
## CORD   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.411    
## CT     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.622    
## CAR    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.823    
## DC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.945    
## PA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.779    
## CP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.664    
## PV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.643    
## PS     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.411    
## FG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.644    
## RO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.400    
## FA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.883    
## TO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.385    
## SOL    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.825    
## MC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.415    
## OV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.664    
## TA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.426    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: PF_CF 
## 
##        average        sd     ratio       ava       avb cumsum     p   
## AT     0.37860   0.08841   4.28200  48.00000 139.40000  0.665 0.002 **
## EA     0.11520   0.13151   0.87600  30.20000   0.00000  0.867 0.957   
## TG     0.01790   0.01504   1.19100   2.80000   2.40000  0.898 0.013 * 
## FA     0.01700   0.01104   1.53700   4.00000   0.00000  0.928 0.004 **
## MC     0.01080   0.02217   0.48900   3.00000   0.00000  0.947 0.385   
## TE     0.00580   0.01186   0.48600   0.00000   1.20000  0.957 0.124   
## SOL    0.00500   0.00593   0.84600   1.20000   0.00000  0.966 0.073 . 
## CP     0.00500   0.00663   0.75400   1.20000   0.00000  0.975 0.115   
## PA     0.00340   0.00399   0.86300   0.60000   0.40000  0.981 0.096 . 
## OV     0.00330   0.00475   0.69200   0.80000   0.00000  0.987 0.144   
## PV     0.00330   0.00415   0.78900   0.80000   0.00000  0.993 0.082 . 
## RO     0.00180   0.00375   0.48900   0.40000   0.00000  0.996 0.391   
## TO     0.00090   0.00187   0.48900   0.20000   0.00000  0.997 0.362   
## TA     0.00080   0.00162   0.48900   0.20000   0.00000  0.999 0.362   
## AS     0.00070   0.00148   0.48900   0.20000   0.00000  1.000 0.967   
## MR     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.661   
## SC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.637   
## CORD   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.391   
## CLAY   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.969   
## CT     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.670   
## CAR    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.801   
## DC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.947   
## PP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.796   
## PS     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.391   
## FG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.661   
## SF     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.410   
## NAB    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.658   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: PF_SQAP 
## 
##        average        sd     ratio       ava       avb cumsum     p   
## EA     0.45840   0.16544   2.77050  30.20000 165.00000  0.755 0.002 **
## AT     0.07820   0.06532   1.19760  48.00000  37.80000  0.884 0.988   
## NAB    0.01670   0.02921   0.57230   0.00000   5.00000  0.912 0.018 * 
## FA     0.01330   0.00847   1.56530   4.00000   0.00000  0.934 0.066 . 
## TG     0.00910   0.00381   2.37830   2.80000   0.00000  0.949 0.433   
## MC     0.00880   0.01792   0.48920   3.00000   0.00000  0.963 0.406   
## SOL    0.00390   0.00471   0.83550   1.20000   0.00000  0.970 0.237   
## CP     0.00390   0.00523   0.75010   1.20000   0.00000  0.976 0.189   
## OV     0.00260   0.00376   0.68800   0.80000   0.00000  0.980 0.301   
## PV     0.00260   0.00325   0.79250   0.80000   0.00000  0.985 0.163   
## PA     0.00210   0.00292   0.73080   0.60000   0.00000  0.988 0.424   
## SF     0.00200   0.00414   0.48810   0.00000   0.60000  0.991 0.074 . 
## RO     0.00140   0.00288   0.48890   0.40000   0.00000  0.994 0.400   
## CLAY   0.00120   0.00246   0.48840   0.00000   0.40000  0.996 0.914   
## TO     0.00070   0.00144   0.48890   0.20000   0.00000  0.997 0.392   
## PP     0.00070   0.00138   0.48810   0.00000   0.20000  0.998 0.678   
## TA     0.00060   0.00129   0.48910   0.20000   0.00000  0.999 0.404   
## AS     0.00060   0.00119   0.48920   0.20000   0.00000  1.000 0.971   
## TE     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.674   
## MR     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.633   
## SC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.657   
## CORD   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.414   
## CT     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.641   
## CAR    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.792   
## DC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.937   
## PS     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.414   
## FG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.633   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Contrast: CF_SQAP 
## 
##        average        sd     ratio       ava       avb cumsum     p    
## EA     0.47000   0.06595   7.12700   0.00000 165.00000  0.596 0.001 ***
## AT     0.28920   0.08862   3.26300 139.40000  37.80000  0.962 0.026 *  
## NAB    0.01430   0.02489   0.57300   0.00000   5.00000  0.980 0.185    
## TG     0.00740   0.01509   0.48900   2.40000   0.00000  0.990 0.514    
## TE     0.00370   0.00754   0.48900   1.20000   0.00000  0.994 0.421    
## SF     0.00170   0.00352   0.48900   0.00000   0.60000  0.996 0.345    
## PA     0.00120   0.00251   0.48900   0.40000   0.00000  0.998 0.699    
## CLAY   0.00100   0.00213   0.48900   0.00000   0.40000  0.999 0.935    
## PP     0.00060   0.00117   0.48900   0.00000   0.20000  1.000 0.792    
## MR     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.641    
## SC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.651    
## CORD   0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.391    
## CT     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.650    
## CAR    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.815    
## DC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.941    
## CP     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.660    
## PV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.654    
## AS     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.969    
## PS     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.391    
## FG     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.641    
## RO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.411    
## FA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.896    
## TO     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.397    
## SOL    0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.814    
## MC     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.402    
## OV     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.660    
## TA     0.00000   0.00000       NaN   0.00000   0.00000  1.000 0.404    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 999
#Correlation indices (for determining the ecological preferences of species - positive and negative)

herb_datapa <- ifelse(herb_data>0,1,0)
phi <- multipatt(herb_datapa,site, func = "r.g", control = how(nperm = 999))

summary(phi)
## 
##  Multilevel pattern analysis
##  ---------------------------
## 
##  Association function: r.g
##  Significance level (alpha): 0.05
## 
##  Total number of species: 28
##  Selected number of species: 7 
##  Number of species associated to 1 group: 6 
##  Number of species associated to 2 groups: 0 
##  Number of species associated to 3 groups: 1 
##  Number of species associated to 4 groups: 0 
## 
##  List of species associated to each combination: 
## 
##  Group CFUA  #sps.  3 
##       stat p.value    
## DC   1.000   0.001 ***
## CLAY 0.890   0.001 ***
## CAR  0.739   0.021 *  
## 
##  Group PF  #sps.  3 
##      stat p.value    
## TG  0.890   0.001 ***
## FA  0.873   0.001 ***
## SOL 0.739   0.021 *  
## 
##  Group PF+RT+SQAP  #sps.  1 
##     stat p.value   
## EA 0.784   0.002 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
round(phi$str, 3)
##          CF   CFUA     PF     RT   SQAP CF+CFUA  CF+PF  CF+RT CF+SQAP CFUA+PF
## Site    NaN    NaN    NaN    NaN    NaN     NaN    NaN    NaN     NaN     NaN
## AT      NaN    NaN    NaN    NaN    NaN     NaN    NaN    NaN     NaN     NaN
## TG   -0.047 -0.281  0.890 -0.281 -0.281  -0.268  0.688 -0.268  -0.268   0.497
## TE    0.221  0.221 -0.147 -0.147 -0.147   0.361  0.060  0.060   0.060   0.060
## EA   -0.480 -0.480  0.120  0.320  0.520  -0.784 -0.294 -0.131   0.033  -0.294
## MR   -0.147  0.590 -0.147 -0.147 -0.147   0.361 -0.241 -0.241  -0.241   0.361
## SC   -0.147 -0.147 -0.147  0.590 -0.147  -0.241 -0.241  0.361  -0.241  -0.241
## CORD -0.102  0.408 -0.102 -0.102 -0.102   0.250 -0.167 -0.167  -0.167   0.250
## CLAY -0.281  0.890 -0.281 -0.281 -0.047   0.497 -0.459 -0.459  -0.268   0.497
## CT   -0.147  0.590 -0.147 -0.147 -0.147   0.361 -0.241 -0.241  -0.241   0.361
## CAR  -0.185  0.739 -0.185 -0.185 -0.185   0.452 -0.302 -0.302  -0.302   0.452
## DC   -0.250  1.000 -0.250 -0.250 -0.250   0.612 -0.408 -0.408  -0.408   0.612
## PA    0.123 -0.185  0.431 -0.185 -0.185  -0.050  0.452 -0.050  -0.050   0.201
## CP   -0.147 -0.147  0.590 -0.147 -0.147  -0.241  0.361 -0.241  -0.241   0.361
## PP   -0.185 -0.185 -0.185  0.431  0.123  -0.302 -0.302  0.201  -0.050  -0.302
## PV   -0.147 -0.147  0.590 -0.147 -0.147  -0.241  0.361 -0.241  -0.241   0.361
## AS   -0.281  0.187 -0.047  0.421 -0.281  -0.076 -0.268  0.115  -0.459   0.115
## PS   -0.102  0.408 -0.102 -0.102 -0.102   0.250 -0.167 -0.167  -0.167   0.250
## FG   -0.147  0.590 -0.147 -0.147 -0.147   0.361 -0.241 -0.241  -0.241   0.361
## SF   -0.102 -0.102 -0.102 -0.102  0.408  -0.167 -0.167 -0.167   0.250  -0.167
## NAB  -0.147 -0.147 -0.147 -0.147  0.590  -0.241 -0.241 -0.241   0.361  -0.241
## RO   -0.102 -0.102  0.408 -0.102 -0.102  -0.167  0.250 -0.167  -0.167   0.250
## FA   -0.218 -0.218  0.873 -0.218 -0.218  -0.356  0.535 -0.356  -0.356   0.535
## TO   -0.102 -0.102  0.408 -0.102 -0.102  -0.167  0.250 -0.167  -0.167   0.250
## SOL  -0.185 -0.185  0.739 -0.185 -0.185  -0.302  0.452 -0.302  -0.302   0.452
## MC   -0.102 -0.102  0.408 -0.102 -0.102  -0.167  0.250 -0.167  -0.167   0.250
## OV   -0.147 -0.147  0.590 -0.147 -0.147  -0.241  0.361 -0.241  -0.241   0.361
## TA   -0.102 -0.102  0.408 -0.102 -0.102  -0.167  0.250 -0.167  -0.167   0.250
##      CFUA+RT CFUA+SQAP  PF+RT PF+SQAP RT+SQAP CF+CFUA+PF CF+CFUA+RT
## Site     NaN       NaN    NaN     NaN     NaN        NaN        NaN
## AT       NaN       NaN    NaN     NaN     NaN        NaN        NaN
## TG    -0.459    -0.459  0.497   0.497  -0.459      0.459     -0.497
## TE     0.060     0.060 -0.241  -0.241  -0.241      0.241      0.241
## EA    -0.131     0.033  0.360   0.523   0.686     -0.686     -0.523
## MR     0.361     0.361 -0.241  -0.241  -0.241      0.241      0.241
## SC     0.361    -0.241  0.361  -0.241   0.361     -0.361      0.241
## CORD   0.250     0.250 -0.167  -0.167  -0.167      0.167      0.167
## CLAY   0.497     0.688 -0.459  -0.268  -0.268      0.268      0.268
## CT     0.361     0.361 -0.241  -0.241  -0.241      0.241      0.241
## CAR    0.452     0.452 -0.302  -0.302  -0.302      0.302      0.302
## DC     0.612     0.612 -0.408  -0.408  -0.408      0.408      0.408
## PA    -0.302    -0.302  0.201   0.201  -0.302      0.302     -0.201
## CP    -0.241    -0.241  0.361   0.361  -0.241      0.241     -0.361
## PP     0.201    -0.050  0.201  -0.050   0.452     -0.452      0.050
## PV    -0.241    -0.241  0.361   0.361  -0.241      0.241     -0.361
## AS     0.497    -0.076  0.306  -0.268   0.115     -0.115      0.268
## PS     0.250     0.250 -0.167  -0.167  -0.167      0.167      0.167
## FG     0.361     0.361 -0.241  -0.241  -0.241      0.241      0.241
## SF    -0.167     0.250 -0.167   0.250   0.250     -0.250     -0.250
## NAB   -0.241     0.361 -0.241   0.361   0.361     -0.361     -0.361
## RO    -0.167    -0.167  0.250   0.250  -0.167      0.167     -0.250
## FA    -0.356    -0.356  0.535   0.535  -0.356      0.356     -0.535
## TO    -0.167    -0.167  0.250   0.250  -0.167      0.167     -0.250
## SOL   -0.302    -0.302  0.452   0.452  -0.302      0.302     -0.452
## MC    -0.167    -0.167  0.250   0.250  -0.167      0.167     -0.250
## OV    -0.241    -0.241  0.361   0.361  -0.241      0.241     -0.361
## TA    -0.167    -0.167  0.250   0.250  -0.167      0.167     -0.250
##      CF+CFUA+SQAP CF+PF+RT CF+PF+SQAP CF+RT+SQAP CFUA+PF+RT CFUA+PF+SQAP
## Site          NaN      NaN        NaN        NaN        NaN          NaN
## AT            NaN      NaN        NaN        NaN        NaN          NaN
## TG         -0.497    0.459      0.459     -0.497      0.268        0.268
## TE          0.241   -0.060     -0.060     -0.060     -0.060       -0.060
## EA         -0.360   -0.033      0.131      0.294     -0.033        0.131
## MR          0.241   -0.361     -0.361     -0.361      0.241        0.241
## SC         -0.361    0.241     -0.361      0.241      0.241       -0.361
## CORD        0.167   -0.250     -0.250     -0.250      0.167        0.167
## CLAY        0.459   -0.688     -0.497     -0.497      0.268        0.459
## CT          0.241   -0.361     -0.361     -0.361      0.241        0.241
## CAR         0.302   -0.452     -0.452     -0.452      0.302        0.302
## DC          0.408   -0.612     -0.612     -0.612      0.408        0.408
## PA         -0.201    0.302      0.302     -0.201      0.050        0.050
## CP         -0.361    0.241      0.241     -0.361      0.241        0.241
## PP         -0.201    0.050     -0.201      0.302      0.050       -0.201
## PV         -0.361    0.241      0.241     -0.361      0.241        0.241
## AS         -0.306    0.076     -0.497     -0.115      0.459       -0.115
## PS          0.167   -0.250     -0.250     -0.250      0.167        0.167
## FG          0.241   -0.361     -0.361     -0.361      0.241        0.241
## SF          0.167   -0.250      0.167      0.167     -0.250        0.167
## NAB         0.241   -0.361      0.241      0.241     -0.361        0.241
## RO         -0.250    0.167      0.167     -0.250      0.167        0.167
## FA         -0.535    0.356      0.356     -0.535      0.356        0.356
## TO         -0.250    0.167      0.167     -0.250      0.167        0.167
## SOL        -0.452    0.302      0.302     -0.452      0.302        0.302
## MC         -0.250    0.167      0.167     -0.250      0.167        0.167
## OV         -0.361    0.241      0.241     -0.361      0.241        0.241
## TA         -0.250    0.167      0.167     -0.250      0.167        0.167
##      CFUA+RT+SQAP PF+RT+SQAP CF+CFUA+PF+RT CF+CFUA+PF+SQAP CF+CFUA+RT+SQAP
## Site          NaN        NaN           NaN             NaN             NaN
## AT            NaN        NaN           NaN             NaN             NaN
## TG         -0.688      0.268         0.281           0.281          -0.890
## TE         -0.060     -0.361         0.147           0.147           0.147
## EA          0.294      0.784        -0.520          -0.320          -0.120
## MR          0.241     -0.361         0.147           0.147           0.147
## SC          0.241      0.241         0.147          -0.590           0.147
## CORD        0.167     -0.250         0.102           0.102           0.102
## CLAY        0.459     -0.497         0.047           0.281           0.281
## CT          0.241     -0.361         0.147           0.147           0.147
## CAR         0.302     -0.452         0.185           0.185           0.185
## DC          0.408     -0.612         0.250           0.250           0.250
## PA         -0.452      0.050         0.185           0.185          -0.431
## CP         -0.361      0.241         0.147           0.147          -0.590
## PP          0.302      0.302        -0.123          -0.431           0.185
## PV         -0.361      0.241         0.147           0.147          -0.590
## AS          0.268      0.076         0.281          -0.421           0.047
## PS          0.167     -0.250         0.102           0.102           0.102
## FG          0.241     -0.361         0.147           0.147           0.147
## SF          0.167      0.167        -0.408           0.102           0.102
## NAB         0.241      0.241        -0.590           0.147           0.147
## RO         -0.250      0.167         0.102           0.102          -0.408
## FA         -0.535      0.356         0.218           0.218          -0.873
## TO         -0.250      0.167         0.102           0.102          -0.408
## SOL        -0.452      0.302         0.185           0.185          -0.739
## MC         -0.250      0.167         0.102           0.102          -0.408
## OV         -0.361      0.241         0.147           0.147          -0.590
## TA         -0.250      0.167         0.102           0.102          -0.408
##      CF+PF+RT+SQAP CFUA+PF+RT+SQAP
## Site           NaN             NaN
## AT             NaN             NaN
## TG           0.281           0.047
## TE          -0.221          -0.221
## EA           0.480           0.480
## MR          -0.590           0.147
## SC           0.147           0.147
## CORD        -0.408           0.102
## CLAY        -0.890           0.281
## CT          -0.590           0.147
## CAR         -0.739           0.185
## DC          -1.000           0.250
## PA           0.185          -0.123
## CP           0.147           0.147
## PP           0.185           0.185
## PV           0.147           0.147
## AS          -0.187           0.281
## PS          -0.408           0.102
## FG          -0.590           0.147
## SF           0.102           0.102
## NAB          0.147           0.147
## RO           0.102           0.102
## FA           0.218           0.218
## TO           0.102           0.102
## SOL          0.185           0.185
## MC           0.102           0.102
## OV           0.147           0.147
## TA           0.102           0.102
#ISA across all sites

inv_inter <- multipatt(abund, site, duleg = TRUE, control = how(nperm=999))

summary(inv_inter)
## 
##  Multilevel pattern analysis
##  ---------------------------
## 
##  Association function: IndVal.g
##  Significance level (alpha): 0.05
## 
##  Total number of species: 27
##  Selected number of species: 8 
##  Number of species associated to 1 group: 8 
##  Number of species associated to 2 groups: 0 
##  Number of species associated to 3 groups: 0 
##  Number of species associated to 4 groups: 0 
## 
##  List of species associated to each combination: 
## 
##  Group CF  #sps.  1 
##     stat p.value    
## AT 0.681   0.001 ***
## 
##  Group CFUA  #sps.  3 
##       stat p.value    
## DC   1.000   0.001 ***
## CLAY 0.982   0.001 ***
## CAR  0.775   0.027 *  
## 
##  Group PF  #sps.  3 
##      stat p.value   
## FA  0.894   0.004 **
## SOL 0.775   0.022 * 
## TG  0.734   0.015 * 
## 
##  Group SQAP  #sps.  1 
##     stat p.value    
## EA 0.887   0.001 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Understory / Site RDA - Indicator Species

library(ade4)
library(vegan)
library(MASS)
library(ellipse)
## 
## Attaching package: 'ellipse'
## The following object is masked from 'package:car':
## 
##     ellipse
## The following object is masked from 'package:graphics':
## 
##     pairs
library(FactoMineR)
library(factoextra)
library(ggrepel)

herb_data <- read.csv("Data/herb_data.csv")
NestedMatrix_herb <- read.csv("Data/NestedMatrix_herbCSV.csv")

#Omit Site names (not numeric)
herb_data2 <- herb_data[, -1]
herb.hel <- decostand(herb_data2, "hellinger")
original_data <- NestedMatrix_herb[, -1]
zdata <- as.data.frame(scale(original_data))

#RDA of species with parsimonius environmnental variables across sites

rownames(herb.hel)<- NestedMatrix_herb$Site

herb.rda <- rda(herb.hel ~ WeeklyTempROC + C + PPFD4 + Slope, data = zdata)

sites_to_label <- c("CFUA", "RT", "PF", "CF", "SQAP")

plot(herb.rda, scaling=2, display = c("sp", "lc", "cn"), main="RDA Triplot - Understory Species Associations - scaling=2", xlab="RDA1", ylab="RDA2", xlim=c(-1, 1), ylim=c(-1,1))

for (site in sites_to_label) {
  site_coords <- scores(herb.rda, display = "sites")[site, ]
  text(site_coords["RDA1"], site_coords["RDA2"], labels = site, cex = 0.7, col = "darkgreen")
}

summary(herb.rda)
## 
## Call:
## rda(formula = herb.hel ~ WeeklyTempROC + C + PPFD4 + Slope, data = zdata) 
## 
## Partitioning of variance:
##               Inertia Proportion
## Total          0.3872     1.0000
## Constrained    0.2412     0.6229
## Unconstrained  0.1460     0.3771
## 
## Eigenvalues, and their contribution to the variance 
## 
## Importance of components:
##                         RDA1   RDA2    RDA3     RDA4     PC1     PC2     PC3
## Eigenvalue            0.1502 0.0679 0.01547 0.007585 0.06067 0.03652 0.01346
## Proportion Explained  0.3879 0.1754 0.03997 0.019590 0.15671 0.09431 0.03476
## Cumulative Proportion 0.3879 0.5633 0.60328 0.622873 0.77958 0.87389 0.90865
##                            PC4      PC5      PC6      PC7      PC8      PC9
## Eigenvalue            0.006954 0.006214 0.005933 0.003687 0.003496 0.002831
## Proportion Explained  0.017959 0.016050 0.015324 0.009522 0.009029 0.007311
## Cumulative Proportion 0.926607 0.942657 0.957981 0.967504 0.976533 0.983843
##                           PC10     PC11      PC12      PC13      PC14      PC15
## Eigenvalue            0.002008 0.001840 0.0008418 0.0005847 0.0004341 0.0003594
## Proportion Explained  0.005187 0.004752 0.0021741 0.0015102 0.0011211 0.0009283
## Cumulative Proportion 0.989030 0.993783 0.9959568 0.9974671 0.9985882 0.9995165
##                            PC16         PC17
## Eigenvalue            0.0001866 0.0000005679
## Proportion Explained  0.0004821 0.0000014667
## Cumulative Proportion 0.9999985 1.0000000000
## 
## Accumulated constrained eigenvalues
## Importance of components:
##                         RDA1   RDA2    RDA3     RDA4
## Eigenvalue            0.1502 0.0679 0.01547 0.007585
## Proportion Explained  0.6228 0.2816 0.06416 0.031451
## Cumulative Proportion 0.6228 0.9044 0.96855 1.000000
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  1.74595 
## 
## 
## Species scores
## 
##           RDA1      RDA2       RDA3       RDA4        PC1         PC2
## AT    0.341807 -0.415841 -0.0579900  0.0014156 -0.3507476  0.00996439
## TG    0.014233 -0.103672  0.1496015  0.0444632  0.0072720  0.00237056
## TE    0.035345 -0.014536 -0.0041504 -0.0333629  0.0014647  0.03192808
## EA   -0.934051  0.107037 -0.0156211  0.0165553  0.5838010  0.04816161
## MR    0.033630  0.044157  0.0019866  0.0024616 -0.0008412 -0.01730928
## SC   -0.012720 -0.021349 -0.0750837  0.0592784  0.0271990  0.00660200
## CORD  0.011630  0.015270  0.0006870  0.0008513 -0.0007714  0.01634222
## CLAY  0.169242  0.251640  0.0111001  0.0039056  0.0090572 -0.08968973
## CT    0.153046  0.200950  0.0090406  0.0112024  0.0330382 -0.32090694
## CAR   0.219979  0.288834  0.0129945  0.0161017 -0.0319487  0.36238100
## DC    0.282856  0.371392  0.0167087  0.0207040  0.0092788 -0.13454106
## PA    0.007098 -0.037992  0.0496431  0.0113628 -0.0405818 -0.00351856
## CP   -0.007414 -0.024943  0.0658184  0.0390903  0.0137400 -0.00064269
## PP   -0.020707 -0.007409 -0.0448188  0.0279783  0.0075012  0.00950674
## PV   -0.005974 -0.020100  0.0530388  0.0315004  0.0177064  0.00332805
## AS    0.022578  0.013288 -0.1845020  0.1750183 -0.0129936  0.14839641
## PS    0.011630  0.015270  0.0006870  0.0008513 -0.0007714  0.01634222
## FG    0.024698  0.032428  0.0014589  0.0018078  0.0011895 -0.02079067
## SF   -0.022694  0.009275  0.0001237 -0.0129251  0.0033747  0.00047703
## NAB  -0.084073  0.034362  0.0004583 -0.0478833 -0.0212397 -0.00060666
## RO   -0.003408 -0.011465  0.0302543  0.0179683 -0.0307878 -0.00369888
## FA   -0.019291 -0.064903  0.1712617  0.1017143  0.0089597  0.00098887
## TO   -0.002410 -0.008107  0.0213930  0.0127055 -0.0075892 -0.00060941
## SOL  -0.008892 -0.029914  0.0789363  0.0468812 -0.0020313 -0.00217659
## MC   -0.007029 -0.023647  0.0623981  0.0370590  0.0778839  0.01147447
## OV   -0.005879 -0.019779  0.0521924  0.0309977  0.0167919  0.00003124
## TA   -0.002003 -0.006739  0.0177821  0.0105610  0.0222639  0.00152810
## 
## 
## Site scores (weighted sums of species scores)
## 
##          RDA1      RDA2        RDA3    RDA4      PC1       PC2
## CFUA  0.42374  0.764773  0.23401513 -0.1835  0.13400 -0.863664
## 2     0.45343  0.462087  0.09984385 -0.1976 -0.09605  0.164653
## 3     0.38718  0.396603 -0.12906176  0.1695 -0.06959  1.007515
## 4     0.40801  0.532520  0.15390291 -0.2163  0.05966 -0.902138
## 5     0.43994  0.617478 -0.23392347  0.5825 -0.02802  0.593634
## RT   -0.43588  0.045139 -0.07682725 -0.2775  0.57699 -0.066993
## 8     0.09298 -0.174977 -1.05353899  1.4325 -0.28293  0.160132
## 9     0.30620 -0.420525 -0.16233837 -0.4887 -0.68430 -0.186588
## 10   -0.06156 -0.208329 -0.73606527  0.7416 -0.05721  0.040252
## 11   -0.35114  0.004433 -0.62388523  0.6864  0.44745  0.053196
## PF    0.02896 -0.336638  0.49427708  0.2467 -0.20168 -0.016195
## 13    0.27020 -0.429562  0.76442791  0.4512 -0.57854 -0.069507
## 14    0.29647 -0.445433  0.25285197 -0.2135 -0.64119 -0.067699
## 15   -0.44268  0.061916  0.59433298  0.7057  0.70961  0.104545
## 16   -0.47314  0.072469  0.73668528  0.4980  0.71180  0.048855
## CF    0.30620 -0.420525 -0.16233837 -0.4887 -0.01203 -0.004618
## 18    0.29175 -0.428482  0.31907006 -0.3540  0.04813  0.018471
## 19    0.30620 -0.420525 -0.16233837 -0.4887 -0.01203 -0.004618
## 20    0.30620 -0.420525 -0.16233837 -0.4887 -0.01203 -0.004618
## 21    0.30620 -0.420525 -0.16233837 -0.4887 -0.01203 -0.004618
## SQAP -0.65036  0.318757  0.04871425 -0.3424  0.14220  0.010923
## 23   -0.45930  0.109370 -0.04353894 -0.5452 -0.25378 -0.009865
## 24   -0.49389  0.169985 -0.03259910 -0.2580 -0.11982 -0.025420
## 25   -0.61320  0.266443  0.00009917 -0.2412  0.08504  0.012021
## 26   -0.64254  0.304073  0.04291126 -0.2416  0.14636  0.012341
## 
## 
## Site constraints (linear combinations of constraining variables)
## 
##          RDA1    RDA2      RDA3     RDA4      PC1       PC2
## CFUA  0.42246  0.5547  0.024955  0.03092  0.13400 -0.863664
## 2     0.42246  0.5547  0.024955  0.03092 -0.09605  0.164653
## 3     0.42246  0.5547  0.024955  0.03092 -0.06959  1.007515
## 4     0.42246  0.5547  0.024955  0.03092  0.05966 -0.902138
## 5     0.42246  0.5547  0.024955  0.03092 -0.02802  0.593634
## RT   -0.08988 -0.1509 -0.530531  0.41885  0.57699 -0.066993
## 8    -0.08988 -0.1509 -0.530531  0.41885 -0.28293  0.160132
## 9    -0.08988 -0.1509 -0.530531  0.41885 -0.68430 -0.186588
## 10   -0.08988 -0.1509 -0.530531  0.41885 -0.05721  0.040252
## 11   -0.08988 -0.1509 -0.530531  0.41885  0.44745  0.053196
## PF   -0.06404 -0.2154  0.568515  0.33765 -0.20168 -0.016195
## 13   -0.06404 -0.2154  0.568515  0.33765 -0.57854 -0.069507
## 14   -0.06404 -0.2154  0.568515  0.33765 -0.64119 -0.067699
## 15   -0.06404 -0.2154  0.568515  0.33765  0.70961  0.104545
## 16   -0.06404 -0.2154  0.568515  0.33765  0.71180  0.048855
## CF    0.30331 -0.4221 -0.066057 -0.46173 -0.01203 -0.004618
## 18    0.30331 -0.4221 -0.066057 -0.46173  0.04813  0.018471
## 19    0.30331 -0.4221 -0.066057 -0.46173 -0.01203 -0.004618
## 20    0.30331 -0.4221 -0.066057 -0.46173 -0.01203 -0.004618
## 21    0.30331 -0.4221 -0.066057 -0.46173 -0.01203 -0.004618
## SQAP -0.57186  0.2337  0.003117 -0.32570  0.14220  0.010923
## 23   -0.57186  0.2337  0.003117 -0.32570 -0.25378 -0.009865
## 24   -0.57186  0.2337  0.003117 -0.32570 -0.11982 -0.025420
## 25   -0.57186  0.2337  0.003117 -0.32570  0.08504  0.012021
## 26   -0.57186  0.2337  0.003117 -0.32570  0.14636  0.012341
## 
## 
## Biplot scores for constraining variables
## 
##                  RDA1    RDA2    RDA3    RDA4 PC1 PC2
## WeeklyTempROC -0.3343 -0.3902  0.7642  0.3899   0   0
## C             -0.4083 -0.4645 -0.6549 -0.4343   0   0
## PPFD4         -0.6347 -0.3473  0.4912 -0.4849   0   0
## Slope         -0.3930 -0.3069 -0.1016  0.8608   0   0