diff --git a/DESCRIPTION b/DESCRIPTION index f96d095..8dbf61f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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) , Seber (1965) <10.2307/2333827>, Turek et al. (2016) ). diff --git a/R/dDHMM.R b/R/dDHMM.R index af30c35..48c6cb2 100644 --- a/R/dDHMM.R +++ b/R/dDHMM.R @@ -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)) - ) - diff --git a/R/dNmixture.R b/R/dNmixture.R index c817b4c..932168c 100644 --- a/R/dNmixture.R +++ b/R/dNmixture.R @@ -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 @@ -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