aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Kellner <ken@kenkellner.com>2024-01-04 23:13:34 -0500
committerKen Kellner <ken@kenkellner.com>2024-01-04 23:13:34 -0500
commit209f809281a08c94946e3a710fba7c136ea68cfe (patch)
tree7147348dadbeb691c398ba6fa60735651e211898
parent9ff89b580cd765c3c6cddfac9b3431a2128f4316 (diff)
Bump version and fix a couple check errors
-rw-r--r--DESCRIPTION4
-rw-r--r--NAMESPACE2
-rw-r--r--NEWS.md7
-rw-r--r--R/occuCOP.R4
-rw-r--r--man/occuCOP.Rd2
-rw-r--r--vignettes/contributing_to_unmarked.Rmd76
6 files changed, 51 insertions, 44 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index e155530..6c9614f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: unmarked
-Version: 1.3.2.9006
-Date: 2023-01-04
+Version: 1.4.0
+Date: 2024-01-05
Type: Package
Title: Models for Data from Unmarked Animals
Authors@R: c(
diff --git a/NAMESPACE b/NAMESPACE
index 67da285..aea62db 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -7,7 +7,7 @@ importFrom(stats, confint, fitted, coef, vcov, predict, update, profile,
pnorm, qchisq, qnorm, quantile, rbinom,
reshape, rmultinom, rnbinom, rpois, runif, sd, uniroot,
update.formula, sigma)
-importFrom(graphics, plot, hist, abline, axis, lines, points, polygon, segments)
+importFrom(graphics, plot, hist, abline, axis, lines, points, polygon, segments, title)
importFrom(utils, head, read.csv)
importFrom(grDevices, devAskNewPage, dev.interactive, palette.colors)
importFrom(MASS, mvrnorm)
diff --git a/NEWS.md b/NEWS.md
index 1ae9387..14b00fd 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,10 @@
+# unmarked 1.4.0
+
+* Added count-data occupancy model (occuCOP)
+* Added multi-scale occupancy model (goccu)
+* Added ZIP support to gdistsamp, gmultmix, and gpcount
+* Fixed bug in TMB engine for occu that resulted in incorrect detection coefficient estimates when there were many interspersed NAs in the encounter history
+
# unmarked 1.3.3
* Increase required R version to 4.0
diff --git a/R/occuCOP.R b/R/occuCOP.R
index ec27b58..f22c235 100644
--- a/R/occuCOP.R
+++ b/R/occuCOP.R
@@ -366,7 +366,7 @@ setMethod("get_orig_data", "unmarkedFitOccuCOP", function(object, type, ...){
## getP ----
-setMethod("getP", "unmarkedFitOccuCOP", function(object) {
+setMethod("getP", "unmarkedFitOccuCOP", function(object, na.rm = TRUE) {
data <- object@data
M = nrow(getY(data))
J = ncol(getY(data))
@@ -380,7 +380,7 @@ setMethod("getP", "unmarkedFitOccuCOP", function(object) {
## fitted ----
-setMethod("fitted", "unmarkedFitOccuCOP", function(object) {
+setMethod("fitted", "unmarkedFitOccuCOP", function(object, na.rm = FALSE) {
data <- object@data
M = nrow(getY(data))
J = ncol(getY(data))
diff --git a/man/occuCOP.Rd b/man/occuCOP.Rd
index f0b5be0..7549ca3 100644
--- a/man/occuCOP.Rd
+++ b/man/occuCOP.Rd
@@ -95,7 +95,7 @@ occuCOP(data,
\references{
-Pautrel, L., Moulherat, S., Gimenez, O. & Etienne, M.-P. Submitted. \emph{Analysing biodiversity observation data collected in continuous time: Should we use discrete or continuous-time occupancy models?} Preprint at \href{https://doi.org/10.1101/2023.11.17.567350}{https://doi.org/10.1101/2023.11.17.567350}.
+Pautrel, L., Moulherat, S., Gimenez, O. & Etienne, M.-P. Submitted. \emph{Analysing biodiversity observation data collected in continuous time: Should we use discrete or continuous-time occupancy models?} Preprint at \doi{10.1101/2023.11.17.567350}.
}
diff --git a/vignettes/contributing_to_unmarked.Rmd b/vignettes/contributing_to_unmarked.Rmd
index e9802a4..8ffab04 100644
--- a/vignettes/contributing_to_unmarked.Rmd
+++ b/vignettes/contributing_to_unmarked.Rmd
@@ -55,15 +55,15 @@ You can have more information about each `unmarkedFrame` subclass by looking at
## Define the `unmarkedFrame` subclass for this model
-- All `unmarkedFrame` subclasses are children of the `umarkedFrame` class, defined [here](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R#L24-L30).
-- [Example with `occu`](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R#L65-L66)
-- [Example with `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L1-L11)
-- All `unmarkedFrame` subclasses need to pass the [validunmarkedFrame](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R#L4-L19) validity check. You may want to add complementary validity check, like, for example, the [`unmarkedFrameDS subclass](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R#L43-L62).
+- All `unmarkedFrame` subclasses are children of the `umarkedFrame` class, defined [here](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R#L24-L30).
+- [Example with `occu`](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R#L65-L66)
+- [Example with `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L1-L11)
+- All `unmarkedFrame` subclasses need to pass the [validunmarkedFrame](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R#L4-L19) validity check. You may want to add complementary validity check, like, for example, the [`unmarkedFrameDS subclass](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R#L43-L62).
## Write the function that creates the `unmarkedFrame` object
-- [Example with `occu`](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R#L232-L239)
-- [Example with `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L13-L50)
+- [Example with `occu`](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R#L232-L239)
+- [Example with `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L13-L50)
## Write the S4 methods associated with the `unmarkedFrame` object {#methods-unmarkedFrame}
@@ -74,12 +74,12 @@ Note that you may not have to write all of the S4 methods below. Most of them wi
Here are methods you probably will have to rewrite.
- Subsetting the `unmarkedFrame` object: `umf[i, ]`, `umf[, j]` and `umf[i, j]`
- - Example with `occu`: [code for `unmarkedFrame` mother class](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R#L1126-L1235), as used to subset an `unmarkedFrameOccu` object.
- - Example with `gdistremoval`: [`umf[i, ]` when `i` is numeric](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L67-L120), [`umf[i, ]` when `i` is logical](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L122-L126), [`umf[i, j]`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L128-L174)
+ - Example with `occu`: [code for `unmarkedFrame` mother class](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R#L1126-L1235), as used to subset an `unmarkedFrameOccu` object.
+ - Example with `gdistremoval`: [`umf[i, ]` when `i` is numeric](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L67-L120), [`umf[i, ]` when `i` is logical](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L122-L126), [`umf[i, j]`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L128-L174)
### Generic methods {-}
-Here are methods that you should test but probably will not have to rewrite. They are defined in the [`unmarkedFrame.R`](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFrame.R) file, for the `unmarkedFrame` mother class.
+Here are methods that you should test but probably will not have to rewrite. They are defined in the [`unmarkedFrame.R`](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFrame.R) file, for the `unmarkedFrame` mother class.
- `coordinates`
- `getY`
@@ -107,8 +107,8 @@ You may also need to add specific methods to allow users to access an attribute
The fitting function can be declined into three main steps: reading the `unmarkedFrame` object, maximising the likelihood, and formatting the outputs.
-- [Example: the `occu()` function](https://github.com/rbchan/unmarked/tree/master/R/occu.R#L4-L161)
-- [Example: the `gdistremoval()` function](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L257-L472)
+- [Example: the `occu()` function](https://github.com/rbchan/unmarked/blob/master/R/occu.R#L4-L161)
+- [Example: the `gdistremoval()` function](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L257-L472)
## Inputs of the fitting function
@@ -127,8 +127,8 @@ Most models have their own `getDesign` function, an S4 method. The purpose of th
Writing the `getDesign` method is frequently the most tedious and difficult part of the work adding a new function.
-- [Example for `occu`](https://github.com/rbchan/unmarked/tree/master/R/getDesign.R#L10-L153), as used for `occu`
-- [Example for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L177-L253)
+- [Example for `occu`](https://github.com/rbchan/unmarked/blob/master/R/getDesign.R#L10-L153), as used for `occu`
+- [Example for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L177-L253)
## The likelihood function
@@ -141,7 +141,7 @@ Writing the `getDesign` method is frequently the most tedious and difficult part
If you are mainly used to coding in R, you should probably start here. If users want to dig deeper into the likelihood of a model, it may be useful for them to be able to read the R code to calculate likelihood, as they may not be familiar with other languages. This likelihood function can be used only for **fixed-effects models**.
-- [Example for `occu`](https://github.com/rbchan/unmarked/tree/master/R/occu.R#L65-L74)
+- [Example for `occu`](https://github.com/rbchan/unmarked/blob/master/R/occu.R#L65-L74)
- `gdistremoval` doesn't have an R version of the likelihood function
### The C++ likelihood function: faster
@@ -165,24 +165,24 @@ Your C++ function should be in a `.cpp` file in the `./src/` folder of the packa
Outputs from `optim` should be organized unto `unmarkedEstimate` (S4) objects, with one `unmarkedEstimate` per submodel (*e.g.* state, detection). These objects include the parameter estimates and other information about link functions etc.
-The `unmarkedEstimate` class is defined [here](https://github.com/rbchan/unmarked/tree/master/R/unmarkedEstimate.R#L5-L26) in the `unmarkedEstimate.R` file, and the `unmarkedEstimate` function is defined [here](https://github.com/rbchan/unmarked/tree/master/R/unmarkedEstimate.R#L86-L100), and is used to create new `unmarkedEstimate` objects. You normally will not need to create `unmarkedEstimate` subclass.
+The `unmarkedEstimate` class is defined [here](https://github.com/rbchan/unmarked/blob/master/R/unmarkedEstimate.R#L5-L26) in the `unmarkedEstimate.R` file, and the `unmarkedEstimate` function is defined [here](https://github.com/rbchan/unmarked/blob/master/R/unmarkedEstimate.R#L86-L100), and is used to create new `unmarkedEstimate` objects. You normally will not need to create `unmarkedEstimate` subclass.
-- [Example for the state estimate for `occu`](https://github.com/rbchan/unmarked/tree/master/R/occu.R#L132-L139)
-- [Example for the lambda estimate for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L429-L431C72)
+- [Example for the state estimate for `occu`](https://github.com/rbchan/unmarked/blob/master/R/occu.R#L132-L139)
+- [Example for the lambda estimate for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L429-L431C72)
### Design the `unmarkedFit` object
You'll need to create a new `unmarkedFit` subclass for your model. The main component of `unmarkedFit` objects is a list of the `unmarkedEstimates` described above.
-- [Definition of the `unmarkedFit` mother class](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFit.R#L1-L14)
-- [Example of the `unmarkedFitOccu` subclass definition](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFit.R#L68-L70)
-- [Example of the `unmarkedFitGDR` subclass definition](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L255)
+- [Definition of the `unmarkedFit` mother class](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFit.R#L1-L14)
+- [Example of the `unmarkedFitOccu` subclass definition](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFit.R#L68-L70)
+- [Example of the `unmarkedFitGDR` subclass definition](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L255)
After you defined your `unmarkedFit` subclass, you can create the object in your fitting function.
-- [Example of the `unmarkedFitOccu` object creation](https://github.com/rbchan/unmarked/tree/master/R/occu.R#L153-L158)
-- [Example of the `unmarkedFitGDR` object creation](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L466-L470)
+- [Example of the `unmarkedFitOccu` object creation](https://github.com/rbchan/unmarked/blob/master/R/occu.R#L153-L158)
+- [Example of the `unmarkedFitGDR` object creation](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L466-L470)
The fitting function return this `unmarkedFit` object.
@@ -206,17 +206,17 @@ Those are methods you will want to rewrite, adjusting them for your model.
#### `getP` {-}
-The `getP` method ([defined here](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFit.R#L1475-L1492)) "back-transforms" the detection parameter ($p$ the detection probability or $\lambda$ the detection rate, depending on the model). It returns a matrix of the estimated detection parameters. It is called by several other methods that are useful to extract information from the `unmarkedFit` object.
+The `getP` method ([defined here](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFit.R#L1475-L1492)) "back-transforms" the detection parameter ($p$ the detection probability or $\lambda$ the detection rate, depending on the model). It returns a matrix of the estimated detection parameters. It is called by several other methods that are useful to extract information from the `unmarkedFit` object.
- For `occu`, the generic method for `unmarkedFit` objects is called.
-- [Example for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L476-L537)
+- [Example for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L476-L537)
#### `simulate` {-}
-The generic `simulate` method ([defined here](https://github.com/rbchan/unmarked/tree/master/R/simulate.R#L62C33-L86)) calls the `simulate_fit` method that depends on the class of the `unmarkedFit` object, which depends on the model.
+The generic `simulate` method ([defined here](https://github.com/rbchan/unmarked/blob/master/R/simulate.R#L62C33-L86)) calls the `simulate_fit` method that depends on the class of the `unmarkedFit` object, which depends on the model.
-- [Example of `simulate_fit` method for `occu`](https://github.com/rbchan/unmarked/tree/master/R/simulate.R#L158-L165)
-- [Example of `simulate_fit` method for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/simulate.R#L536-L558)
+- [Example of `simulate_fit` method for `occu`](https://github.com/rbchan/unmarked/blob/master/R/simulate.R#L158-L165)
+- [Example of `simulate_fit` method for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/simulate.R#L536-L558)
The `simulate` method can be used in two ways:
@@ -227,14 +227,14 @@ You should test both ways with your model.
#### `plot` {-}
-This method plots the results of your model. The generic `plot` method for `unmarkedFit` ([defined here](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFit.R#L1346-L1352)) plot the residuals of the model.
+This method plots the results of your model. The generic `plot` method for `unmarkedFit` ([defined here](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFit.R#L1346-L1352)) plot the residuals of the model.
- For `occu`, the generic method for `unmarkedFit` objects is called.
-- [Example for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/R/gdistremoval.R#L837-L853)
+- [Example for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/R/gdistremoval.R#L837-L853)
### Generic methods {-}
-Here are methods that you should test but probably will not have to rewrite. They are defined in the [`unmarkedFit.R`](https://github.com/rbchan/unmarked/tree/master/R/unmarkedFit.R) file, for the `unmarkedFit` mother class.
+Here are methods that you should test but probably will not have to rewrite. They are defined in the [`unmarkedFit.R`](https://github.com/rbchan/unmarked/blob/master/R/unmarkedFit.R) file, for the `unmarkedFit` mother class.
- `[`
- `backTransform`
@@ -274,10 +274,10 @@ For example, some methods are relevant for some type of models only:
# Update the `NAMESPACE` file
-- Add your fitting function to the functions export [here](https://github.com/rbchan/unmarked/tree/master/NAMESPACE#L23-L27)
-- Add the new subclasses (`unmarkedFrame`, `unmarkedFit`) to the classes export [here](https://github.com/rbchan/unmarked/tree/master/NAMESPACE#L31-L43)
-- Add the function you wrote to create your `unmarkedFrame` object to the functions export [here](https://github.com/rbchan/unmarked/tree/master/NAMESPACE#L58-L64)
-- If you wrote new methods, for example to [access new attributes for objects of a subclass](#Methods-to-access-new-attributes), add them to the methods export [here](https://github.com/rbchan/unmarked/tree/master/NAMESPACE#L45-L54)
+- Add your fitting function to the functions export [here](https://github.com/rbchan/unmarked/blob/master/NAMESPACE#L23-L27)
+- Add the new subclasses (`unmarkedFrame`, `unmarkedFit`) to the classes export [here](https://github.com/rbchan/unmarked/blob/master/NAMESPACE#L31-L43)
+- Add the function you wrote to create your `unmarkedFrame` object to the functions export [here](https://github.com/rbchan/unmarked/blob/master/NAMESPACE#L58-L64)
+- If you wrote new methods, for example to [access new attributes for objects of a subclass](#Methods-to-access-new-attributes), add them to the methods export [here](https://github.com/rbchan/unmarked/blob/master/NAMESPACE#L45-L54)
- If required, export other functions you created that may be called by users of the package
# Write tests
@@ -295,11 +295,11 @@ Write your tests in the `./tests/testthat/` folder, creating a R file for your m
You need to write the documentation files for the new classes and functions you added. Documentation `.Rd` files are stored in the `man` folder. [Here](https://r-pkgs.org/man.html) is a documentation on how to format your documentation.
- The most important, your fitting function!
- - [Example for `occu`](https://github.com/rbchan/unmarked/tree/master/man/occu.Rd)
- - [Example for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/man/gdistremoval.Rd)
+ - [Example for `occu`](https://github.com/rbchan/unmarked/blob/master/man/occu.Rd)
+ - [Example for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/man/gdistremoval.Rd)
- Your `unmarkedFrame` constructor function
- - [Example for `occu`](https://github.com/rbchan/unmarked/tree/master/man/occu.Rd)
- - [Example for `gdistremoval`](https://github.com/rbchan/unmarked/tree/master/man/gdistremoval.Rd)
+ - [Example for `occu`](https://github.com/rbchan/unmarked/blob/master/man/occu.Rd)
+ - [Example for `gdistremoval`](https://github.com/rbchan/unmarked/blob/master/man/gdistremoval.Rd)
- Add your fitting function to the reference of all functions to [_pkgdown.yml](https://github.com/rbchan/unmarked/blob/master/_pkgdown.yml)
- Add the specific "type" for the predict methods of your `unmarkedFit` class to [predict-methods.Rd](https://github.com/rbchan/unmarked/blob/master/man/predict-methods.Rd)
- Add your `getP` method for the signature of you `unmarkedFitList` object in [getP-methods.Rd](https://github.com/rbchan/unmarked/blob/master/man/getP-methods.Rd).