Skip to content

Commit

Permalink
Merge pull request #11 from nimble-dev/nMixture
Browse files Browse the repository at this point in the history
Updated master to match CRAN release from 0.2.0
  • Loading branch information
dochvam authored Apr 2, 2020
2 parents 03873a2 + 1d3f96a commit 7ce6c91
Show file tree
Hide file tree
Showing 20 changed files with 1,314 additions and 102 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ run_tests\.R
^\.travis\.yml$
^doc$
^Meta$
\.Rmd$
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Package: nimbleEcology
Type: Package
Title: Distributions for Ecological Models in 'nimble'
Version: 0.1.1
Version: 0.2.0
Maintainer: Benjamin R. Goldstein <[email protected]>
Authors@R: c(person("Benjamin R.", "Goldstein", role = c("aut", "cre"),
email = "[email protected]"),
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 All @@ -19,11 +19,12 @@ Encoding: UTF-8
LazyData: true
URL: https://github.com/nimble-dev/nimbleEcology
Collate:
dDynOcc.R
dCJS.R
dDynOcc.R
dDHMM.R
dHMM.R
dOcc.R
dNmixture.R
zzz.R
RoxygenNote: 6.1.1
Suggests:
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export(dDynOcc_vvs)
export(dDynOcc_vvv)
export(dHMM)
export(dHMMo)
export(dNmixture_s)
export(dNmixture_v)
export(dOcc_s)
export(dOcc_v)
export(rCJS_ss)
Expand All @@ -42,9 +44,12 @@ export(rDynOcc_vvs)
export(rDynOcc_vvv)
export(rHMM)
export(rHMMo)
export(rNmixture_s)
export(rNmixture_v)
export(rOcc_s)
export(rOcc_v)
import(nimble)
importFrom(stats,dbinom)
importFrom(stats,rbinom)
importFrom(stats,runif)
importFrom("stats", "dpois", "qpois", "rpois")
6 changes: 6 additions & 0 deletions R/dCJS.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ dCJS_ss <- nimbleFunction(
if (len != 0) {
if (len != length(x)) stop("Argument len must match length of data, or be 0.")
}
if (x[1] != 1) stop("dCJS requires specifying first capture. x[1] must equal 1.")

## Note the calculations used here are actually in hidden Markov model form.
probAliveGivenHistory <- 1
## logProbData will be the final answer
Expand Down Expand Up @@ -191,6 +193,7 @@ dCJS_sv <- nimbleFunction(
if (len != length(x)) stop("Argument len must match length of data, or be 0.")
}
if (length(x) != length(probCapture)) stop("Length of probCapture does not match length of data.")
if (x[1] != 1) stop("dCJS requires specifying first capture. x[1] must equal 1.")

## Note the calculations used here are actually in hidden Markov model form.
probAliveGivenHistory <- 1
Expand Down Expand Up @@ -238,6 +241,7 @@ dCJS_vs <- nimbleFunction(
}
if (length(probSurvive) < length(x) - 1)
stop("Length of probSurvive must be at least length of data minus 1.")
if (x[1] != 1) stop("dCJS requires specifying first capture. x[1] must equal 1.")

## Note the calculations used here are actually in hidden Markov model form.
probAliveGivenHistory <- 1
Expand Down Expand Up @@ -290,6 +294,8 @@ dCJS_vv <- nimbleFunction(
if (length(probSurvive) < length(x) - 1)
stop("Length of probSurvive must be at least length of data minus 1.")
if (length(x) != length(probCapture)) stop("Length of probCapture does not match length of data.")
if (x[1] != 1) stop("dCJS requires specifying first capture. x[1] must equal 1.")

## Note the calculations used here are actually in hidden Markov model form.
probAliveGivenHistory <- 1
## logProbData will be the final answer
Expand Down
35 changes: 2 additions & 33 deletions R/dDHMM.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Dynamic Hidden Markov Model distribution for use in NIMBLE models
#' Dynamic Hidden Markov Model distribution for use in \code{nimble} models
#'
#' \code{dDHMM} and \code{dDHMMo} provide Dynamic hidden Markov model
#' distributions for NIMBLE models.
#' distributions for \code{nimble} models.
#'
#' @name dDHMM
#' @aliases dDHMM dDHMMo rDHMM rDHMMo
Expand Down 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))
)

2 changes: 1 addition & 1 deletion R/dDynOcc.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# dDynOcc
#' Dynamic occupancy distribution for use in NIMBLE models
#' Dynamic occupancy distribution for use in \code{nimble} models
#' \code{dDynOcc_**} and \code{rDynOcc_**} provide dynamic occupancy
#' model distributions that can be used directly from R or in \code{nimble}
#' models.
Expand Down
2 changes: 1 addition & 1 deletion R/dHMM.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Hidden Markov Model distribution for use in NIMBLE models
#' Hidden Markov Model distribution for use in \code{nimble} models
#'
#' \code{dHMM} and \code{dHMMo} provide hidden Markov model
#' distributions that can be used directly from R or in \code{nimble}
Expand Down
Loading

0 comments on commit 7ce6c91

Please sign in to comment.