-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWasseramselBasic.R
55 lines (42 loc) · 2.17 KB
/
WasseramselBasic.R
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
52
53
54
55
library(unmarked)
library(ggplot2)
library(readxl)
detections <- read_excel("C:/.../DetectionHistory.xlsx")
umf <- unmarkedFrameOccu(y=detections)
summary(umf)
######################## Basic Model
umf <- unmarkedFrameOccu(y=detectionsMissing)
basic <- occu(~1 ~1, data = umf)
basic
basic.psi <- predict(basic, newdata=data.frame(site=1), type="state")
basic.p <- predict(basic, newdata=data.frame(site=1), type="det")
basic.psi
basic.p
basic_mb.gof.boot <- mb.gof.test(basic, nsim = 1000)
basic_mb.gof.boot
################ Grafik
outputs.basic <- data.frame(Par=c("psi", "p"),
estimates = c(basic.psi$Predicted, basic.p$Predicted),
lwr = c(basic.psi$lower, basic.p$lower),
upr = c(basic.psi$upper, basic.p$upper)
)
outputs.basic
ggplot(outputs.basic, aes(x = Par, y = estimates)) +
geom_point(size=2) +
geom_point(aes(x=Par, y=c(0.64,0.46)), color="orange", size = 2)+
geom_errorbar(aes(ymin = lwr, ymax = upr), size=1, colour = "red", width=.1) +
geom_point(size=3) +
geom_point(aes(x=Par, y=c(0.64,0.46)), color="orange", size = 3)+
labs(x = "", y = "Wert") +
scale_y_continuous(limits = c(0,1), breaks=seq(0,1,0.2))
################## Kontrollgänge
f1 <- function(x){return( (1-(1-basic.p$Predicted)^x)*100)}
f2 <- function(x){return( (1-(1-basic.p$lower)^x)*100)}
f3 <- function(x){return( (1-(1-basic.p$upper)^x)*100)}
ggplot(data.frame(x=c(0,12)), aes(x=x) ) + stat_function(fun=f1) +
stat_function(fun=f2, color="gray") +
stat_function(fun=f3, color="gray") +
labs(x = "Anzahl Kontrollgänge",
y = "Wahrscheinlichkeit, anwesende \nWasseramseln nachzuweisen [%]") +
scale_x_continuous(breaks = 0:12, minor_breaks = NULL) +
scale_y_continuous(breaks = c(0,20,40,50,60,70,80,90,95,99), minor_breaks = 100, labels=c(0,20,40,50,60,70,80,90,95,99))