Skip to content

Commit

Permalink
Merge pull request #9 from dochvam/nMixture
Browse files Browse the repository at this point in the history
Add Daniel's edits and resolve dDHMM issue
  • Loading branch information
dochvam authored Feb 20, 2020
2 parents b5d3b06 + 9d65989 commit 1d3f96a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 34 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Authors@R: c(person("Benjamin R.", "Goldstein", role = c("aut", "cre"),
person("Daniel", "Turek", role = "aut"),
person("Lauren", "Ponisio", role = "aut"),
person("Perry", "de Valpine", role = "aut"))
Date: 2019-09-24
Date: 2020-02-20
Description: Common ecological distributions for 'nimble' models in the form of nimbleFunction objects.
Includes Cormack-Jolly-Seber, occupancy, dynamic occupancy, hidden Markov, and dynamic hidden Markov models.
(Jolly (1965) <doi:10.2307/2333826>, Seber (1965) <10.2307/2333827>, Turek et al. (2016) <doi:10.1007/s10651-016-0353-z>).
Expand Down
31 changes: 0 additions & 31 deletions R/dDHMM.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,34 +330,3 @@ rDHMMo <- nimbleFunction(
# }
# return(ans)
# })



registerDistributions(list(
dDHMM = list(
BUGSdist = "dDHMM(init, probObs, probTrans, len)",
Rdist = "dDHMM(init, probObs, probTrans, len)",
discrete = TRUE,
types = c('value = double(1)',
'init = double(1)',
'probObs = double(2)',
'probTrans = double(3)',
'len = double()'),
mixedSizes = TRUE,
pqAvail = FALSE))
)

registerDistributions(list(
dDHMMo = list(
BUGSdist = "dDHMMo(init, probObs, probTrans, len)",
Rdist = "dDHMMo(init, probObs, probTrans, len)",
discrete = TRUE,
types = c('value = double(1)',
'init = double(1)',
'probObs = double(3)',
'probTrans = double(3)',
'len = double()'),
mixedSizes = TRUE,
pqAvail = FALSE))
)

8 changes: 6 additions & 2 deletions R/dNmixture.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ dNmixture_v <- nimbleFunction(

## For each x, the conditional distribution of (N - x | x) is pois(lambda * (1-p))
## We determine the lowest N and highest N at extreme quantiles and sum over those.
if (Nmin == -1 & Nmax == -1) {
if (Nmin == -1) {
Nmin <- min(x + qpois(0.00001, lambda * (1 - prob)))
}
if (Nmax == -1) {
Nmax <- max(x + qpois(0.99999, lambda * (1 - prob)))
}
Nmin <- max( max(x), Nmin ) ## set Nmin to at least the largest x
Expand Down Expand Up @@ -217,8 +219,10 @@ dNmixture_s <- nimbleFunction(

## For each x, the conditional distribution of (N - x | x) is pois(lambda * (1-p))
## We determine the lowest N and highest N at extreme quantiles and sum over those.
if (Nmin == -1 & Nmax == -1) {
if (Nmin == -1) {
Nmin <- min(x + qpois(0.00001, lambda * (1 - prob)))
}
if (Nmax == -1) {
Nmax <- max(x + qpois(0.99999, lambda * (1 - prob)))
}
Nmin <- max( max(x), Nmin ) ## set Nmin to at least the largest x
Expand Down

0 comments on commit 1d3f96a

Please sign in to comment.