library(ggplot2)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(meta)
## Loading 'meta' package (version 6.5-0).
## Type 'help(meta)' for a brief overview.
## Readers of 'Meta-Analysis with R (Use R!)' should install
## older version of 'meta' package: https://tinyurl.com/dt4y5drs
library(PRISMAstatement)
library(skimr)
library(MASS)
##
## Attaching package: 'MASS'
##
## The following object is masked from 'package:dplyr':
##
## select
library(ggpubr)
library(patchwork)
##
## Attaching package: 'patchwork'
##
## The following object is masked from 'package:MASS':
##
## area
### Load and clean up dirty data
#photo <- read.csv("observations.csv")
#photo <- photo %>%
# filter(common_name != "Human")
#photo <- photo %>%
# filter(common_name != "Human-Camera Trapper")
#photo <- photo %>%
# filter(common_name != "Domestic Dog")
#photo <- photo %>%
# filter(common_name != "Vehicle")
#photo <- photo %>%
# dplyr::filter(common_name != "Insect")
#photo <- photo %>%
# dplyr::filter(common_name != "Animal")
#photo <- photo %>%
# dplyr::filter(common_name != "Bird")
#photo <- photo %>%
# filter(common_name != "No CV Result")
#count.hit <- photo %>%
# count(animal.hit) %>%
# na.omit()
#summary(count.hit)
### 0.489% capture rate
### Total Observations is species list!
#Total_Observations <- photo %>% group_by(common_name) %>% summarise(total = sum(animal.hit)) %>% filter(common_name != "Blank") %>% filter(common_name != "No CV Result") %>% filter(common_name != "Mammal")
#animals_by_factor <- photo %>% group_by(factor,common_name, scientific_name) %>% summarise(captures = sum(animal.hit))
#animals_by_factor <- animals_by_factor %>% filter(common_name != "Blank") %>% filter(common_name != "No CV Result")
#factor_obvs <- merge(animals_by_factor, Total_Observations, all = TRUE)
#factor_obvs$percent_presence <- factor_obvs$captures/factor_obvs$total
### Rought version of percent proportion figure.
#write.csv(factor_obvs, file = "scientific.csv")
scientific <- read.csv("scientific.csv")
#plot1 <- ggplot(scientific, aes(scientific_name, percent_presence, fill = factor)) + geom_bar(stat = "identity") + coord_flip() + theme_classic() + scale_x_discrete(limits=rev) + xlab("Species") + ylab("Percent Proportion") + labs(fill = "factor")
#plot1 + scale_fill_manual(values = c("#009900", "#0066cc", "#8B0000")) + scale_x_discrete(limits = rev(levels(factor_obvs$scientific_name)))
### This figure works well!
library(dplyr)
library(ggplot2)
# Calculate the total counts of each species
scientific <- scientific %>%
group_by(scientific_name, factor) %>%
summarize(total_counts = sum(percent_presence))
## `summarise()` has grouped output by 'scientific_name'. You can override using
## the `.groups` argument.
# Create a custom order based on percent presence
custom_order <- scientific %>%
arrange(factor, -total_counts) %>%
pull(scientific_name)
# Create a numeric variable to represent the custom order
scientific <- scientific %>%
mutate(order_var = match(scientific_name, custom_order))
# Create the bar plot with custom x-axis order
plot1 <- ggplot(scientific, aes(factor(order_var), total_counts, fill = factor)) +
geom_bar(stat = "identity") +
coord_flip() +
theme_classic() +
xlab("Species") +
ylab("Relative Proportion") +
labs(fill = "Microsite") +
scale_fill_brewer(palette = "Paired") +
scale_x_continuous(breaks = 1:length(custom_order), labels = custom_order) + scale_x_discrete(labels = custom_order) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10))
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
plot1
### Determine animal abundance at each site (This will also help with PCOA)
#photo_final <- photo %>% filter(common_name != "Blank") %>% filter(common_name != "No CV Result") %>% filter(common_name != "Mammal")
#write.csv(photo_final, file = "observations.csv") ### Use this as final data
photo_final <- read.csv("observations.csv")
Total_Observations_factors <- photo_final %>% group_by(site_code, factor, microsite_number) %>% summarise(total = sum(animal_hit))
## `summarise()` has grouped output by 'site_code', 'factor'. You can override
## using the `.groups` argument.
#animals_density <- photo %>% group_by(site_code,factor, common_name, microsite_number) %>% summarise(captures = sum(animal.hit))
#animals_density <- animals_density %>% filter(common_name != "Blank")
library(dplyr)
### Geolocated Shrub Density setup and cleanup.
Cuyama_shrubs <- read.csv("Cuyama.csv")
Cuyama_shrubs <- Cuyama_shrubs %>% filter(site_code != "Cuyama_2") %>% filter(site_code != "Cuyama_4") %>% filter(site_code != "Cuyama_5") %>% filter(site_code != "Cuyama_6")
Carrizo_shrubs <- read.csv("Carrizo.csv")
Carrizo_shrubs <- Carrizo_shrubs %>% filter(site_code != "Carrizo_1")%>% filter(site_code != "Carrizo_2")%>% filter(site_code != "Carrizo_3")%>% filter(site_code != "Carrizo_4")%>% filter(site_code != "Carrizo_5")%>% filter(site_code != "Carrizo_6")%>% filter(site_code != "Carrizo_7")
shrubs <- rbind(Carrizo_shrubs, Cuyama_shrubs)
### Combine site level data with geolocated data to determine the shrub density around each mimic, shrub and open area. Use Lizard code!!!
library(tidyverse)
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(RColorBrewer)
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
#set key attributes####
x = 4326 #crs for first spatial df
y = 4326 #crs for second spatial df
z = 20 #set buffer is using a join to point data SET FOR 20M
shrubs <- shrubs %>%
st_as_sf(coords=c("long","lat"), crs = x, remove=FALSE) %>%
st_transform(32610) #crs = 32610 is UTM and will return distances in meters
site <- read_csv("Chpt5_Site_Data.csv") %>%
st_as_sf(coords=c("long","lat"), crs = y, remove=FALSE) %>%
st_transform(32610) #crs = 32610 is UTM and will return distances in meters
## Rows: 58 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): site_code, factor, functioned
## dbl (5): rep, site number, lat, long, pendant_ID
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
buffer <- st_buffer(site, z) #decide on spatial scale
joined.xy <- st_intersection(buffer, shrubs)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
joined.xy <- joined.xy %>%
group_by(rep) %>%
summarize(n_shrubs = n()) %>%
st_drop_geometry
tidy_all <- left_join(site, joined.xy, by = "rep") %>%
dplyr::mutate(n_shrubs = replace_na(n_shrubs, 0))
max(tidy_all$n_shrubs) #checks ecological viability
## [1] 30
min(tidy_all$n_shrubs) #checks ecological viability
## [1] 0
sum(tidy_all$n_shrubs) #checks positive co-occurrences
## [1] 611
nrow(buffer) - nrow(tidy_all) #ensure that tidy dataframe comprised all buffers
## [1] 0
#write data AS tidy_20m
#write.csv(tidy_all, file = "tidy_20m.csv")
library(dplyr)
tidy_20m <- read.csv("tidy_20m.csv")%>%
distinct(rep, .keep_all = TRUE)
###write.csv(tidy_20m, file = "tidy_20m.csv")
###THIS SHOULD BE ALL CLEANED UP AND NOW WORK!!!
### PCOA
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.6-4
library(ape)
##
## Attaching package: 'ape'
## The following object is masked from 'package:ggpubr':
##
## rotate
## The following object is masked from 'package:dplyr':
##
## where
animals_density_final <- photo_final %>% group_by(site_code,factor,microsite_number, common_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'site_code', 'factor', 'microsite_number'.
## You can override using the `.groups` argument.
pca_data_final <- animals_density_final ### Created new df for pca data
pca_data_final <- pca_data_final %>%
spread(common_name, captures) %>%
ungroup() %>%
dplyr::select(-site_code, -factor, -microsite_number) %>%
replace(is.na(.),0)
dim(pca_data_final)
## [1] 53 21
env_final <- read.csv("environment.csv") ### Drop Tecopa open 1, Tecopa open 4, since they have no animal observations.
dim(env_final)
## [1] 53 5
model010 <- adonis(pca_data_final ~ factor+shrub_density, data = env_final)
## 'adonis' will be deprecated: use 'adonis2' instead
model010
## $aov.tab
## Permutation: free
## Number of permutations: 999
##
## Terms added sequentially (first to last)
##
## Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
## factor 2 0.7190 0.35951 1.1694 0.04212 0.294
## shrub_density 1 1.2885 1.28851 4.1913 0.07548 0.001 ***
## Residuals 49 15.0636 0.30742 0.88240
## Total 52 17.0712 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## $call
## adonis(formula = pca_data_final ~ factor + shrub_density, data = env_final)
##
## $coefficients
## Bewick's Wren Black-tailed Jackrabbit California Ground Squirrel
## (Intercept) 0.0076319553 1.57842126 -0.011387527
## factor1 -0.0128239472 -0.17166774 -0.002104166
## factor2 0.0270797066 -0.45504757 -0.053282362
## shrub_density 0.0005352569 -0.03677871 0.006545535
## California Pocket Mouse California Quail Cassin's Kingbird
## (Intercept) -0.009216160 0.201627947 0.009885252
## factor1 0.011361669 0.330209739 -0.025167341
## factor2 0.040473648 -0.169199459 0.054549073
## shrub_density 0.004933453 -0.003282236 0.001575473
## Common Poorwill Common Raven Coyote Desert Cottontail
## (Intercept) 0.005102551 1.53102403 0.83092590 -0.16570596
## factor1 0.034366522 0.01478412 0.02186533 0.11723801
## factor2 -0.015828897 -0.05508749 -0.01344370 -0.02201191
## shrub_density 0.001085663 -0.05626888 -0.02606095 0.05138845
## Giant Kangaroo Rat Heermann's Kangaroo Rat Horned Lark
## (Intercept) 0.2236461935 42.922232 0.34904693
## factor1 -0.0157724889 5.006682 -0.15420995
## factor2 0.1043736211 7.953404 0.31847775
## shrub_density -0.0008117221 -1.704012 -0.01493165
## Kit Fox Loggerhead Shrike Mourning Dove
## (Intercept) 1.30200080 1.63788020 0.084954106
## factor1 0.41290996 0.88229861 0.131699453
## factor2 -0.20660716 0.09195141 -0.067991512
## shrub_density -0.05823822 -0.05362668 -0.001716862
## Nelson's Antelope Squirrel Red-tailed Hawk Salinas Pocket Mouse
## (Intercept) 5.5106881 0.0444105000 0.03084767
## factor1 2.3369656 -0.0403940534 0.04260460
## factor2 -0.1196759 0.0796804786 0.02211196
## shrub_density -0.1853251 -0.0004140667 0.00273688
## Say's Phoebe Song Sparrow
## (Intercept) 0.0185491971 0.101486306
## factor1 0.0331651398 -0.084955200
## factor2 -0.0168030478 -0.084648437
## shrub_density -0.0001767358 -0.001704238
##
## $coef.sites
## 1 2 3 4 5
## (Intercept) 0.936275457 0.926204692 0.57949457 0.55262669 0.610222530
## factor1 -0.050205797 0.016998412 0.03941641 0.04437136 0.026543387
## factor2 -0.017674861 0.075343266 -0.05155083 -0.01563137 -0.065002603
## shrub_density -0.008553169 -0.001238154 0.01022613 0.00940238 0.006715876
## 6 7 8 9 10
## (Intercept) 0.777242019 0.852058173 0.58608635 0.9257864943 0.95563208
## factor1 -0.041612390 -0.004972056 -0.01060948 0.0174686958 0.03692741
## factor2 0.002386197 -0.001167039 -0.01348249 -0.0591197112 0.05193310
## shrub_density -0.003860334 -0.006594950 0.01383112 0.0005773103 -0.00562015
## 11 12 13 14
## (Intercept) 0.895770431 0.9445820911 0.910485150 0.9445820911
## factor1 0.001734654 0.0239997735 0.046846314 0.0239997735
## factor2 0.032341752 -0.0713384528 0.089246857 -0.0713384528
## shrub_density -0.009063453 -0.0004010324 -0.001097481 -0.0004010324
## 15 16 17 18 19
## (Intercept) 0.7240134806 0.988997878 0.989568529 0.628236663 0.734035940
## factor1 -0.0421516204 0.007832231 0.001355325 0.039426078 -0.020556889
## factor2 0.0014222960 -0.008458344 0.037364794 -0.053097717 0.009279855
## shrub_density 0.0002140372 -0.006003473 -0.008149366 0.005630839 -0.003154350
## 20 21 22 23 24
## (Intercept) 0.849116203 0.987294774 0.854749137 0.923738530 0.887724497
## factor1 -0.021309556 -0.015100373 -0.044242542 -0.040625010 0.042308680
## factor2 0.003258647 -0.001243885 -0.015412171 -0.002078609 0.100568762
## shrub_density -0.009217237 -0.007575176 -0.007148741 -0.008938216 -0.002356877
## 25 26 27 28 29
## (Intercept) 0.936275457 0.731556747 0.647618294 0.6926429273 0.54947382
## factor1 -0.050205797 0.011891249 -0.002206746 0.0007272092 0.04568939
## factor2 -0.017674861 0.054178234 -0.055715480 -0.0143286949 -0.04795711
## shrub_density -0.008553169 -0.003562781 0.004547975 0.0081519152 0.01072234
## 30 31 32 33 34
## (Intercept) 0.766943208 0.754156996 0.63491138 0.655337994 0.622870994
## factor1 -0.034480106 -0.026628674 -0.03578040 0.001598991 0.001360762
## factor2 -0.024230700 -0.033313028 -0.01861093 -0.060408324 -0.045068645
## shrub_density 0.008905597 0.009354036 0.01356842 0.004606980 0.005245220
## 35 36 37 38 39
## (Intercept) 0.579718734 0.60371032 0.54552608 0.557621277 0.565385089
## factor1 0.008214607 -0.02984032 0.04271827 0.046084510 0.040188676
## factor2 -0.020719713 -0.01900946 -0.05037329 -0.003355421 -0.009586730
## shrub_density 0.013578295 0.01426815 0.01166769 0.010428737 0.008461571
## 40 41 42 43 44
## (Intercept) 0.53778473 0.57279308 0.51257919 0.739734525 0.686837166
## factor1 0.03840331 0.03026120 0.05695778 -0.023949999 -0.016346030
## factor2 -0.01593148 -0.04312069 -0.02323254 -0.028733281 0.014287801
## shrub_density 0.01216791 0.01243267 0.01144910 0.009710738 0.003589044
## 45 46 47 48 49
## (Intercept) 0.793263881 0.860713167 0.536006661 0.53760256 0.65048975
## factor1 -0.048109313 -0.051690340 0.046633363 0.04631280 -0.02889655
## factor2 -0.026089161 -0.029771764 -0.036217614 -0.05777980 -0.02215887
## shrub_density -0.003114114 -0.006472206 0.009675989 0.01095332 0.01318175
## 50 51 52 53
## (Intercept) 0.650342540 0.58461555 0.62135819 0.54052840
## factor1 0.001653830 -0.01223346 -0.03298820 0.04584001
## factor2 0.019105412 -0.01574979 -0.01459240 -0.06756914
## shrub_density 0.005595415 0.01401674 0.01373927 0.01026113
##
## $f.perms
## [,1] [,2]
## [1,] 0.4599572 0.83577460
## [2,] 1.0426373 0.50260218
## [3,] 0.7034085 1.23925466
## [4,] 0.9732075 0.90349360
## [5,] 1.0744267 0.81035739
## [6,] 0.6178820 0.74934432
## [7,] 1.1192944 0.42579644
## [8,] 0.8535412 0.81257054
## [9,] 0.8490262 0.32708665
## [10,] 1.5232653 0.76301538
## [11,] 0.1897884 0.59132909
## [12,] 0.8523169 0.68573760
## [13,] 0.8627980 0.44380427
## [14,] 0.9774391 2.01167680
## [15,] 0.8830923 1.25428176
## [16,] 1.9363160 2.38845945
## [17,] 0.5682782 0.52568228
## [18,] 0.7076253 1.00260361
## [19,] 0.9601084 0.79152162
## [20,] 0.8232959 0.85045762
## [21,] 0.8852806 2.60325139
## [22,] 0.9956029 0.86179860
## [23,] 0.5700538 0.76355641
## [24,] 1.0609380 0.90454397
## [25,] 1.1497474 0.59293597
## [26,] 0.8971832 0.84859579
## [27,] 0.7369310 1.69376172
## [28,] 0.4625576 0.52977667
## [29,] 1.0252487 0.94679798
## [30,] 1.2761952 0.73483392
## [31,] 0.8824368 1.32167826
## [32,] 1.2544076 0.51593569
## [33,] 1.7296003 0.60301961
## [34,] 1.1356161 2.01154363
## [35,] 1.1044871 2.28475385
## [36,] 0.8098081 1.26715590
## [37,] 0.9338974 1.00848798
## [38,] 0.5620298 1.26477098
## [39,] 0.9327427 1.05740008
## [40,] 0.8104762 0.94348713
## [41,] 0.7200692 0.39736867
## [42,] 0.4856760 0.55342264
## [43,] 0.7975690 0.45297560
## [44,] 0.9354496 0.73740379
## [45,] 1.3561780 0.78019712
## [46,] 1.2410658 1.26482858
## [47,] 1.2163905 3.22989729
## [48,] 1.4362395 0.94438373
## [49,] 1.9562861 0.91148162
## [50,] 0.7452854 1.38839844
## [51,] 0.5900373 2.75999031
## [52,] 1.1248385 0.95444213
## [53,] 1.1930309 1.08957142
## [54,] 1.3714639 1.32731349
## [55,] 0.8049374 0.78399552
## [56,] 0.6057794 0.99907830
## [57,] 1.0839338 1.23387689
## [58,] 0.9855680 1.08813807
## [59,] 0.5996461 0.98929989
## [60,] 1.3597111 1.27342958
## [61,] 0.6600669 1.01348268
## [62,] 0.7770954 2.05820452
## [63,] 0.6879214 0.64634738
## [64,] 1.3822713 0.58966181
## [65,] 0.5537619 0.77430367
## [66,] 0.5289832 1.15160079
## [67,] 0.7268667 2.09181679
## [68,] 0.7893873 1.40791451
## [69,] 1.1521229 0.70369329
## [70,] 0.6427849 1.46974356
## [71,] 1.5647635 0.40380841
## [72,] 0.8445927 2.26938935
## [73,] 1.2808926 0.43145673
## [74,] 1.3916093 0.84989308
## [75,] 1.3671233 1.52268431
## [76,] 0.5546176 0.74488611
## [77,] 0.8052804 0.44288752
## [78,] 0.7360553 0.74136801
## [79,] 0.9959874 0.62172536
## [80,] 0.8053353 0.28883473
## [81,] 0.8656459 0.67144436
## [82,] 1.3724689 0.24956769
## [83,] 1.3117152 1.66752117
## [84,] 0.9354733 1.46798531
## [85,] 1.0197722 1.74907073
## [86,] 0.7008857 0.45577260
## [87,] 1.9856993 1.21809666
## [88,] 0.6886301 1.49626287
## [89,] 1.1392427 0.57323213
## [90,] 1.0017322 0.40427086
## [91,] 0.7890888 0.74338727
## [92,] 0.8284465 1.17794793
## [93,] 0.8451960 0.63826764
## [94,] 1.0756299 1.66882409
## [95,] 1.2618578 1.07849012
## [96,] 0.6779259 1.28792570
## [97,] 0.9787246 1.98480184
## [98,] 0.7702501 1.18225141
## [99,] 0.9089062 1.27380754
## [100,] 0.9026844 0.89566471
## [101,] 0.7557570 0.61819842
## [102,] 0.8900891 0.89995854
## [103,] 1.8239635 0.24700190
## [104,] 1.1504143 1.67426838
## [105,] 0.8161170 1.46591168
## [106,] 0.4092939 0.87994409
## [107,] 0.6616104 0.51970298
## [108,] 0.8294680 0.71552527
## [109,] 1.2568653 1.07604437
## [110,] 0.9343306 1.65798650
## [111,] 0.5595005 2.01297985
## [112,] 0.7992344 0.27633843
## [113,] 1.2852678 0.94597383
## [114,] 1.0933206 1.64008119
## [115,] 0.8115787 1.85038636
## [116,] 0.6870516 1.24507577
## [117,] 1.6266079 1.16072986
## [118,] 0.6695099 0.99724531
## [119,] 1.5716739 2.06998069
## [120,] 0.5618964 1.26760238
## [121,] 1.2609441 1.76125027
## [122,] 2.3583426 0.42918201
## [123,] 0.7785811 0.91202947
## [124,] 0.8273639 0.34288430
## [125,] 0.4294628 0.62012345
## [126,] 0.8896084 0.52405824
## [127,] 0.6866725 0.71082001
## [128,] 0.8373530 1.51575276
## [129,] 1.4013307 1.15880270
## [130,] 1.2071304 1.23987723
## [131,] 1.4395104 0.41414906
## [132,] 1.0705153 1.62348466
## [133,] 0.2974585 1.28395394
## [134,] 1.6956815 1.46879653
## [135,] 0.8026053 2.21687803
## [136,] 0.6391281 1.34305702
## [137,] 0.8471105 0.79191853
## [138,] 0.4042362 1.23533713
## [139,] 1.1554654 1.02727063
## [140,] 1.1213135 1.63038351
## [141,] 0.8683775 0.80243885
## [142,] 0.6838353 2.38109766
## [143,] 1.6649706 1.19672960
## [144,] 0.8677079 0.80293590
## [145,] 1.8848155 1.72594690
## [146,] 1.1303223 1.40596611
## [147,] 0.8834158 1.89168216
## [148,] 1.3630623 1.54788346
## [149,] 1.4889734 1.73870678
## [150,] 1.4288653 0.46873238
## [151,] 0.8146585 1.59916170
## [152,] 1.1493537 0.52828824
## [153,] 0.6132353 1.02205253
## [154,] 1.0782394 0.70131669
## [155,] 1.2766102 0.48526665
## [156,] 1.1414232 2.12821670
## [157,] 1.1360666 1.48980028
## [158,] 0.9153304 0.37129558
## [159,] 0.6450904 1.70048322
## [160,] 1.4240051 0.92431515
## [161,] 1.0517462 0.51019757
## [162,] 0.8739827 3.41926564
## [163,] 0.7551974 1.82582816
## [164,] 1.2835878 0.86425028
## [165,] 1.1184198 1.44862828
## [166,] 0.5900899 2.31983579
## [167,] 1.1938067 1.35395511
## [168,] 1.1242882 1.12253623
## [169,] 1.5792740 1.44728914
## [170,] 0.8460862 1.23942934
## [171,] 1.0512533 0.71505829
## [172,] 1.3573211 0.92947826
## [173,] 1.0931692 0.76256894
## [174,] 0.6092751 0.57218316
## [175,] 0.5101799 0.47861940
## [176,] 1.8718841 1.06266070
## [177,] 0.5179361 0.92296348
## [178,] 1.1927200 0.83214441
## [179,] 1.0152133 1.02799880
## [180,] 1.3114024 1.20743833
## [181,] 0.9778099 0.85028550
## [182,] 1.8090544 0.58661346
## [183,] 0.9052078 1.20252256
## [184,] 0.5842099 1.41514061
## [185,] 0.8227753 1.14049646
## [186,] 0.9394447 0.91904003
## [187,] 1.3173163 0.38655292
## [188,] 1.0624500 1.27435486
## [189,] 0.8938294 0.65851059
## [190,] 0.9606644 1.00826976
## [191,] 0.8032187 0.55990488
## [192,] 0.7393309 0.82284766
## [193,] 0.8882897 0.97887212
## [194,] 0.6575407 1.32676517
## [195,] 1.1732416 1.56569254
## [196,] 0.7969695 1.67134396
## [197,] 1.1572445 1.06678467
## [198,] 0.6616483 1.18706107
## [199,] 2.3984901 0.95481733
## [200,] 0.6253683 1.19531161
## [201,] 1.0566598 1.29996521
## [202,] 0.6297481 1.44878014
## [203,] 0.8558501 1.62024633
## [204,] 0.8568445 0.71380980
## [205,] 1.9803250 0.65792643
## [206,] 1.8484831 0.97705283
## [207,] 1.2473200 0.91201897
## [208,] 1.1901035 0.95651717
## [209,] 0.6999643 1.08653047
## [210,] 0.8292040 0.17395316
## [211,] 0.5765239 1.74468941
## [212,] 1.5467431 0.49979046
## [213,] 2.7331782 1.73606747
## [214,] 1.1080662 0.38607177
## [215,] 1.2265040 0.90847359
## [216,] 0.7944392 1.02596895
## [217,] 0.8269498 0.82504663
## [218,] 1.0995456 2.03031621
## [219,] 1.2623924 1.06249858
## [220,] 1.0410670 0.70588706
## [221,] 1.1091452 0.83795062
## [222,] 1.3492663 0.47681329
## [223,] 0.8276861 1.85119125
## [224,] 1.2828631 1.05128423
## [225,] 0.6153764 0.76843460
## [226,] 1.3691524 1.60514924
## [227,] 1.0092886 0.88655998
## [228,] 1.0370490 0.35206558
## [229,] 1.0878436 0.46590179
## [230,] 0.3215025 1.23649197
## [231,] 0.9811357 1.27594695
## [232,] 1.0460018 1.05644235
## [233,] 1.6705937 0.70596700
## [234,] 0.8906043 0.80206793
## [235,] 1.1467583 1.52023607
## [236,] 0.9412889 0.62580126
## [237,] 0.8318293 1.45775055
## [238,] 0.9084554 1.30197418
## [239,] 0.7813009 0.19049536
## [240,] 0.8063977 0.52416881
## [241,] 0.9943149 0.39812366
## [242,] 1.1303820 0.29685756
## [243,] 1.9693554 0.33917957
## [244,] 0.6927489 0.66530052
## [245,] 1.0492643 1.18776134
## [246,] 0.5396945 0.65912900
## [247,] 0.7099256 0.47325832
## [248,] 0.3817309 0.79509043
## [249,] 1.0495968 0.98325605
## [250,] 1.3287628 0.63263196
## [251,] 1.0445835 0.37927237
## [252,] 0.8463631 0.56750830
## [253,] 0.8469430 0.39868357
## [254,] 1.2653633 0.76285162
## [255,] 1.6085854 1.09402033
## [256,] 1.1969472 0.61765924
## [257,] 1.1100303 1.19671593
## [258,] 0.4530513 0.14425296
## [259,] 1.3439128 0.88796493
## [260,] 0.7051329 0.93656667
## [261,] 1.1737709 1.52113650
## [262,] 1.9966074 1.61442764
## [263,] 0.6576103 2.95374729
## [264,] 1.0258283 2.00108295
## [265,] 1.1327780 1.10664763
## [266,] 1.4337845 1.01820734
## [267,] 1.7356807 0.99993904
## [268,] 0.7911979 0.76113778
## [269,] 0.8772472 1.58192291
## [270,] 0.3170194 1.12587571
## [271,] 1.0251369 0.38776532
## [272,] 0.8015990 0.88670611
## [273,] 1.0074434 0.58257635
## [274,] 1.1212656 0.86931163
## [275,] 2.1189109 1.39648626
## [276,] 0.8579511 0.80095726
## [277,] 1.0088317 0.36111837
## [278,] 0.5986079 0.72886504
## [279,] 1.4609141 0.64041333
## [280,] 1.1954366 2.17428208
## [281,] 0.5493951 1.27961526
## [282,] 1.7146841 0.60464874
## [283,] 0.8755060 0.78788718
## [284,] 0.6815880 0.93502038
## [285,] 0.3490789 0.91065799
## [286,] 1.2522925 0.29116124
## [287,] 0.8974091 1.30178449
## [288,] 0.9269665 0.55304192
## [289,] 1.3579240 0.52596202
## [290,] 1.2634631 1.08748755
## [291,] 0.7047291 2.11519543
## [292,] 0.4755216 1.00931075
## [293,] 0.4525303 2.45173588
## [294,] 1.7549381 0.31142339
## [295,] 1.1262524 0.88003663
## [296,] 0.8612480 0.21986841
## [297,] 0.6332394 0.41761796
## [298,] 0.7595142 0.69711543
## [299,] 0.6220158 2.17750530
## [300,] 0.5195922 0.47066606
## [301,] 2.2143477 1.33536599
## [302,] 0.9619690 1.21818256
## [303,] 1.3393011 0.46854008
## [304,] 0.6741815 1.10632058
## [305,] 0.9050634 0.36331844
## [306,] 0.7586536 0.05326183
## [307,] 1.8850744 1.49398749
## [308,] 0.8701400 1.26480962
## [309,] 0.6246170 0.94605366
## [310,] 0.7434882 0.66343739
## [311,] 0.6241196 0.36803575
## [312,] 0.7392008 0.63206829
## [313,] 0.6204418 0.90183133
## [314,] 1.4369364 0.86566185
## [315,] 1.0950103 0.88372775
## [316,] 0.3606183 0.45191790
## [317,] 0.9038696 0.41789458
## [318,] 0.6818844 0.77545759
## [319,] 0.9386359 0.97881848
## [320,] 0.9608002 0.38317046
## [321,] 0.4499469 1.12595899
## [322,] 0.6515932 1.11300687
## [323,] 1.0367430 2.00804202
## [324,] 1.7616044 0.59096547
## [325,] 0.6198267 0.99565930
## [326,] 0.6294190 0.80635666
## [327,] 0.7138286 0.72195313
## [328,] 1.2155795 1.04477719
## [329,] 0.9943878 0.37867912
## [330,] 0.5346592 0.65465115
## [331,] 1.3035920 0.70328380
## [332,] 0.6514606 0.91280464
## [333,] 0.6156430 1.22799016
## [334,] 1.3393159 2.21337787
## [335,] 0.9396514 0.82130009
## [336,] 0.7621975 0.75879105
## [337,] 1.0811002 0.53382832
## [338,] 0.5429740 0.72627893
## [339,] 0.6794016 0.50554019
## [340,] 0.3440995 0.72592403
## [341,] 0.7144134 1.47694685
## [342,] 1.6501142 0.31222010
## [343,] 1.3195745 0.59195932
## [344,] 1.0822338 0.82016395
## [345,] 1.0248923 0.68616112
## [346,] 0.8465658 0.39546285
## [347,] 1.3159924 1.32586331
## [348,] 2.0137595 1.07913145
## [349,] 0.5617655 0.41669802
## [350,] 0.5234729 0.96833320
## [351,] 0.7451603 0.77258102
## [352,] 0.8004728 0.99977931
## [353,] 0.4928175 0.42095239
## [354,] 1.5239090 2.39179650
## [355,] 0.5447614 1.68510240
## [356,] 0.9025730 0.63968245
## [357,] 0.9116071 0.59002542
## [358,] 0.6358900 0.33353475
## [359,] 1.3176158 0.80371362
## [360,] 1.2458030 1.28267054
## [361,] 0.7105637 0.75557652
## [362,] 0.4880201 0.84447725
## [363,] 1.2478312 0.23313198
## [364,] 0.5642719 0.43466534
## [365,] 1.0983181 1.09554752
## [366,] 1.1016706 1.12650157
## [367,] 1.1275571 1.65042046
## [368,] 0.5977609 0.82010587
## [369,] 1.2126740 2.08352687
## [370,] 1.2353064 0.59179882
## [371,] 1.1449709 0.93600040
## [372,] 0.6851895 1.28372510
## [373,] 1.0730000 0.70669400
## [374,] 0.5480474 0.23999514
## [375,] 0.4946227 0.50322509
## [376,] 1.1536442 0.93753283
## [377,] 0.7435991 0.55417308
## [378,] 0.9497826 0.72361137
## [379,] 0.5480471 0.20004169
## [380,] 0.4743367 1.20513190
## [381,] 0.9153583 0.28900591
## [382,] 1.6431589 0.87475903
## [383,] 1.2614956 1.32784061
## [384,] 1.4692273 0.72311505
## [385,] 0.6734591 2.05855272
## [386,] 0.8930846 1.50969552
## [387,] 0.7161146 0.98951760
## [388,] 0.8183737 0.40099835
## [389,] 1.7915631 1.17755079
## [390,] 1.1669373 1.06571843
## [391,] 0.7302804 0.80439728
## [392,] 0.4985687 0.76551647
## [393,] 1.9499124 0.99995150
## [394,] 1.3754953 0.73471859
## [395,] 0.8166079 1.36225881
## [396,] 1.0498461 1.29567139
## [397,] 0.9807533 0.34989353
## [398,] 1.0709584 1.54775608
## [399,] 1.2439865 1.06446855
## [400,] 1.1690408 1.16383593
## [401,] 0.8810735 0.49818260
## [402,] 1.0517341 1.89335193
## [403,] 0.8416317 1.50919464
## [404,] 0.4464852 2.26712068
## [405,] 0.7589892 0.47375604
## [406,] 1.0772708 0.44622388
## [407,] 0.6379868 0.47027829
## [408,] 0.9601450 0.81424399
## [409,] 0.5592093 3.17780327
## [410,] 0.6745780 1.13658209
## [411,] 0.2152670 1.51470433
## [412,] 0.8104944 0.66711496
## [413,] 0.7259179 0.31287038
## [414,] 0.9528539 0.90366831
## [415,] 0.5554814 1.78897283
## [416,] 0.9522524 1.45215423
## [417,] 0.7504043 0.92277790
## [418,] 1.5086416 1.93706647
## [419,] 0.7773664 0.35261346
## [420,] 1.1835498 0.68973841
## [421,] 1.1991893 0.20739234
## [422,] 0.9997656 1.27780616
## [423,] 1.3405092 0.84994973
## [424,] 0.5064495 0.84304223
## [425,] 0.6983098 1.29447065
## [426,] 0.6837848 3.16463869
## [427,] 0.9092428 1.08922354
## [428,] 0.6197779 0.44091036
## [429,] 1.1432138 0.84256893
## [430,] 1.6432492 1.07135652
## [431,] 1.0456480 0.49432068
## [432,] 0.8931504 0.61291320
## [433,] 1.1340499 1.10807504
## [434,] 1.8952161 2.09410218
## [435,] 0.6988086 1.67150293
## [436,] 1.3106526 0.91627176
## [437,] 0.8594195 3.23619282
## [438,] 0.6460948 1.00534759
## [439,] 1.1055952 0.87704563
## [440,] 0.8446594 0.65659851
## [441,] 1.4585461 0.90865992
## [442,] 0.7577382 0.83440239
## [443,] 2.0883890 0.98178903
## [444,] 0.9351446 1.52629841
## [445,] 0.9316319 0.87163312
## [446,] 1.5698442 0.86845565
## [447,] 0.5665456 1.01549874
## [448,] 0.5626745 0.99853102
## [449,] 0.6398035 0.81222033
## [450,] 1.1809123 1.03955848
## [451,] 0.3925237 0.86232830
## [452,] 1.2468293 0.72436298
## [453,] 0.6302959 1.62102968
## [454,] 1.3907056 1.09013804
## [455,] 0.5423411 0.85684597
## [456,] 0.7422516 0.65444308
## [457,] 0.6018106 1.08696899
## [458,] 1.1609321 1.41112646
## [459,] 1.1874088 1.25278072
## [460,] 2.0163243 1.57418813
## [461,] 0.8098701 0.66892541
## [462,] 1.1923378 0.90976174
## [463,] 0.7547008 0.99467647
## [464,] 1.8055849 0.73126206
## [465,] 0.7455785 0.88636978
## [466,] 1.0432839 0.72553917
## [467,] 2.2074087 1.02002908
## [468,] 1.0077337 1.96836279
## [469,] 0.9918374 1.45675952
## [470,] 0.9758125 0.96661780
## [471,] 0.6003911 0.49975790
## [472,] 0.4956800 1.22750434
## [473,] 0.8705493 2.17921105
## [474,] 0.9148897 0.53954524
## [475,] 1.3509824 0.29611586
## [476,] 1.6922938 0.93668942
## [477,] 0.7355045 0.69490253
## [478,] 1.4599986 0.75834578
## [479,] 1.6294612 1.25118250
## [480,] 0.7197546 0.72239331
## [481,] 1.9410846 1.61116602
## [482,] 0.6536349 1.10902314
## [483,] 1.1855946 2.29321694
## [484,] 0.3603394 1.57431066
## [485,] 0.3285999 0.70380126
## [486,] 0.8538744 0.56730120
## [487,] 0.5645355 0.53727387
## [488,] 0.5015303 0.31231024
## [489,] 0.8075431 0.59975462
## [490,] 0.3570011 0.47374297
## [491,] 1.3168424 1.15909600
## [492,] 0.6382237 1.22011819
## [493,] 1.0127913 1.09584083
## [494,] 1.1353079 1.42338686
## [495,] 1.3087479 1.91018187
## [496,] 0.7963326 1.26443020
## [497,] 1.0779486 1.58335191
## [498,] 0.6494726 1.36397610
## [499,] 1.1949046 0.97350825
## [500,] 0.9483530 1.71308576
## [501,] 2.1204888 1.48745550
## [502,] 1.1743416 1.64908701
## [503,] 1.0091568 0.37161949
## [504,] 0.4072796 1.04429603
## [505,] 1.5271301 1.96019099
## [506,] 1.2287315 0.43114476
## [507,] 1.3698661 1.06423562
## [508,] 0.8407309 0.69494132
## [509,] 0.8870609 0.34694123
## [510,] 0.3702202 0.44149551
## [511,] 0.8236391 0.65362775
## [512,] 0.6200980 0.89792275
## [513,] 0.8793795 0.92653874
## [514,] 1.2934338 1.05694898
## [515,] 0.8973448 1.34372462
## [516,] 0.6185947 1.60939311
## [517,] 0.3942516 1.23078762
## [518,] 1.3765297 0.86618075
## [519,] 0.5434618 1.21685042
## [520,] 0.9651031 1.11770380
## [521,] 1.2173040 0.91633644
## [522,] 0.9418050 0.43549662
## [523,] 0.7126328 1.51671943
## [524,] 1.0219008 0.96877390
## [525,] 0.6968741 0.69634657
## [526,] 0.9297531 0.86218619
## [527,] 0.7484446 1.12988831
## [528,] 1.3800316 0.76352916
## [529,] 0.8777571 0.63468762
## [530,] 0.3820690 0.64416194
## [531,] 1.3018695 0.54206278
## [532,] 0.6346759 0.61905107
## [533,] 0.7632757 0.65272424
## [534,] 1.1734091 0.58840477
## [535,] 1.2222309 1.01749008
## [536,] 1.2835646 0.63317336
## [537,] 0.7093720 0.41070668
## [538,] 1.9728403 1.24053844
## [539,] 1.1759590 1.34327685
## [540,] 1.1334995 2.29717735
## [541,] 0.5597736 0.80365050
## [542,] 0.8628270 2.18391311
## [543,] 1.0882726 0.23109391
## [544,] 0.6462586 1.92913387
## [545,] 1.0964461 1.32362761
## [546,] 1.4883107 1.52824533
## [547,] 0.9425796 0.85256355
## [548,] 0.8156692 1.17420337
## [549,] 1.3709601 1.76308330
## [550,] 0.7998989 0.60009149
## [551,] 1.1644218 0.99234329
## [552,] 0.9521748 0.65166021
## [553,] 1.5160259 0.82291667
## [554,] 1.0270599 1.14838124
## [555,] 0.6650235 0.97053886
## [556,] 0.6941643 0.37243516
## [557,] 0.6059180 0.72065664
## [558,] 1.4736556 1.99828353
## [559,] 1.5632961 0.79161819
## [560,] 1.6506321 0.52065148
## [561,] 0.8987973 1.03386674
## [562,] 1.5999100 1.09541304
## [563,] 1.6499875 0.94294638
## [564,] 2.1977576 0.47777041
## [565,] 1.7149846 1.26052839
## [566,] 0.6909844 1.11851775
## [567,] 0.9084368 0.91727704
## [568,] 1.5132242 1.09965041
## [569,] 0.8268782 0.37365889
## [570,] 0.7236254 0.20079560
## [571,] 1.0127392 0.65364606
## [572,] 0.8665130 1.97563799
## [573,] 0.8214295 0.57913885
## [574,] 1.0409466 1.17211506
## [575,] 1.4722340 0.82896578
## [576,] 0.9063910 1.31975334
## [577,] 1.6012484 1.13366360
## [578,] 1.0652507 0.64675186
## [579,] 0.2560096 0.79152454
## [580,] 0.9212990 0.91637675
## [581,] 0.9765630 1.52128346
## [582,] 1.1269429 0.80616560
## [583,] 1.0579819 0.66749512
## [584,] 0.9843757 0.15330493
## [585,] 0.8050076 1.09661760
## [586,] 0.7127697 0.69340984
## [587,] 1.7848382 1.32805900
## [588,] 0.5843713 0.81732330
## [589,] 1.8642460 0.58201039
## [590,] 1.1710262 1.83004908
## [591,] 1.2190796 1.62474887
## [592,] 1.4671631 0.42240324
## [593,] 0.9912271 0.25846625
## [594,] 0.8854594 1.18902854
## [595,] 0.7107006 0.29439301
## [596,] 0.9796125 0.89710748
## [597,] 1.6404288 1.25579941
## [598,] 0.7219896 0.80773044
## [599,] 1.8101802 0.38837876
## [600,] 0.8148713 0.88771104
## [601,] 0.8901417 0.36594319
## [602,] 1.3805386 0.39059287
## [603,] 1.2423347 0.89072052
## [604,] 0.8085874 1.34649496
## [605,] 0.7324197 0.47387237
## [606,] 0.8296322 1.14272939
## [607,] 0.9581982 0.50120377
## [608,] 1.6340489 0.65294311
## [609,] 0.5797476 0.90626303
## [610,] 1.0755741 1.03890082
## [611,] 0.7288982 0.89491200
## [612,] 0.9359585 1.23192617
## [613,] 1.7201793 0.56154848
## [614,] 1.6177320 0.62894380
## [615,] 1.5366916 0.79874701
## [616,] 1.2335096 0.35919356
## [617,] 1.6454639 0.93628310
## [618,] 0.8284709 1.02798730
## [619,] 0.4517260 1.13568875
## [620,] 0.8173306 2.00852879
## [621,] 0.7366453 0.73216848
## [622,] 1.3345530 0.56955129
## [623,] 1.1154167 1.02734495
## [624,] 0.6403605 0.41783438
## [625,] 1.0394503 2.10612397
## [626,] 0.7980853 0.44437543
## [627,] 0.7856355 0.63672340
## [628,] 1.9369054 4.18188242
## [629,] 0.7925586 0.39619156
## [630,] 0.9454898 0.70277811
## [631,] 1.4790091 0.36848178
## [632,] 1.8357507 0.34228332
## [633,] 0.5132617 1.53471031
## [634,] 1.9878506 2.15092830
## [635,] 1.8914638 1.82277447
## [636,] 1.3005615 0.76688387
## [637,] 0.6326528 1.58548151
## [638,] 0.6251044 1.02472280
## [639,] 0.9828446 1.57245566
## [640,] 1.1721122 1.17866651
## [641,] 2.5873978 1.02934753
## [642,] 0.6524322 2.52434615
## [643,] 0.5855141 1.59252396
## [644,] 1.0238643 0.83445289
## [645,] 1.4436485 0.69051705
## [646,] 0.4439376 0.40049460
## [647,] 0.7013870 0.51008094
## [648,] 1.6416343 0.58593403
## [649,] 1.6603244 0.66945936
## [650,] 0.7737036 0.53322450
## [651,] 0.9650264 0.58296748
## [652,] 1.1619597 0.98485660
## [653,] 0.8942587 1.33208139
## [654,] 0.7542762 0.65584182
## [655,] 0.8273817 1.48986673
## [656,] 0.9561734 1.43369211
## [657,] 1.0984707 0.92798317
## [658,] 0.5429216 0.60082053
## [659,] 0.6615079 1.40821221
## [660,] 1.2194520 0.71256038
## [661,] 0.7546587 0.67810696
## [662,] 1.1391690 1.57317371
## [663,] 1.2630388 1.64130230
## [664,] 0.9124970 0.55167096
## [665,] 1.1023730 1.53750788
## [666,] 1.4180320 0.35546435
## [667,] 0.8076809 1.05358807
## [668,] 1.1404703 0.96425399
## [669,] 0.6227488 1.30818472
## [670,] 0.7715472 0.40001147
## [671,] 1.5124930 1.45686859
## [672,] 1.2421551 2.30789780
## [673,] 0.8690331 1.81391477
## [674,] 1.0543007 0.41708062
## [675,] 0.8435668 0.44357255
## [676,] 1.0629607 1.51585087
## [677,] 0.5922369 0.74136721
## [678,] 0.8019473 0.77224229
## [679,] 1.2501128 1.28763651
## [680,] 0.8351733 1.82414261
## [681,] 0.9478407 0.38457588
## [682,] 0.3545234 0.76776433
## [683,] 0.7497906 1.33751168
## [684,] 0.4878910 0.17530569
## [685,] 0.5932700 0.88062584
## [686,] 0.6257983 1.22720453
## [687,] 0.5986350 0.56563438
## [688,] 0.8267029 1.01600198
## [689,] 0.9507819 0.25773220
## [690,] 0.8699451 0.98611339
## [691,] 0.5950744 0.83183616
## [692,] 0.5535604 1.14954414
## [693,] 0.7007386 0.57952528
## [694,] 0.6178633 1.50831561
## [695,] 1.3239512 0.75950011
## [696,] 1.3987148 1.14815301
## [697,] 1.0159620 0.47816569
## [698,] 0.7284469 1.77396161
## [699,] 0.8938933 1.02192840
## [700,] 0.7607588 0.34406807
## [701,] 1.9560295 0.87261775
## [702,] 0.9168741 1.49632044
## [703,] 0.9553180 0.85058890
## [704,] 1.5805771 0.77999563
## [705,] 1.6093713 0.95878107
## [706,] 0.7834773 1.02098641
## [707,] 1.1471172 1.44541467
## [708,] 0.4540114 0.48576378
## [709,] 1.9850254 0.68238676
## [710,] 1.0013860 0.83992692
## [711,] 1.2912023 0.53404474
## [712,] 1.9868597 1.54211795
## [713,] 1.0133956 0.44294528
## [714,] 1.1299563 1.12352738
## [715,] 0.6239997 0.30592509
## [716,] 1.2597942 0.47484347
## [717,] 0.6377306 0.58293417
## [718,] 0.7145270 0.71534360
## [719,] 1.5245074 0.77742196
## [720,] 0.8604560 0.42722585
## [721,] 1.0250631 0.94431315
## [722,] 0.5043084 1.62524266
## [723,] 1.2233889 0.56538176
## [724,] 0.9195425 1.07496445
## [725,] 1.3065672 0.74668972
## [726,] 0.6017845 0.43295748
## [727,] 0.6292322 1.93304145
## [728,] 0.6645895 0.90506139
## [729,] 1.0370525 0.83511511
## [730,] 1.3487661 0.94289922
## [731,] 0.7240026 1.10813387
## [732,] 0.4718213 1.87551454
## [733,] 0.9944666 1.12157721
## [734,] 0.9661874 0.77841698
## [735,] 0.9407827 0.94478734
## [736,] 1.5181115 0.96755605
## [737,] 1.0861487 0.86111625
## [738,] 0.6814118 3.05385408
## [739,] 0.9482977 0.63038335
## [740,] 0.9306620 0.66625435
## [741,] 1.1508735 0.84649672
## [742,] 1.2675839 0.92012869
## [743,] 0.6834506 1.45330205
## [744,] 1.5143191 0.31880034
## [745,] 0.7137232 0.54559870
## [746,] 1.0063173 2.19902076
## [747,] 0.3965653 1.90413978
## [748,] 1.8291876 2.16370708
## [749,] 0.7090465 1.30993472
## [750,] 0.8907871 2.28733647
## [751,] 0.8699750 1.52031111
## [752,] 0.7602984 2.00049630
## [753,] 1.1909609 0.82478296
## [754,] 1.4657535 0.89682536
## [755,] 0.4725414 0.22447273
## [756,] 1.6490548 0.58343126
## [757,] 0.9413869 0.36074091
## [758,] 1.4498713 1.03019044
## [759,] 1.2375759 0.86547952
## [760,] 0.9193135 1.29408591
## [761,] 0.5771571 0.70259725
## [762,] 0.9491589 1.22134232
## [763,] 0.7235649 0.85166016
## [764,] 0.5410474 0.72592391
## [765,] 1.2319115 1.02541922
## [766,] 1.4274635 1.41833337
## [767,] 0.7957080 0.66642774
## [768,] 0.5917500 0.27670856
## [769,] 0.8486788 1.31599536
## [770,] 0.6169780 0.76140694
## [771,] 0.5996015 0.50340651
## [772,] 0.7277137 0.87138947
## [773,] 1.5698327 0.82215948
## [774,] 0.8608864 1.46293119
## [775,] 0.6647665 0.31986231
## [776,] 1.6290902 0.53280367
## [777,] 0.8655513 1.33921985
## [778,] 1.4019251 0.26458114
## [779,] 1.8297420 0.74024376
## [780,] 1.1883039 0.64357600
## [781,] 0.8684364 0.37717464
## [782,] 0.9782983 0.80129507
## [783,] 0.6238439 0.43358882
## [784,] 1.3323997 0.54460076
## [785,] 1.2017552 0.99595303
## [786,] 0.4963368 0.76132299
## [787,] 2.9405050 0.23439556
## [788,] 0.7952164 2.57144416
## [789,] 1.2546925 0.45443448
## [790,] 0.9324109 1.03560029
## [791,] 2.1734120 1.74761765
## [792,] 1.1395664 1.07587413
## [793,] 1.1394652 0.32758519
## [794,] 1.0238373 0.25847345
## [795,] 0.6711264 0.75496750
## [796,] 0.8125245 0.73409889
## [797,] 0.6825956 0.81450507
## [798,] 1.2502209 2.16433193
## [799,] 0.8710509 0.40158436
## [800,] 0.8176545 1.01010220
## [801,] 0.9998345 1.02776361
## [802,] 1.5370206 0.72601096
## [803,] 0.9978976 0.65335191
## [804,] 0.7683641 0.57229276
## [805,] 1.0969314 0.89035396
## [806,] 1.1777961 1.13722497
## [807,] 1.0037105 1.80154453
## [808,] 1.2888395 1.90541547
## [809,] 1.1125493 1.81919154
## [810,] 0.6534811 4.13206487
## [811,] 0.7059548 0.51270332
## [812,] 1.6927398 0.62226572
## [813,] 1.4917362 0.95479764
## [814,] 0.7568100 2.52392640
## [815,] 0.4332299 0.41458914
## [816,] 1.3038428 0.67148336
## [817,] 0.6654238 1.73693640
## [818,] 0.6226148 1.83175958
## [819,] 1.2886579 1.30836586
## [820,] 0.6817998 0.76073197
## [821,] 1.5190464 0.69891208
## [822,] 0.7927665 1.02616794
## [823,] 0.7207393 0.55893148
## [824,] 1.3722153 0.41449675
## [825,] 0.6847540 1.30796215
## [826,] 1.2708533 1.25506678
## [827,] 0.9701445 1.90515580
## [828,] 0.7946362 1.12439047
## [829,] 0.8442446 0.67309974
## [830,] 1.4013851 0.95543551
## [831,] 1.1982387 1.30534280
## [832,] 1.0662492 0.84689471
## [833,] 1.2345292 2.02006640
## [834,] 1.2409209 0.62990089
## [835,] 0.4699213 1.90678208
## [836,] 0.4353303 1.10362360
## [837,] 0.4065671 0.62276542
## [838,] 1.1821853 1.68761016
## [839,] 0.7423076 0.88223074
## [840,] 1.3922291 0.83107795
## [841,] 0.9872968 0.41358690
## [842,] 1.1640101 1.24507446
## [843,] 1.2230356 1.32156622
## [844,] 0.7346304 0.81759965
## [845,] 0.9675008 0.84794097
## [846,] 0.2980342 0.82192500
## [847,] 0.8163188 2.07591575
## [848,] 0.8644544 0.63777696
## [849,] 1.2792576 1.15264767
## [850,] 0.8981216 0.76016666
## [851,] 0.7728509 0.75964400
## [852,] 2.1304241 0.70694266
## [853,] 0.5945976 0.62526587
## [854,] 1.7130342 1.23462044
## [855,] 0.8712119 1.16131277
## [856,] 1.1970056 0.98527057
## [857,] 0.6069538 1.11598565
## [858,] 1.0419167 0.65549208
## [859,] 0.7197137 0.44549738
## [860,] 0.9528973 0.41792414
## [861,] 1.4841738 1.29001847
## [862,] 0.8689362 0.67111451
## [863,] 0.4694707 0.86417011
## [864,] 0.9496348 0.82919513
## [865,] 1.9967742 0.27221558
## [866,] 0.7268905 0.87527850
## [867,] 1.0504223 0.38427903
## [868,] 0.8659629 1.19837882
## [869,] 2.4641232 1.80969054
## [870,] 0.4597671 1.11602650
## [871,] 1.1237199 0.79087277
## [872,] 1.8705795 1.00932670
## [873,] 1.2060647 0.47306640
## [874,] 0.5903629 1.85772154
## [875,] 0.9254537 0.65488186
## [876,] 1.5737251 1.07317929
## [877,] 1.3714923 0.66803761
## [878,] 0.7888457 1.32511561
## [879,] 1.1428083 0.37643234
## [880,] 0.9952552 0.52939704
## [881,] 1.3074274 1.63848752
## [882,] 0.5697533 1.60022278
## [883,] 0.7272473 1.28984686
## [884,] 0.8809793 1.07550857
## [885,] 0.7932648 0.23076546
## [886,] 0.6737258 0.36594250
## [887,] 0.8286653 0.36390364
## [888,] 1.1121391 1.90718114
## [889,] 1.2961952 0.30017475
## [890,] 0.4563531 0.43695480
## [891,] 1.3936794 0.78549102
## [892,] 1.3511735 1.65126750
## [893,] 1.7417694 0.53419978
## [894,] 1.0606282 1.10656493
## [895,] 0.8665410 1.58838985
## [896,] 0.7208128 1.04857034
## [897,] 1.0779552 1.06686868
## [898,] 1.5091876 0.42718878
## [899,] 0.7517713 1.31610275
## [900,] 1.0928493 1.85331555
## [901,] 0.7271310 1.64483017
## [902,] 1.1622049 0.89520336
## [903,] 1.5143047 1.16098743
## [904,] 0.8342278 2.34222733
## [905,] 1.1645357 0.57855718
## [906,] 0.8935149 0.53379762
## [907,] 0.8889430 1.58445771
## [908,] 0.7996588 1.71423389
## [909,] 1.0609418 1.17259754
## [910,] 0.7152316 1.36031688
## [911,] 1.2182367 0.63905704
## [912,] 0.7120088 0.62793812
## [913,] 1.0610500 1.15609908
## [914,] 1.5639122 1.18423949
## [915,] 0.4644116 0.67447712
## [916,] 1.0376288 0.53735065
## [917,] 0.6104388 0.51254913
## [918,] 0.8120774 2.37832387
## [919,] 1.1650104 0.61278652
## [920,] 0.5433542 1.29394994
## [921,] 1.4880376 0.76281827
## [922,] 0.9116112 0.98179425
## [923,] 1.4045044 0.43077253
## [924,] 0.7741703 0.60425727
## [925,] 0.7016026 0.62509517
## [926,] 0.8111239 0.89328913
## [927,] 0.6263828 0.57730410
## [928,] 0.9005575 0.53503452
## [929,] 0.8245573 0.71955285
## [930,] 0.7336173 1.56712831
## [931,] 1.1403295 1.75125492
## [932,] 0.7207910 1.83048095
## [933,] 0.6334206 0.56450732
## [934,] 2.1726911 0.22841207
## [935,] 0.5590524 0.66877594
## [936,] 1.6411651 0.42193534
## [937,] 1.7886062 1.86934179
## [938,] 0.6319271 1.72548227
## [939,] 0.8864005 1.14340620
## [940,] 0.8545877 0.69356165
## [941,] 0.8665172 0.50388313
## [942,] 1.2142519 0.58516447
## [943,] 1.5791129 0.71189078
## [944,] 0.6995305 0.38932142
## [945,] 1.4012472 0.38818707
## [946,] 1.6756710 2.84250893
## [947,] 1.2980745 1.22573640
## [948,] 0.7812542 0.45253976
## [949,] 0.6612159 1.88582339
## [950,] 0.9066814 0.95709836
## [951,] 1.0620743 1.24835088
## [952,] 1.4383693 1.36931194
## [953,] 1.6734733 2.06493796
## [954,] 0.9820771 1.07760795
## [955,] 1.0824610 0.89546916
## [956,] 0.6076773 0.74429575
## [957,] 1.1106382 0.60470531
## [958,] 0.7375140 0.45665437
## [959,] 1.4812775 0.24345309
## [960,] 0.7597711 0.66479901
## [961,] 0.9348882 1.88101359
## [962,] 0.5683129 1.74407504
## [963,] 1.2398335 1.12431938
## [964,] 1.5848157 1.88529038
## [965,] 0.8209194 1.58343085
## [966,] 1.1251159 0.21865188
## [967,] 0.9124771 1.75284863
## [968,] 2.8911078 0.69488178
## [969,] 1.7221705 0.62077510
## [970,] 2.0562568 0.42664762
## [971,] 1.4845690 0.35420440
## [972,] 0.5468467 1.18689076
## [973,] 0.7435401 0.37322234
## [974,] 0.9700710 0.86866993
## [975,] 1.1460167 1.36687125
## [976,] 0.6023146 0.40082043
## [977,] 1.4531492 0.47942158
## [978,] 1.2459988 1.21412753
## [979,] 0.7107660 0.71509753
## [980,] 1.0515236 0.38844426
## [981,] 0.9548321 1.31627826
## [982,] 0.5411350 0.39525743
## [983,] 0.8908697 2.52877229
## [984,] 0.6059120 0.39416712
## [985,] 1.0005552 1.16564603
## [986,] 0.9063894 1.01430222
## [987,] 0.6406938 0.70247428
## [988,] 1.1166691 0.33820486
## [989,] 0.8351770 0.91273884
## [990,] 0.8716710 0.60042835
## [991,] 0.9662992 1.27239273
## [992,] 1.9983173 1.07775183
## [993,] 1.0031705 1.18651036
## [994,] 1.7032450 1.02501933
## [995,] 1.4873095 0.66056383
## [996,] 1.5929669 0.98300208
## [997,] 1.9592538 1.03564187
## [998,] 0.8350251 0.39235785
## [999,] 1.4468407 2.37973722
##
## $model.matrix
## (Intercept) factor1 factor2 shrub_density
## 1 1 1 0 11
## 2 1 1 0 14
## 3 1 0 1 13
## 4 1 1 0 12
## 5 1 0 1 12
## 6 1 1 0 8
## 7 1 0 1 10
## 8 1 1 0 9
## 9 1 0 1 10
## 10 1 -1 -1 5
## 11 1 -1 -1 10
## 12 1 0 1 9
## 13 1 -1 -1 12
## 14 1 0 1 12
## 15 1 1 0 10
## 16 1 0 1 16
## 17 1 1 0 22
## 18 1 0 1 22
## 19 1 1 0 30
## 20 1 0 1 28
## 21 1 1 0 26
## 22 1 0 1 28
## 23 1 1 0 28
## 24 1 -1 -1 24
## 25 1 0 1 28
## 26 1 -1 -1 18
## 27 1 0 1 12
## 28 1 1 0 8
## 29 1 0 1 8
## 30 1 1 0 5
## 31 1 0 1 6
## 32 1 1 0 7
## 33 1 0 1 6
## 34 1 1 0 3
## 35 1 0 1 1
## 36 1 1 0 1
## 37 1 0 1 0
## 38 1 -1 -1 9
## 39 1 0 1 8
## 40 1 -1 -1 10
## 41 1 0 1 8
## 42 1 -1 -1 11
## 43 1 0 1 10
## 44 1 1 0 0
## 45 1 0 1 0
## 46 1 1 0 0
## 47 1 0 1 0
## 48 1 1 0 0
## 49 1 0 1 0
## 50 1 1 0 0
## 51 1 0 1 0
## 52 1 1 0 0
## 53 1 0 1 0
##
## $terms
## pca_data_final ~ factor + shrub_density
## attr(,"variables")
## list(pca_data_final, factor, shrub_density)
## attr(,"factors")
## factor shrub_density
## pca_data_final 0 0
## factor 1 0
## shrub_density 0 1
## attr(,"term.labels")
## [1] "factor" "shrub_density"
## attr(,"order")
## [1] 1 1
## attr(,"intercept")
## [1] 1
## attr(,"response")
## [1] 1
## attr(,".Environment")
## <environment: R_GlobalEnv>
##
## attr(,"class")
## [1] "adonis"
dist_final <- vegdist(pca_data_final, species = "bray")
res_final <- pcoa(dist_final)
p02 <- as.data.frame(res_final$vectors)%>%
dplyr::select(Axis.1, Axis.2) %>%
bind_cols(env_final,.)
pcoa_final <- ggplot(p02, aes(Axis.1, Axis.2, group = factor)) +
geom_point(aes(color = factor)) +
geom_text(aes(label=site.number), hjust = 0, vjust = 0, check_overlap = TRUE, nudge_x = 0.01)+
scale_color_brewer(palette = "Paired") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
labs(color = "Microsite") + theme(aspect.ratio = 1)
pcoa_final2 <- ggplot(p02, aes(Axis.1, Axis.2, group = shrub_density)) +
geom_point(aes(color = factor)) +
geom_text(aes(label=site.number), hjust = 0, vjust = 0, check_overlap = TRUE, nudge_x = 0.01)+
scale_color_brewer(palette = "Paired") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
labs(color = "Microsite") + theme(aspect.ratio = 1)
pcoa_final
model020 <- betadisper(dist_final, env_final$factor)
model020
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist_final, group = env_final$factor)
##
## No. of Positive Eigenvalues: 29
## No. of Negative Eigenvalues: 21
##
## Average distance to median:
## mimic open shrub
## 0.5574 0.5262 0.5339
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 50 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 4.6259 3.6419 2.1983 1.7025 1.5594 0.8852 0.6750 0.4914
anova(model020)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 2 0.01109 0.0055448 0.2288 0.7963
## Residuals 50 1.21160 0.0242320
permutest(model020,pairwise = TRUE, permutations = 99)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 99
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 2 0.01109 0.0055448 0.2288 99 0.87
## Residuals 50 1.21160 0.0242320
##
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
## mimic open shrub
## mimic 0.59000 0.61
## open 0.51802 0.96
## shrub 0.64556 0.91398
model020.HSD <- TukeyHSD(model020)
model020.HSD
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## open-mimic -0.031224995 -0.1440249 0.08157493 0.7826750
## shrub-mimic -0.023489283 -0.1807813 0.13380270 0.9308934
## shrub-open 0.007735711 -0.1449961 0.16046753 0.9917840
pcoa_boxplot <- boxplot(model020, xlab = "Microsite")
pcoa_boxplot
## $stats
## [,1] [,2] [,3]
## [1,] 0.4166372 0.2596219 0.3879586
## [2,] 0.4627337 0.3549799 0.4123306
## [3,] 0.5371419 0.5150237 0.5264774
## [4,] 0.6368308 0.6875687 0.6456148
## [5,] 0.7901610 0.8104633 0.7143069
##
## $n
## [1] 20 25 8
##
## $conf
## [,1] [,2] [,3]
## [1,] 0.4756336 0.4099256 0.3961615
## [2,] 0.5986502 0.6201218 0.6567933
##
## $out
## numeric(0)
##
## $group
## numeric(0)
##
## $names
## [1] "mimic" "open" "shrub"
### Clean up and add abundance to df
library(stringr)
photo <- read.csv("observations.csv")
colnames(tidy_20m)[4] <- "microsite_number"
tidy_20m <- tidy_20m %>%
mutate(factor = str_to_title(factor))
df <- merge(Total_Observations_factors, tidy_20m, by = c("site_code", "factor", "microsite_number"))
colnames(df)[4] <- "abundance"
colnames(df)[5] <- "rep"
colnames(df)[10] <- "shrub_density"
df <- df %>%
dplyr::select(-functioned)
df <- df %>%
dplyr::select(rep, everything())
df <- df %>%
dplyr::select(-abundance, everything())
### Calculate Richness across the tested sites
density_simple_2023 <- animals_density_final %>%
group_by(site_code, factor, microsite_number) %>%
summarise(animals = sum(captures), richness = n())
## `summarise()` has grouped output by 'site_code', 'factor'. You can override
## using the `.groups` argument.
richness <- density_simple_2023 %>%
dplyr::select(-animals)
df <- merge(df, richness, by = c("site_code", "factor", "microsite_number"))
### Evenness Data
evenness_results <- animals_density_final %>%
group_by(site_code, factor, microsite_number) %>%
summarize(evenness = diversity(captures, index = "shannon")) ### This worked 100x better than Vegan!!!
## `summarise()` has grouped output by 'site_code', 'factor'. You can override
## using the `.groups` argument.
df <- merge(df, evenness_results, by = c("site_code", "factor", "microsite_number"))
#write.csv(df, file = "Dataframe.csv")
df <- read.csv("Dataframe.csv")
### Handheld Temp Data
handheld_temp <- read.csv("Chapter5_Temp_Data.csv")
colnames(handheld_temp)[5] <- "microsite_number"
colnames(handheld_temp)[8] <- "ground_temp"
handheld_temp <- handheld_temp %>%
group_by(site_code, factor, microsite_number ) %>%
summarise(mean_ambient_temp = mean(temp), mean_rh = mean(rh), mean_ground_temp = mean(ground_temp))
## `summarise()` has grouped output by 'site_code', 'factor'. You can override
## using the `.groups` argument.
handheld_temp <- handheld_temp %>%
mutate(factor = str_to_title(factor))
df <- merge(df, handheld_temp, by = c("site_code", "factor", "microsite_number"))
colnames(df)[7] <- "pendant_ID"
colnames(df)[8] <- "shrub_density"
### Pendant Temp and test if temp is significant compared across factors
library(emmeans)
pendant_temp <- read.csv("Temp_Final.csv")
pendant_temp <- pendant_temp %>%
group_by(site_code, factor, microsite_number) %>%
summarise(mean_pendant_temp = mean(temp))
## `summarise()` has grouped output by 'site_code', 'factor'. You can override
## using the `.groups` argument.
anova_result <- aov(mean_pendant_temp ~ factor, data = pendant_temp) ### Temp is significant.
print(summary(anova_result))
## Df Sum Sq Mean Sq F value Pr(>F)
## factor 2 13.87 6.937 4.836 0.0187 *
## Residuals 21 30.12 1.434
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_result <- emmeans(anova_result, pairwise ~ factor) ### Mimic Significantly cooler than open areas!
print(emmeans_result)
## $emmeans
## factor emmean SE df lower.CL upper.CL
## Mimic 18.4 0.423 21 17.6 19.3
## Open 20.4 0.453 21 19.4 21.3
## Shrub 19.5 0.399 21 18.7 20.4
##
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## Mimic - Open -1.911 0.620 21 -3.083 0.0149
## Mimic - Shrub -1.100 0.582 21 -1.889 0.1665
## Open - Shrub 0.811 0.604 21 1.344 0.3875
##
## P value adjustment: tukey method for comparing a family of 3 estimates
### Final Data Frame
#write.csv(df, file = "tidy_mimic_experiment.csv")
### use df as final dataframe since it has all required data.
### First check if temp sig varies based off handheld logger.
df <- read.csv("tidy_mimic_2023.csv")
supp1.1 <- ggplot(df, aes(x = microsite, y = mean_ambient_temp, fill = microsite)) +
geom_boxplot() + stat_summary(fun = mean, geom = "point", shape = 18, size = 2, fill = "black", position = position_dodge(width = 0.75 )) +
labs(
x = "Microsite",
y = "Ambient Temperature (°C)") + theme_classic() + labs(tag = "A", x = NULL) +
scale_fill_manual(values = c("mimic" = "#a6cee3", "open" = "#1f78b4", "shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) + theme(legend.position = "none") + theme(aspect.ratio = 1)
supp1.1
ambient_anova_result <- aov(mean_ambient_temp ~ microsite, data = df) ### Temp from handheld not significant
print(summary(ambient_anova_result))
## Df Sum Sq Mean Sq F value Pr(>F)
## microsite 2 1.4 0.700 0.208 0.813
## Residuals 55 185.2 3.367
### Check Ground temp
supp1.2 <- ggplot(df, aes(x = microsite, y = mean_ground_temp, fill = microsite)) +
geom_boxplot() + stat_summary(fun = mean, geom = "point", shape = 18, size = 2, position = position_dodge(width = 0.75 )) + labs(
x = "Microsite",
y = "Ground Temperature (°C)") + theme_classic() + labs(tag = "B") +
scale_fill_manual(values = c("mimic" = "#a6cee3", "open" = "#1f78b4", "shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) + theme(legend.position = "none") + theme(aspect.ratio = 1)
supp1.2
ground_anova_result <- aov(mean_ground_temp ~ microsite, data = df) ### Ground temp significantly varied
print(summary(ground_anova_result))
## Df Sum Sq Mean Sq F value Pr(>F)
## microsite 2 1050 525.2 26.56 8.46e-09 ***
## Residuals 55 1088 19.8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ground_emmeans_result <- emmeans(ground_anova_result, pairwise ~ microsite)
print(ground_emmeans_result)
## $emmeans
## microsite emmean SE df lower.CL upper.CL
## mimic 34.5 0.994 55 32.5 36.4
## open 34.9 0.826 55 33.3 36.6
## shrub 23.0 1.482 55 20.0 26.0
##
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## mimic - open -0.496 1.29 55 -0.384 0.9222
## mimic - shrub 11.444 1.78 55 6.412 <.0001
## open - shrub 11.940 1.70 55 7.037 <.0001
##
## P value adjustment: tukey method for comparing a family of 3 estimates
### Now Humidity
ggplot(df, aes(x = microsite, y = mean_rh)) +
geom_boxplot() +
labs(
x = "Factor",
y = "Relative Humidity") + theme_classic()
rh_anova_result <- aov(mean_rh ~ microsite, data = df) ### Ground temp significantly varied
print(summary(rh_anova_result))
## Df Sum Sq Mean Sq F value Pr(>F)
## microsite 2 10.9 5.46 0.551 0.58
## Residuals 55 545.1 9.91
Supp1 <- (supp1.1 / supp1.2) + plot_layout(guides = 'collect')
print(Supp1)
### Final findings from temp data so far. Loggers indicate that mimics were cooler than open areas and not significantly different from shrubs. Handheld ambient indicate no significance. Handheld ground indicates that the temperature under shrubs is cooler than mimic and open, with no signifiacne between open and mimics. Finally RH is not signicant across any of the factors.
### Now we test abundance with the factors.
# df now has factor = microsite and site_code has been edited to match regional.csv
library(AER) ### For testing overdispersion
## Loading required package: car
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
## The following object is masked from 'package:purrr':
##
## some
## Loading required package: lmtest
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: survival
plot2.1 <- ggplot(df, aes(x = microsite, y = abundance, fill = microsite)) +
geom_boxplot() + stat_summary(fun = mean, geom = "point", shape = 18, size = 2, position = position_dodge(width = 0.75 )) +
labs(
x = "Microsite",
y = "Abundance") + theme_classic() + labs(tag = "A", x = NULL)+
scale_fill_manual(values = c("mimic" = "#a6cee3", "open" = "#1f78b4", "shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) + theme(aspect.ratio = 0.7) + theme(legend.position = "none") + theme(legend.text = element_text(size = 8))
plot2.1
hist(df$abundance, main = "Histogram of Response Variable") ### data is skewed.
shapiro.test(df$abundance)
##
## Shapiro-Wilk normality test
##
## data: df$abundance
## W = 0.56434, p-value = 7.41e-12
model1 <- glm(abundance~microsite + mean_ambient_temp + shrub_density, family = "poisson", data = df)
model1
##
## Call: glm(formula = abundance ~ microsite + mean_ambient_temp + shrub_density,
## family = "poisson", data = df)
##
## Coefficients:
## (Intercept) micrositeopen micrositeshrub mean_ambient_temp
## 3.79435 -0.57841 -0.10553 0.03792
## shrub_density
## -0.11226
##
## Degrees of Freedom: 57 Total (i.e. Null); 53 Residual
## Null Deviance: 4372
## Residual Deviance: 3065 AIC: 3305
anova(model1, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: abundance
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 4372.1
## microsite 2 241.77 55 4130.4 < 2.2e-16 ***
## mean_ambient_temp 1 14.07 54 4116.3 0.0001763 ***
## shrub_density 1 1051.79 53 3064.5 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
abundance_emmeans_result <- emmeans(model1, pairwise ~ microsite)
print(abundance_emmeans_result)
## $emmeans
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 3.48 0.0418 Inf 3.40 3.57
## open 2.91 0.0437 Inf 2.82 2.99
## shrub 3.38 0.0650 Inf 3.25 3.51
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## mimic - open 0.578 0.0473 Inf 12.239 <.0001
## mimic - shrub 0.106 0.0769 Inf 1.373 0.3553
## open - shrub -0.473 0.0779 Inf -6.069 <.0001
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
dispersion_test_abundance <- dispersiontest(model1)
print(dispersion_test_abundance)
##
## Overdispersion test
##
## data: model1
## z = 2.1079, p-value = 0.01752
## alternative hypothesis: true dispersion is greater than 1
## sample estimates:
## dispersion
## 80.94488
### Richness Data
plot2.2 <- ggplot(df, aes(x = microsite, y = richness, fill = microsite)) +
geom_boxplot() + stat_summary(fun = mean, geom = "point", shape = 18, size = 2, position = position_dodge(width = 0.75 )) +
labs(
x = "Microsite",
y = "Richness") + theme_classic() + labs(tag = "B", x = NULL)+
scale_fill_manual(values = c("mimic" = "#a6cee3", "open" = "#1f78b4", "shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) + theme(aspect.ratio = 0.7) + theme(legend.position = "none") + theme(legend.text = element_text(size = 8))
plot2.2
hist(df$richness, main = "Histogram of Response Variable") ### data is skewed.
shapiro.test(df$richness)
##
## Shapiro-Wilk normality test
##
## data: df$richness
## W = 0.93675, p-value = 0.004686
model2 <- glm(richness~microsite + mean_ambient_temp + shrub_density, family = "poisson", data = df)
model2
##
## Call: glm(formula = richness ~ microsite + mean_ambient_temp + shrub_density,
## family = "poisson", data = df)
##
## Coefficients:
## (Intercept) micrositeopen micrositeshrub mean_ambient_temp
## 0.68567 -0.51958 -0.46319 0.04118
## shrub_density
## -0.02223
##
## Degrees of Freedom: 57 Total (i.e. Null); 53 Residual
## Null Deviance: 93.5
## Residual Deviance: 73.72 AIC: 238.7
anova(model2, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: richness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 93.497
## microsite 2 12.1743 55 81.322 0.002272 **
## mean_ambient_temp 1 1.8426 54 79.480 0.174641
## shrub_density 1 5.7622 53 73.718 0.016374 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
richness_emmeans_result <- emmeans(model2, pairwise ~ microsite)
print(richness_emmeans_result)
## $emmeans
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 1.398 0.112 Inf 1.179 1.62
## open 0.879 0.119 Inf 0.645 1.11
## shrub 0.935 0.214 Inf 0.516 1.35
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## mimic - open 0.5196 0.161 Inf 3.226 0.0036
## mimic - shrub 0.4632 0.243 Inf 1.903 0.1379
## open - shrub -0.0564 0.246 Inf -0.229 0.9714
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
dispersion_test_richness <- dispersiontest(model2)
print(dispersion_test_richness) ### Non sig p-value so should be good
##
## Overdispersion test
##
## data: model2
## z = 0.78055, p-value = 0.2175
## alternative hypothesis: true dispersion is greater than 1
## sample estimates:
## dispersion
## 1.119264
### Evenness
plot2.3 <- ggplot(df, aes(x = microsite, y = evenness, fill = microsite )) +
geom_boxplot() + stat_summary(fun = mean, geom = "point", shape = 18, size = 2, position = position_dodge(width = 0.75 )) +
labs(
x = "Microsite",
y = "Evenness") + theme_classic() + labs(tag = "C") +
scale_fill_manual(values = c("mimic" = "#a6cee3", "open" = "#1f78b4", "shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) + theme(aspect.ratio = 0.7) + theme(legend.position = "none") + theme(legend.text = element_text(size = 8))
plot2.3
hist(df$evenness, main = "Histogram of Response Variable") ### data is skewed.
shapiro.test(df$evenness)
##
## Shapiro-Wilk normality test
##
## data: df$evenness
## W = 0.91115, p-value = 0.0004352
model3 <- glm(evenness~microsite + mean_ambient_temp + shrub_density, family = "poisson", data = df)
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
model3
##
## Call: glm(formula = evenness ~ microsite + mean_ambient_temp + shrub_density,
## family = "poisson", data = df)
##
## Coefficients:
## (Intercept) micrositeopen micrositeshrub mean_ambient_temp
## -0.445437 -0.545571 -1.070068 0.010256
## shrub_density
## 0.002026
##
## Degrees of Freedom: 57 Total (i.e. Null); 53 Residual
## Null Deviance: 29.23
## Residual Deviance: 25.21 AIC: Inf
anova(model3, test = "Chisq")
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: evenness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 29.230
## microsite 2 4.0028 55 25.227 0.1351
## mean_ambient_temp 1 0.0103 54 25.216 0.9190
## shrub_density 1 0.0106 53 25.206 0.9181
evenness_emmeans_result <- emmeans(model3, pairwise ~ microsite)
print(evenness_emmeans_result)
## $emmeans
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic -0.188 0.247 Inf -0.672 0.2958
## open -0.734 0.268 Inf -1.259 -0.2083
## shrub -1.258 0.626 Inf -2.484 -0.0322
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## mimic - open 0.546 0.365 Inf 1.495 0.2935
## mimic - shrub 1.070 0.674 Inf 1.588 0.2509
## open - shrub 0.524 0.680 Inf 0.771 0.7209
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
dispersion_test_evenness <- dispersiontest(model3)
print(dispersion_test_evenness)
##
## Overdispersion test
##
## data: model3
## z = -6.1775, p-value = 1
## alternative hypothesis: true dispersion is greater than 1
## sample estimates:
## dispersion
## 0.3522632
Fig2 <- (plot2.1 / plot2.2 / plot2.3) + plot_layout(guides = 'collect')
print(Fig2)
### Abundance v Shrub Density (Shrub density on its own is significant but not between microsites)
model7 <- glm(abundance~microsite*shrub_density, data = df) ### It is NOT poisson for this distribution! It is gaussian!
model7 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = abundance ~ microsite * shrub_density, data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 94.682 -52.430
## micrositeshrub shrub_density
## -39.787 -4.256
## micrositeopen:shrub_density micrositeshrub:shrub_density
## 2.792 2.059
##
## Degrees of Freedom: 57 Total (i.e. Null); 52 Residual
## Null Deviance: 256400
## Residual Deviance: 208400 AIC: 653.4
anova(model7, test = "Chisq")
## Analysis of Deviance Table
##
## Model: gaussian, link: identity
##
## Response: abundance
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 256391
## microsite 2 9191.4 55 247199 0.317706
## shrub_density 1 31068.7 54 216131 0.005366 **
## microsite:shrub_density 2 7715.0 52 208416 0.381954
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
abundance_density <- ggplot(df, aes(shrub_density, abundance, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Shrub Density", y = "Abundance") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "A", x = NULL) + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
abundance_density
## `geom_smooth()` using formula = 'y ~ x'
### richness v density (Again, significant shrub density but not the interactio with microsite!)
model8 <- glm(richness~microsite*shrub_density, data = df) ### It is NOT poisson for this distribution! It is gaussian!
model8
##
## Call: glm(formula = richness ~ microsite * shrub_density, data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 5.05346 -1.99806
## micrositeshrub shrub_density
## -2.18201 -0.08799
## micrositeopen:shrub_density micrositeshrub:shrub_density
## 0.03263 0.05514
##
## Degrees of Freedom: 57 Total (i.e. Null); 52 Residual
## Null Deviance: 251.7
## Residual Deviance: 191.8 AIC: 248
anova(model8, test = "Chisq")
## Analysis of Deviance Table
##
## Model: gaussian, link: identity
##
## Response: richness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 251.72
## microsite 2 39.061 55 212.66 0.005015 **
## shrub_density 1 19.474 54 193.19 0.021571 *
## microsite:shrub_density 2 1.404 52 191.78 0.826641
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
richness_density <- ggplot(df, aes(shrub_density, richness, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Shrub Density", y = "Richness") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "B", x = NULL) + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
richness_density
## `geom_smooth()` using formula = 'y ~ x'
### Evenness v density (Density is not significant for evenness)
model9 <- glm(evenness~microsite*shrub_density, data = df) ### It is NOT poisson for this distribution! It is gaussian!
model9
##
## Call: glm(formula = evenness ~ microsite * shrub_density, data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 0.892735 -0.452855
## micrositeshrub shrub_density
## -1.025832 -0.006926
## micrositeopen:shrub_density micrositeshrub:shrub_density
## 0.010858 0.039157
##
## Degrees of Freedom: 57 Total (i.e. Null); 52 Residual
## Null Deviance: 12.57
## Residual Deviance: 9.896 AIC: 76.04
anova(model9, test = "Chisq")
## Analysis of Deviance Table
##
## Model: gaussian, link: identity
##
## Response: evenness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 12.5653
## microsite 2 2.26450 55 10.3008 0.002607 **
## shrub_density 1 0.00506 54 10.2957 0.870414
## microsite:shrub_density 2 0.39961 52 9.8961 0.349977
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
evenness_density <- ggplot(df, aes(shrub_density, evenness, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Shrub Density per 20m radius", y = "Evenness") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "C") + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
evenness_density
## `geom_smooth()` using formula = 'y ~ x'
density <- (abundance_density/richness_density/evenness_density) + plot_layout(guides = 'collect') + theme(legend.position = 'right') + labs(color = "Microsite")
print(density)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
# Abundance v Ambient temp (No significance)
model4 <- glm(abundance~microsite*mean_ambient_temp + shrub_density, family = "poisson", data = df)
model4 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = abundance ~ microsite * mean_ambient_temp + shrub_density,
## family = "poisson", data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 7.9117 -12.3693
## micrositeshrub mean_ambient_temp
## -23.2666 -0.1471
## shrub_density micrositeopen:mean_ambient_temp
## -0.1053 0.5064
## micrositeshrub:mean_ambient_temp
## 0.9781
##
## Degrees of Freedom: 57 Total (i.e. Null); 51 Residual
## Null Deviance: 4372
## Residual Deviance: 2363 AIC: 2607
anova(model4, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: abundance
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 4372.1
## microsite 2 241.77 55 4130.4 < 2.2e-16 ***
## mean_ambient_temp 1 14.07 54 4116.3 0.0001763 ***
## shrub_density 1 1051.79 53 3064.5 < 2.2e-16 ***
## microsite:mean_ambient_temp 2 701.77 51 2362.7 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(model4, pairwise~microsite|mean_ambient_temp)
## $emmeans
## mean_ambient_temp = 23:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 3.42 0.0443 Inf 3.33 3.51
## open 2.70 0.0502 Inf 2.60 2.79
## shrub 2.65 0.1129 Inf 2.42 2.87
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ambient_temp = 23:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.7237 0.0556 Inf 13.018 <.0001
## mimic - shrub 0.7734 0.1224 Inf 6.317 <.0001
## open - shrub 0.0498 0.1246 Inf 0.400 0.9157
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
abundance_ambient <- ggplot(df, aes(mean_ambient_temp, abundance, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Ambient Temperature (°C)", y = "Abundance") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "A") + labs(x = NULL) + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
abundance_ambient
## `geom_smooth()` using formula = 'y ~ x'
### Richness v Ambient temperature
model5 <- glm(richness~microsite*mean_ambient_temp + shrub_density, family = "poisson", data = df)
model5 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = richness ~ microsite * mean_ambient_temp + shrub_density,
## family = "poisson", data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 1.723809 -2.551620
## micrositeshrub mean_ambient_temp
## -10.862741 -0.004581
## shrub_density micrositeopen:mean_ambient_temp
## -0.020931 0.087898
## micrositeshrub:mean_ambient_temp
## 0.443273
##
## Degrees of Freedom: 57 Total (i.e. Null); 51 Residual
## Null Deviance: 93.5
## Residual Deviance: 66.48 AIC: 235.4
anova(model5, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: richness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 93.497
## microsite 2 12.1743 55 81.322 0.002272 **
## mean_ambient_temp 1 1.8426 54 79.480 0.174641
## shrub_density 1 5.7622 53 73.718 0.016374 *
## microsite:mean_ambient_temp 2 7.2411 51 66.476 0.026768 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(model5, pairwise~microsite|mean_ambient_temp) ### Higher richness at mimic microsites than shrub and open sites
## $emmeans
## mean_ambient_temp = 23:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 1.398 0.112 Inf 1.178 1.62
## open 0.868 0.122 Inf 0.629 1.11
## shrub 0.729 0.256 Inf 0.227 1.23
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ambient_temp = 23:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.530 0.164 Inf 3.243 0.0034
## mimic - shrub 0.669 0.282 Inf 2.375 0.0462
## open - shrub 0.139 0.285 Inf 0.487 0.8775
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
richness_ambient <- ggplot(df, aes(mean_ambient_temp, richness, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Ambient Temperature (°C)", y = "Richness") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "B", x = NULL) + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
richness_ambient
## `geom_smooth()` using formula = 'y ~ x'
### Evenness v ambient temperature (No significance)
library(patchwork)
model6 <- glm(evenness~microsite*mean_ambient_temp + shrub_density, family = "poisson", data = df)
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
model6 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = evenness ~ microsite * mean_ambient_temp + shrub_density,
## family = "poisson", data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 0.274827 -2.296530
## micrositeshrub mean_ambient_temp
## -8.966668 -0.021756
## shrub_density micrositeopen:mean_ambient_temp
## 0.002833 0.076108
## micrositeshrub:mean_ambient_temp
## 0.338872
##
## Degrees of Freedom: 57 Total (i.e. Null); 51 Residual
## Null Deviance: 29.23
## Residual Deviance: 24.67 AIC: Inf
anova(model6, test = "Chisq")
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: evenness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 29.230
## microsite 2 4.0028 55 25.227 0.1351
## mean_ambient_temp 1 0.0103 54 25.216 0.9190
## shrub_density 1 0.0106 53 25.206 0.9181
## microsite:mean_ambient_temp 2 0.5341 51 24.672 0.7657
evenness_ambient <- ggplot(df, aes(mean_ambient_temp, evenness, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Ambient Temperature (°C)", y = "Evenness") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "C") + theme(aspect.ratio = 0.8)
evenness_ambient
## `geom_smooth()` using formula = 'y ~ x'
ambient <- (abundance_ambient / richness_ambient / evenness_ambient) +
plot_layout(guides = 'collect') +
theme(legend.position = 'right') + labs(color = "Microsite")
print(ambient)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
### Abundance v ground temp (Need second opinion on this one!)
model10 <- glm(abundance~microsite*mean_ground_temp, family = poisson, data = df)
model10
##
## Call: glm(formula = abundance ~ microsite * mean_ground_temp, family = poisson,
## data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 2.11764 0.12080
## micrositeshrub mean_ground_temp
## 3.64664 0.05299
## micrositeopen:mean_ground_temp micrositeshrub:mean_ground_temp
## -0.02285 -0.16287
##
## Degrees of Freedom: 57 Total (i.e. Null); 52 Residual
## Null Deviance: 4372
## Residual Deviance: 4033 AIC: 4276
anova(model10, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: abundance
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 4372.1
## microsite 2 241.766 55 4130.4 < 2.2e-16 ***
## mean_ground_temp 1 61.043 54 4069.3 5.585e-15 ***
## microsite:mean_ground_temp 2 35.921 52 4033.4 1.585e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(model10, pairwise~microsite|mean_ground_temp)
## $emmeans
## mean_ground_temp = 32.9:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 3.86 0.0358 Inf 3.79 3.93
## open 3.23 0.0421 Inf 3.15 3.31
## shrub 2.15 0.2886 Inf 1.58 2.71
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ground_temp = 32.9:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.631 0.0553 Inf 11.425 <.0001
## mimic - shrub 1.716 0.2908 Inf 5.899 <.0001
## open - shrub 1.084 0.2916 Inf 3.717 0.0006
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
abundance_ground <- ggplot(df, aes(mean_ground_temp, abundance, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Ground Temperature (°C)", y = "Abundance") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5),legend.title = element_blank(), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "A", x = NULL) + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
abundance_ground
## `geom_smooth()` using formula = 'y ~ x'
model11 <- glm(richness~microsite*mean_ground_temp, family = poisson, data = df)
model11
##
## Call: glm(formula = richness ~ microsite * mean_ground_temp, family = poisson,
## data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## 0.6908803 -0.5632701
## micrositeshrub mean_ground_temp
## 1.2458992 0.0214299
## micrositeopen:mean_ground_temp micrositeshrub:mean_ground_temp
## 0.0008181 -0.0670169
##
## Degrees of Freedom: 57 Total (i.e. Null); 52 Residual
## Null Deviance: 93.5
## Residual Deviance: 79.5 AIC: 246.5
anova(model11, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: richness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 93.497
## microsite 2 12.1743 55 81.322 0.002272 **
## mean_ground_temp 1 1.2781 54 80.044 0.258258
## microsite:mean_ground_temp 2 0.5461 52 79.498 0.761073
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(model11, pairwise~microsite|mean_ground_temp)
## $emmeans
## mean_ground_temp = 32.9:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 1.396 0.118 Inf 1.164 1.63
## open 0.860 0.137 Inf 0.592 1.13
## shrub 0.436 0.930 Inf -1.386 2.26
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ground_temp = 32.9:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.536 0.181 Inf 2.964 0.0085
## mimic - shrub 0.961 0.937 Inf 1.025 0.5611
## open - shrub 0.424 0.940 Inf 0.451 0.8938
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
richness_ground <- ggplot(df, aes(mean_ground_temp, richness, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Ground Temperature (°C)", y = "Richness") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "B", x = NULL) + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
richness_ground
## `geom_smooth()` using formula = 'y ~ x'
### Evenness v ground temp
model12 <- glm(evenness~microsite*mean_ground_temp, family = poisson, data = df)
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
model12
##
## Call: glm(formula = evenness ~ microsite * mean_ground_temp, family = poisson,
## data = df)
##
## Coefficients:
## (Intercept) micrositeopen
## -0.787014 -0.319166
## micrositeshrub mean_ground_temp
## -0.291376 0.017169
## micrositeopen:mean_ground_temp micrositeshrub:mean_ground_temp
## -0.006513 -0.024726
##
## Degrees of Freedom: 57 Total (i.e. Null); 52 Residual
## Null Deviance: 29.23
## Residual Deviance: 25.08 AIC: Inf
anova(model12, test = "Chisq")
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: evenness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 29.230
## microsite 2 4.0028 55 25.227 0.1351
## mean_ground_temp 1 0.1375 54 25.089 0.7107
## microsite:mean_ground_temp 2 0.0134 52 25.076 0.9933
evenness_ground <- ggplot(df, aes(mean_ground_temp, evenness, color = microsite)) +
geom_point(size = 0.5) +
scale_color_brewer(palette = "Paired") +
labs(x = "Ground Temperature (°C)", y = "Evenness") + theme_classic() + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 10)) +
geom_smooth(method = lm, se = TRUE) + labs(tag = "C") + theme(legend.position = "none") + theme(aspect.ratio = 0.8)
evenness_ground
## `geom_smooth()` using formula = 'y ~ x'
combined_plot <- (abundance_ground / richness_ground / evenness_ground) +
plot_layout(guides = 'collect') +
theme(legend.position = 'right') + labs(color = "Microsite")
print(combined_plot)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
### Maps
library(maps)
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
library(ggmap)
## ℹ Google's Terms of Service: <https://mapsplatform.google.com>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
library(ggplot2)
# Set your Google Maps API key
api_key <- "AIzaSyBWSInlcZQ9hnFVEdCcZqD94IgOl95QhIs"
register_google(key = api_key)
# Specify the bounding box for the map with names
bounding_box <- c(left = -119.4, bottom = 34, right = -119.7, top = 36)
# Option 1
my_map_1 <- get_map(location = bounding_box, maptype = "terrain", source = "google", zoom = 9)
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35,-119.55&zoom=9&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
map1 <- ggmap(my_map_1) +
geom_point(data = site, aes(x = long, y = lat, color = "black"), size = 3, shape = 16) +
labs(title = "Map with Data Points")
map1
# Option 2
my_map_2 <- get_map(location = bounding_box, maptype = "roadmap", source = "google", zoom = 11)
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35,-119.55&zoom=11&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx>
ggmap(my_map_2) +
geom_point(data = site, aes(x = long, y = lat, color = "black"), size = 3, shape = 16) +
labs(title = "Map with Data Points")
# Option 3
my_map_3 <- get_map(location = bounding_box, maptype = "hybrid", source = "google", zoom = 11)
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35,-119.55&zoom=11&size=640x640&scale=2&maptype=hybrid&language=en-EN&key=xxx>
ggmap(my_map_3) +
geom_point(data = site, aes(x = long, y = lat, color = "black"), size = 3, shape = 16) +
labs(title = "Map with Data Points")
# Option 4
my_map_4 <- get_map(location = bounding_box, maptype = "terrain", source = "google", zoom = 8)
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35,-119.55&zoom=8&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
figure_1 <- ggmap(my_map_4) +
geom_point(data = site, aes(x = long, y = lat), color = "black", size = 2, shape = 16) +
labs(x = "Longitude", y = "Latitude")
figure_1
my_map_5 <- get_map(location = bounding_box, maptype = "terrain", source = "google", zoom = 11)
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=35,-119.55&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
microsite <- read.csv("Chpt5_Site_Data.csv")
figure_2 <- ggmap(my_map_5) +
geom_point(data = microsite, aes(x = long, y = lat), size = 3, shape = 16) + scale_colour_brewer(palette = "Paired")+
labs(x = "Longitude", y = "Latitude")
figure_2
temp <- ggplot(df, aes(x = site_code, y = mean_ambient_temp, fill = microsite)) +
geom_boxplot() + stat_summary(fun = mean, geom = "point", shape = 18, size = 2, position = position_dodge(width = 0.75 )) + labs(
x = "Site",
y = "Ambient Temperature (°C)", fill = "Microsite") + theme_classic() +
scale_fill_manual(values = c("mimic" = "#a6cee3", "open" = "#1f78b4", "shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 6)) + theme(aspect.ratio = 1)
temp
p <- glm(mean_ambient_temp~microsite*site_code, family = "gaussian",data = df)
p
##
## Call: glm(formula = mean_ambient_temp ~ microsite * site_code, family = "gaussian",
## data = df)
##
## Coefficients:
## (Intercept)
## 20.9047
## micrositeopen
## 1.2207
## micrositeshrub
## 0.8149
## site_codeCarrizo_soda_shrub
## 5.4053
## site_codeCuyama_1
## 0.9247
## site_codeCuyama_3
## 1.1827
## micrositeopen:site_codeCarrizo_soda_shrub
## -2.3673
## micrositeshrub:site_codeCarrizo_soda_shrub
## -2.6460
## micrositeopen:site_codeCuyama_1
## -0.6800
## micrositeshrub:site_codeCuyama_1
## -0.7176
## micrositeopen:site_codeCuyama_3
## -0.8897
## micrositeshrub:site_codeCuyama_3
## NA
##
## Degrees of Freedom: 57 Total (i.e. Null); 47 Residual
## Null Deviance: 186.6
## Residual Deviance: 41.63 AIC: 169.4
anova(p, test = "Chisq")
## Analysis of Deviance Table
##
## Model: gaussian, link: identity
##
## Response: mean_ambient_temp
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 57 186.572
## microsite 2 1.399 55 185.173 0.45387
## site_code 3 131.274 52 53.899 < 2e-16 ***
## microsite:site_code 5 12.269 47 41.630 0.01658 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em1 <- emmeans(p, pairwise~microsite|site_code)
em1
## $emmeans
## site_code = Carrizo_soda_open:
## microsite emmean SE df lower.CL upper.CL
## mimic 20.9 0.421 47 20.1 21.8
## open 22.1 0.421 47 21.3 23.0
## shrub nonEst NA NA NA NA
##
## site_code = Carrizo_soda_shrub:
## microsite emmean SE df lower.CL upper.CL
## mimic 26.3 0.421 47 25.5 27.2
## open 25.2 0.333 47 24.5 25.8
## shrub 24.5 0.543 47 23.4 25.6
##
## site_code = Cuyama_1:
## microsite emmean SE df lower.CL upper.CL
## mimic 21.8 0.421 47 21.0 22.7
## open 22.4 0.333 47 21.7 23.0
## shrub 21.9 0.543 47 20.8 23.0
##
## site_code = Cuyama_3:
## microsite emmean SE df lower.CL upper.CL
## mimic 22.1 0.421 47 21.2 22.9
## open 22.4 0.333 47 21.7 23.1
## shrub 22.9 0.543 47 21.8 24.0
##
## Confidence level used: 0.95
##
## $contrasts
## site_code = Carrizo_soda_open:
## contrast estimate SE df t.ratio p.value
## mimic - open -1.2207 0.595 47 -2.051 0.1114
## mimic - shrub nonEst NA NA NA NA
## open - shrub nonEst NA NA NA NA
##
## site_code = Carrizo_soda_shrub:
## contrast estimate SE df t.ratio p.value
## mimic - open 1.1467 0.537 47 2.137 0.0932
## mimic - shrub 1.8311 0.687 47 2.664 0.0279
## open - shrub 0.6844 0.637 47 1.074 0.5346
##
## site_code = Cuyama_1:
## contrast estimate SE df t.ratio p.value
## mimic - open -0.5407 0.537 47 -1.008 0.5757
## mimic - shrub -0.0973 0.687 47 -0.142 0.9890
## open - shrub 0.4433 0.637 47 0.696 0.7671
##
## site_code = Cuyama_3:
## contrast estimate SE df t.ratio p.value
## mimic - open -0.3310 0.537 47 -0.617 0.8116
## mimic - shrub -0.8149 0.687 47 -1.186 0.4675
## open - shrub -0.4839 0.637 47 -0.759 0.7294
##
## P value adjustment: tukey method for comparing a family of 3 estimates
em2 <- emmeans(p, pairwise~site_code|microsite)
em2
## $emmeans
## microsite = mimic:
## site_code emmean SE df lower.CL upper.CL
## Carrizo_soda_open 20.9 0.421 47 20.1 21.8
## Carrizo_soda_shrub 26.3 0.421 47 25.5 27.2
## Cuyama_1 21.8 0.421 47 21.0 22.7
## Cuyama_3 22.1 0.421 47 21.2 22.9
##
## microsite = open:
## site_code emmean SE df lower.CL upper.CL
## Carrizo_soda_open 22.1 0.421 47 21.3 23.0
## Carrizo_soda_shrub 25.2 0.333 47 24.5 25.8
## Cuyama_1 22.4 0.333 47 21.7 23.0
## Cuyama_3 22.4 0.333 47 21.7 23.1
##
## microsite = shrub:
## site_code emmean SE df lower.CL upper.CL
## Carrizo_soda_open nonEst NA NA NA NA
## Carrizo_soda_shrub 24.5 0.543 47 23.4 25.6
## Cuyama_1 21.9 0.543 47 20.8 23.0
## Cuyama_3 22.9 0.543 47 21.8 24.0
##
## Confidence level used: 0.95
##
## $contrasts
## microsite = mimic:
## contrast estimate SE df t.ratio p.value
## Carrizo_soda_open - Carrizo_soda_shrub -5.4053 0.595 47 -9.081 <.0001
## Carrizo_soda_open - Cuyama_1 -0.9247 0.595 47 -1.553 0.4147
## Carrizo_soda_open - Cuyama_3 -1.1827 0.595 47 -1.987 0.2075
## Carrizo_soda_shrub - Cuyama_1 4.4807 0.595 47 7.528 <.0001
## Carrizo_soda_shrub - Cuyama_3 4.2227 0.595 47 7.094 <.0001
## Cuyama_1 - Cuyama_3 -0.2580 0.595 47 -0.433 0.9724
##
## microsite = open:
## contrast estimate SE df t.ratio p.value
## Carrizo_soda_open - Carrizo_soda_shrub -3.0380 0.537 47 -5.662 <.0001
## Carrizo_soda_open - Cuyama_1 -0.2447 0.537 47 -0.456 0.9681
## Carrizo_soda_open - Cuyama_3 -0.2930 0.537 47 -0.546 0.9471
## Carrizo_soda_shrub - Cuyama_1 2.7933 0.471 47 5.936 <.0001
## Carrizo_soda_shrub - Cuyama_3 2.7450 0.471 47 5.833 <.0001
## Cuyama_1 - Cuyama_3 -0.0483 0.471 47 -0.103 0.9996
##
## microsite = shrub:
## contrast estimate SE df t.ratio p.value
## Carrizo_soda_open - Carrizo_soda_shrub nonEst NA NA NA NA
## Carrizo_soda_open - Cuyama_1 nonEst NA NA NA NA
## Carrizo_soda_open - Cuyama_3 nonEst NA NA NA NA
## Carrizo_soda_shrub - Cuyama_1 2.5522 0.768 47 3.321 0.0091
## Carrizo_soda_shrub - Cuyama_3 1.5767 0.768 47 2.052 0.1841
## Cuyama_1 - Cuyama_3 -0.9756 0.768 47 -1.270 0.5865
##
## P value adjustment: tukey method for comparing a family of 4 estimates
model4 <- glm(abundance~microsite*mean_ambient_temp*mean_ground_temp + shrub_density, family = "poisson", data = df)
model4 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = abundance ~ microsite * mean_ambient_temp * mean_ground_temp +
## shrub_density, family = "poisson", data = df)
##
## Coefficients:
## (Intercept)
## 2.263e+00
## micrositeopen
## -1.586e+02
## micrositeshrub
## 1.206e+02
## mean_ambient_temp
## -8.800e-03
## mean_ground_temp
## 1.718e-01
## shrub_density
## -1.177e-01
## micrositeopen:mean_ambient_temp
## 6.972e+00
## micrositeshrub:mean_ambient_temp
## -5.315e+00
## micrositeopen:mean_ground_temp
## 3.926e+00
## micrositeshrub:mean_ground_temp
## -6.570e+00
## mean_ambient_temp:mean_ground_temp
## -4.394e-03
## micrositeopen:mean_ambient_temp:mean_ground_temp
## -1.735e-01
## micrositeshrub:mean_ambient_temp:mean_ground_temp
## 2.890e-01
##
## Degrees of Freedom: 57 Total (i.e. Null); 45 Residual
## Null Deviance: 4372
## Residual Deviance: 1629 AIC: 1886
anova(model4, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: abundance
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev
## NULL 57 4372.1
## microsite 2 241.77 55 4130.4
## mean_ambient_temp 1 14.07 54 4116.3
## mean_ground_temp 1 47.39 53 4068.9
## shrub_density 1 1005.41 52 3063.5
## microsite:mean_ambient_temp 2 701.70 50 2361.8
## microsite:mean_ground_temp 2 248.43 48 2113.4
## mean_ambient_temp:mean_ground_temp 1 171.67 47 1941.7
## microsite:mean_ambient_temp:mean_ground_temp 2 312.43 45 1629.3
## Pr(>Chi)
## NULL
## microsite < 2.2e-16 ***
## mean_ambient_temp 0.0001763 ***
## mean_ground_temp 5.812e-12 ***
## shrub_density < 2.2e-16 ***
## microsite:mean_ambient_temp < 2.2e-16 ***
## microsite:mean_ground_temp < 2.2e-16 ***
## mean_ambient_temp:mean_ground_temp < 2.2e-16 ***
## microsite:mean_ambient_temp:mean_ground_temp < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(model4, pairwise~microsite|mean_ambient_temp)
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
## mean_ambient_temp = 23:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 3.15 0.0600 Inf 3.03 3.27
## open 2.85 0.0572 Inf 2.74 2.96
## shrub 4.03 0.5351 Inf 2.98 5.08
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ambient_temp = 23:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.302 0.0739 Inf 4.079 0.0001
## mimic - shrub -0.881 0.5409 Inf -1.628 0.2336
## open - shrub -1.182 0.5398 Inf -2.190 0.0729
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
emmeans(model4, pairwise~microsite|shrub_density)
## $emmeans
## shrub_density = 10.5:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 3.15 0.0600 Inf 3.03 3.27
## open 2.85 0.0572 Inf 2.74 2.96
## shrub 4.03 0.5351 Inf 2.98 5.08
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## shrub_density = 10.5:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.302 0.0739 Inf 4.079 0.0001
## mimic - shrub -0.881 0.5409 Inf -1.628 0.2336
## open - shrub -1.182 0.5398 Inf -2.190 0.0729
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
model5 <- glm(richness~microsite*mean_ambient_temp*mean_ground_temp + shrub_density, family = "poisson", data = df)
model5 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = richness ~ microsite * mean_ambient_temp * mean_ground_temp +
## shrub_density, family = "poisson", data = df)
##
## Coefficients:
## (Intercept)
## -5.024360
## micrositeopen
## -14.017757
## micrositeshrub
## -45.737502
## mean_ambient_temp
## 0.254525
## mean_ground_temp
## 0.196127
## shrub_density
## -0.021113
## micrositeopen:mean_ambient_temp
## 0.615400
## micrositeshrub:mean_ambient_temp
## 2.004582
## micrositeopen:mean_ground_temp
## 0.297205
## micrositeshrub:mean_ground_temp
## 1.676051
## mean_ambient_temp:mean_ground_temp
## -0.007501
## micrositeopen:mean_ambient_temp:mean_ground_temp
## -0.013726
## micrositeshrub:mean_ambient_temp:mean_ground_temp
## -0.074432
##
## Degrees of Freedom: 57 Total (i.e. Null); 45 Residual
## Null Deviance: 93.5
## Residual Deviance: 63.96 AIC: 244.9
anova(model5, test = "Chisq")
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: richness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev
## NULL 57 93.497
## microsite 2 12.1743 55 81.322
## mean_ambient_temp 1 1.8426 54 79.480
## mean_ground_temp 1 0.4189 53 79.061
## shrub_density 1 5.6726 52 73.388
## microsite:mean_ambient_temp 2 7.6318 50 65.756
## microsite:mean_ground_temp 2 0.3744 48 65.382
## mean_ambient_temp:mean_ground_temp 1 0.9819 47 64.400
## microsite:mean_ambient_temp:mean_ground_temp 2 0.4398 45 63.960
## Pr(>Chi)
## NULL
## microsite 0.002272 **
## mean_ambient_temp 0.174641
## mean_ground_temp 0.517478
## shrub_density 0.017232 *
## microsite:mean_ambient_temp 0.022018 *
## microsite:mean_ground_temp 0.829290
## mean_ambient_temp:mean_ground_temp 0.321720
## microsite:mean_ambient_temp:mean_ground_temp 0.802598
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(model5, pairwise~microsite|mean_ambient_temp)
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
## mean_ambient_temp = 23:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 1.385 0.137 Inf 1.116 1.65
## open 0.912 0.143 Inf 0.631 1.19
## shrub 0.572 1.456 Inf -2.282 3.43
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ambient_temp = 23:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.473 0.198 Inf 2.392 0.0442
## mimic - shrub 0.813 1.464 Inf 0.555 0.8439
## open - shrub 0.340 1.463 Inf 0.232 0.9707
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
emmeans(model5, pairwise~microsite|shrub_density)
## $emmeans
## shrub_density = 10.5:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic 1.385 0.137 Inf 1.116 1.65
## open 0.912 0.143 Inf 0.631 1.19
## shrub 0.572 1.456 Inf -2.282 3.43
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## shrub_density = 10.5:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.473 0.198 Inf 2.392 0.0442
## mimic - shrub 0.813 1.464 Inf 0.555 0.8439
## open - shrub 0.340 1.463 Inf 0.232 0.9707
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
model6 <- glm(evenness~microsite*mean_ambient_temp*mean_ground_temp + shrub_density, family = "poisson", data = df)
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
model6 ### Need to run the model this way because the figures show that microsite and temp interaction is not significant.
##
## Call: glm(formula = evenness ~ microsite * mean_ambient_temp * mean_ground_temp +
## shrub_density, family = "poisson", data = df)
##
## Coefficients:
## (Intercept)
## 1.944810
## micrositeopen
## 16.639277
## micrositeshrub
## -80.632468
## mean_ambient_temp
## -0.133752
## mean_ground_temp
## -0.031452
## shrub_density
## 0.004008
## micrositeopen:mean_ambient_temp
## -0.710949
## micrositeshrub:mean_ambient_temp
## 3.522645
## micrositeopen:mean_ground_temp
## -0.522935
## micrositeshrub:mean_ground_temp
## 3.165489
## mean_ambient_temp:mean_ground_temp
## 0.002466
## micrositeopen:mean_ambient_temp:mean_ground_temp
## 0.021623
## micrositeshrub:mean_ambient_temp:mean_ground_temp
## -0.140145
##
## Degrees of Freedom: 57 Total (i.e. Null); 45 Residual
## Null Deviance: 29.23
## Residual Deviance: 24.14 AIC: Inf
anova(model6, test = "Chisq")
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.380957
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.894750
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.045153
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.916350
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.644695
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.348832
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.325083
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.843220
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.578648
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.474139
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.631975
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.203575
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.791702
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.119247
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.485104
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.731271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.193550
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.659872
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.250558
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.374569
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.655243
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.481154
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.223718
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.692421
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.126784
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.949594
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.950271
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.332179
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.781074
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.039721
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.867563
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.011404
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.983088
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.073543
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.450561
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.693147
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.636514
## Warning in dpois(y, mu, log = TRUE): non-integer x = 1.213008
## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: evenness
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev
## NULL 57 29.230
## microsite 2 4.0028 55 25.227
## mean_ambient_temp 1 0.0103 54 25.216
## mean_ground_temp 1 0.1296 53 25.087
## shrub_density 1 0.0098 52 25.077
## microsite:mean_ambient_temp 2 0.5663 50 24.511
## microsite:mean_ground_temp 2 0.0653 48 24.445
## mean_ambient_temp:mean_ground_temp 1 0.0810 47 24.364
## microsite:mean_ambient_temp:mean_ground_temp 2 0.2269 45 24.138
## Pr(>Chi)
## NULL
## microsite 0.1351
## mean_ambient_temp 0.9190
## mean_ground_temp 0.7189
## shrub_density 0.9211
## microsite:mean_ambient_temp 0.7534
## microsite:mean_ground_temp 0.9679
## mean_ambient_temp:mean_ground_temp 0.7759
## microsite:mean_ambient_temp:mean_ground_temp 0.8927
emmeans(model6, pairwise~microsite|mean_ambient_temp)
## NOTE: Results may be misleading due to involvement in interactions
## $emmeans
## mean_ambient_temp = 23:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic -0.257 0.322 Inf -0.887 0.373
## open -0.813 0.341 Inf -1.482 -0.143
## shrub -1.770 4.264 Inf -10.127 6.587
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## mean_ambient_temp = 23:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.555 0.469 Inf 1.184 0.4629
## mimic - shrub 1.512 4.276 Inf 0.354 0.9334
## open - shrub 0.957 4.276 Inf 0.224 0.9728
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
emmeans(model6, pairwise~microsite|shrub_density)
## $emmeans
## shrub_density = 10.5:
## microsite emmean SE df asymp.LCL asymp.UCL
## mimic -0.257 0.322 Inf -0.887 0.373
## open -0.813 0.341 Inf -1.482 -0.143
## shrub -1.770 4.264 Inf -10.127 6.587
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## shrub_density = 10.5:
## contrast estimate SE df z.ratio p.value
## mimic - open 0.555 0.469 Inf 1.184 0.4629
## mimic - shrub 1.512 4.276 Inf 0.354 0.9334
## open - shrub 0.957 4.276 Inf 0.224 0.9728
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 3 estimates
animals <- photo %>% group_by(common_name, scientific_name) %>% summarise(captures = sum(animal_hit))
## `summarise()` has grouped output by 'common_name'. You can override using the
## `.groups` argument.
### RII
### You need to subset the data twice. Once for mimic and once for shrub then rejoin them all.
mimic_open_data <- subset(df, microsite %in% c("mimic", "open")) %>% filter(microsite_number <= 5)
shrub_open_data <- subset(df, microsite %in% c("shrub", "open")) %>% filter((microsite == "open" & microsite_number > 5) | microsite == "shrub")
microsite_combinations <- expand.grid(microsite = c("mimic", "open"),
microsite_number = 1:5, # Adjust the range based on your data
site_code = unique(mimic_open_data$site_code))
rii_results <- data.frame()
calculate_rii <- function(data) {
# Assuming columns are named "abundance", "richness", and "evenness"
rii_abundance <- (data$abundance[1] - data$abundance[2]) / (data$abundance[1] + data$abundance[2])
rii_richness <- (data$richness[1] - data$richness[2]) / (data$richness[1] + data$richness[2])
rii_evenness <- (data$evenness[1] - data$evenness[2]) / (data$evenness[1] + data$evenness[2])
return(c(rii_abundance, rii_richness, rii_evenness))
}
# Iterate through each combination of microsites and site numbers
for (i in 1:nrow(microsite_combinations)) {
current_combination <- microsite_combinations[i, ]
# Filter data for the current microsite pair and site numbers
current_data <- mimic_open_data %>%
filter((microsite == current_combination$microsite &
microsite_number == current_combination$microsite_number &
site_code == current_combination$site_code) |
(microsite == "open" &
microsite_number == current_combination$microsite_number &
site_code == current_combination$site_code))
current_rii <- calculate_rii(current_data)
current_results <- data.frame(microsite = current_combination$microsite,
microsite_number = current_combination$microsite_number,
site_code = current_combination$site_code,
rii_abundance = current_rii[1],
rii_richness = current_rii[2],
rii_evenness = current_rii[3])
rii_results <- rbind(rii_results, current_results)
}
# Display or use RII results
print(rii_results)
## microsite microsite_number site_code rii_abundance rii_richness
## 1 mimic 1 Carrizo_soda_open 0.7391304 0.42857143
## 2 open 1 Carrizo_soda_open NA NA
## 3 mimic 2 Carrizo_soda_open 0.4117647 0.42857143
## 4 open 2 Carrizo_soda_open NA NA
## 5 mimic 3 Carrizo_soda_open 0.6426667 0.16666667
## 6 open 3 Carrizo_soda_open NA NA
## 7 mimic 4 Carrizo_soda_open 0.4919786 0.07692308
## 8 open 4 Carrizo_soda_open NA NA
## 9 mimic 5 Carrizo_soda_open 0.6901408 0.33333333
## 10 open 5 Carrizo_soda_open NA NA
## 11 mimic 1 Carrizo_soda_shrub -0.7682119 0.14285714
## 12 open 1 Carrizo_soda_shrub NA NA
## 13 mimic 2 Carrizo_soda_shrub 0.3548387 0.11111111
## 14 open 2 Carrizo_soda_shrub NA NA
## 15 mimic 3 Carrizo_soda_shrub 0.8604651 0.66666667
## 16 open 3 Carrizo_soda_shrub NA NA
## 17 mimic 4 Carrizo_soda_shrub 0.9024390 0.33333333
## 18 open 4 Carrizo_soda_shrub NA NA
## 19 mimic 5 Carrizo_soda_shrub 0.1282051 -0.14285714
## 20 open 5 Carrizo_soda_shrub NA NA
## 21 mimic 1 Cuyama_1 1.0000000 1.00000000
## 22 open 1 Cuyama_1 NA NA
## 23 mimic 2 Cuyama_1 -0.4285714 -0.20000000
## 24 open 2 Cuyama_1 NA NA
## 25 mimic 3 Cuyama_1 0.6774194 0.00000000
## 26 open 3 Cuyama_1 NA NA
## 27 mimic 4 Cuyama_1 -0.4392523 0.00000000
## 28 open 4 Cuyama_1 NA NA
## 29 mimic 5 Cuyama_1 0.7647059 0.66666667
## 30 open 5 Cuyama_1 NA NA
## 31 mimic 1 Cuyama_3 0.3333333 0.20000000
## 32 open 1 Cuyama_3 NA NA
## 33 mimic 2 Cuyama_3 0.0000000 0.20000000
## 34 open 2 Cuyama_3 NA NA
## 35 mimic 3 Cuyama_3 -0.2000000 -0.33333333
## 36 open 3 Cuyama_3 NA NA
## 37 mimic 4 Cuyama_3 0.8461538 0.33333333
## 38 open 4 Cuyama_3 NA NA
## 39 mimic 5 Cuyama_3 1.0000000 1.00000000
## 40 open 5 Cuyama_3 NA NA
## rii_evenness
## 1 0.5966766
## 2 NA
## 3 0.4670043
## 4 NA
## 5 0.1069349
## 6 NA
## 7 0.2258878
## 8 NA
## 9 0.1524406
## 10 NA
## 11 0.3811298
## 12 NA
## 13 0.0041823
## 14 NA
## 15 1.0000000
## 16 NA
## 17 1.0000000
## 18 NA
## 19 -0.1526385
## 20 NA
## 21 NaN
## 22 NA
## 23 -0.1564565
## 24 NA
## 25 -0.3159922
## 26 NA
## 27 0.1812030
## 28 NA
## 29 1.0000000
## 30 NA
## 31 0.1536151
## 32 NA
## 33 0.3836226
## 34 NA
## 35 -1.0000000
## 36 NA
## 37 0.1729713
## 38 NA
## 39 1.0000000
## 40 NA
rii_results_mimic <- rii_results %>% filter(microsite_number <= 5) %>% filter(microsite == "mimic") %>% mutate_all(~ifelse(is.na(.), 0, .)) %>% mutate(microsite = ifelse(microsite == 1, "Mimic", microsite))
shrub_open_data <- subset(df, microsite %in% c("shrub", "open")) %>% filter((microsite == "open" & microsite_number > 5) | microsite == "shrub")
shrub_open_data <- shrub_open_data %>%
mutate(microsite_number = ifelse(microsite_number == 6, 1, microsite_number)) %>% mutate(microsite_number = ifelse(microsite_number == 7, 2, microsite_number)) %>% mutate(microsite_number = ifelse(microsite_number == 8, 3, microsite_number))
microsite_combinations_2 <- expand.grid(microsite = c("shrub", "open"),
microsite_number = 1:3, # Adjust the range based on your data
site_code = unique(mimic_open_data$site_code))
rii_results <- data.frame()
calculate_rii <- function(data) {
# Assuming columns are named "abundance", "richness", and "evenness"
rii_abundance <- (data$abundance[1] - data$abundance[2]) / (data$abundance[1] + data$abundance[2])
rii_richness <- (data$richness[1] - data$richness[2]) / (data$richness[1] + data$richness[2])
rii_evenness <- (data$evenness[1] - data$evenness[2]) / (data$evenness[1] + data$evenness[2])
return(c(rii_abundance, rii_richness, rii_evenness))
}
# Iterate through each combination of microsites and site numbers
for (i in 1:nrow(microsite_combinations_2)) {
current_combination <- microsite_combinations_2[i, ]
# Filter data for the current microsite pair and site numbers
current_data <- shrub_open_data %>%
filter((microsite == current_combination$microsite &
microsite_number == current_combination$microsite_number &
site_code == current_combination$site_code) |
(microsite == "open" &
microsite_number == current_combination$microsite_number &
site_code == current_combination$site_code))
current_rii <- calculate_rii(current_data)
current_results <- data.frame(microsite = current_combination$microsite,
microsite_number = current_combination$microsite_number,
site_code = current_combination$site_code,
rii_abundance = current_rii[1],
rii_richness = current_rii[2],
rii_evenness = current_rii[3])
rii_results <- rbind(rii_results, current_results)
}
# Display or use RII results
print(rii_results)
## microsite microsite_number site_code rii_abundance rii_richness
## 1 shrub 1 Carrizo_soda_open NA NA
## 2 open 1 Carrizo_soda_open NA NA
## 3 shrub 2 Carrizo_soda_open NA NA
## 4 open 2 Carrizo_soda_open NA NA
## 5 shrub 3 Carrizo_soda_open NA NA
## 6 open 3 Carrizo_soda_open NA NA
## 7 shrub 1 Carrizo_soda_shrub -0.63636364 -0.7142857
## 8 open 1 Carrizo_soda_shrub NA NA
## 9 shrub 2 Carrizo_soda_shrub 0.06614786 -0.2000000
## 10 open 2 Carrizo_soda_shrub NA NA
## 11 shrub 3 Carrizo_soda_shrub 0.00000000 0.4285714
## 12 open 3 Carrizo_soda_shrub NA NA
## 13 shrub 1 Cuyama_1 -1.00000000 -1.0000000
## 14 open 1 Cuyama_1 NA NA
## 15 shrub 2 Cuyama_1 0.00000000 0.0000000
## 16 open 2 Cuyama_1 NA NA
## 17 shrub 3 Cuyama_1 0.60000000 0.5000000
## 18 open 3 Cuyama_1 NA NA
## 19 shrub 1 Cuyama_3 -0.45454545 -0.3333333
## 20 open 1 Cuyama_3 NA NA
## 21 shrub 2 Cuyama_3 NaN NaN
## 22 open 2 Cuyama_3 NA NA
## 23 shrub 3 Cuyama_3 -0.77777778 0.0000000
## 24 open 3 Cuyama_3 NA NA
## rii_evenness
## 1 NA
## 2 NA
## 3 NA
## 4 NA
## 5 NA
## 6 NA
## 7 -1.0000000
## 8 NA
## 9 -0.3151460
## 10 NA
## 11 0.7200527
## 12 NA
## 13 NaN
## 14 NA
## 15 NaN
## 16 NA
## 17 1.0000000
## 18 NA
## 19 -0.3116986
## 20 NA
## 21 NaN
## 22 NA
## 23 NaN
## 24 NA
rii_results_shrub <- rii_results %>% filter(microsite == "shrub") %>% filter(site_code != "Carrizo_soda_open") %>% mutate_all(~ifelse(is.na(.), 0, .)) %>% mutate(microsite = ifelse(microsite == 1, "Shrub", microsite))
### Combine both RII df together.
combined_rii <- rbind(rii_results_mimic, rii_results_shrub)
# Assuming your combined RII dataframe is named "combined_rii"
library(tidyr)
library(ggplot2)
# Reshape data to long format
combined_rii_long <- combined_rii %>%
gather(key = "variable", value = "value", rii_abundance, rii_richness, rii_evenness)
# Create ggplot
summary_data <- combined_rii_long %>%
group_by(microsite, variable) %>%
summarize(avg_value = mean(value),
sd_value = sd(value))
## `summarise()` has grouped output by 'microsite'. You can override using the
## `.groups` argument.
# Create ggplot with point plot and error bars
rii_plot <- ggplot(summary_data, aes(x = variable, y = avg_value, color = microsite)) +
geom_point(position = position_dodge(width = 0.8), size = 3) +
geom_errorbar(aes(ymin = avg_value - sd_value, ymax = avg_value + sd_value),
position = position_dodge(width = 0.8), width = 0.2) +
labs(x = "", y = "RII", fill = "Microsite") +
theme_minimal() + theme_classic() + coord_flip() + scale_x_discrete(labels = c("rii_abundance" = "Abundance",
"rii_richness" = "Richness",
"rii_evenness" = "Evenness")) +
scale_colour_manual(values = c("Mimic" = "#a6cee3", "Shrub" = "#b2df8a")) + theme(text = element_text(size = 12), panel.border = element_rect(color = "black", fill = NA, size = 1.5), axis.text = element_text(size = 12)) + theme(aspect.ratio = 1) + geom_hline(yintercept = 0, linetype = "dashed", color = "black") + labs(colour = "Microsite")
rii_plot