Nothing

```
ettersonEq14v1 <- function(s,f,J){
#This function calculates the function gfe in Eq. 14 of Etterson, M.
#Hidden Markov models for estimating animal mortality from anthropogenic
#hazards. It has been modified to allow time-varying parameters.
#Parameters are assumed to be indexed to the calendar day.
#
#Inputs:
# s = vector of estimated daily persistence probabilities
# f = vector of discovery probabilities
# J = row-vector of intervals between searches
#
#Outputs:
# gfe = function related to the probability of sampling a carcass
# killed between the first and last searches. See ms for details.
# Note: this function requires expm
n <- length(J);#number of searches
N <- sum(J);#number of days of monitoring
Searches<-cumsum(J);
gfe <- 0;
V1<- matrix( c(1,0,0), ncol=3, byrow=TRUE)
V3<- matrix( c(0,0,1), ncol=3, byrow=TRUE)
#Indexing below is for the interval in which an animal is killed.
for (j in 1:N){ #Day the carcass enters the area searched
A <- diag(3);
for (i in j:N){ #daily fates of the carcass after entering search area
qr_i <- s[i];
pr_i <- 1-qr_i;
Svec <- c(qr_i,pr_i,0,0,1,0,0,0,1);
S <- matrix( Svec, ncol=3, byrow=TRUE )
A <- A %*% S
x <- which(i==Searches);
if (length(x)!=0){
pd_i <- f[x];
qd_i = 1-pd_i;
Dvec <- c(qd_i,0,pd_i,0,1,0,0,0,1);
D <- matrix( Dvec, ncol=3, byrow=TRUE )
A <- A %*% D
}
}
gfe <- gfe + V1 %*% A %*% t(V3);
}
p <- gfe/sum(J)
return(p)
}
```

**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.