forked from wldf510sp16/grazing_code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMammal Abundance
51 lines (37 loc) · 1.31 KB
/
Mammal Abundance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
install.packages("googlesheets")
install.packages("metafor")
library(googlesheets)
library(metafor)
###read in Google sheets data
gs_auth(new_user=TRUE)
my.sheet <- gs_title("Data Extraction")
my.data <- data.frame(gs_read_csv(ss=my.sheet, ws="Data", is.na(TRUE)))
names(my.data)
###Subset data into mammals and abundance
mammals<-rbind(my.data[which(my.data$Taxa=="Mammals"
& my.data$Response=="Abundance"),],
my.data[which(my.data$Taxa=="Rodents"
& my.data$Response=="Abundance"),])
head(mammals)
dim(mammals)
wt2<-escalc(measure="SMD",m1i=TrtMean,m2i=CntrlMean,sd1i=sqrt(TrtVar),
sd2i=sqrt(CntrlVar),n1i=n.Trt,n2i=n.Cntrl,
data=mammals,var.names=c("SMD","SMD_var"),digits=4)
head(wt2)
wt2$Taxa
wt2<-wt2[order(wt2$Genus),]
names(wt2)
###Histogram
hist(wt2$SMD, breaks=15, xlab="hedge's d", col=2)
abline(v=0,col=4,lty=3,lwd=5)
forest(wt2$SMD,wt2$SMD_var,slab=wt2$Species,pch=19)
####Fixed Effects Model-excludes studies with "NA" Values
fixef.model <- rma(SMD, SMD_var, data=wt2, method = "FE")
summary(fixef.model)
plot(fixef.model)
forest(fixef.model)
####Random Effects Model-excludes studies with "NA" Values
ranef.model <- rma(SMD, SMD_var, data=wt2, method = "HE")
summary(ranef.model)
plot(ranef.model)
forest(ranef.model)