-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from NERC-CEH/zip
Adding zero-inflated families
- Loading branch information
Showing
32 changed files
with
1,108 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: jsdmstan | ||
Title: Fitting jSDMs in Stan | ||
Version: 0.3.0 | ||
Version: 0.3.0.9000 | ||
Authors@R: | ||
person("Fiona", "Seaton", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-2022-7451")) | ||
|
@@ -12,7 +12,7 @@ License: GPL (>= 3) | |
Encoding: UTF-8 | ||
LazyData: true | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.1 | ||
RoxygenNote: 7.3.2 | ||
Biarch: true | ||
Depends: | ||
R (>= 3.4.0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#' jsdmStanFamily class | ||
#' | ||
#' This is the jsdmStanFamily class, which occupies a slot within any | ||
#' jsdmStanFit object. | ||
#' | ||
#' @name jsdmStanFamily | ||
#' | ||
#' @section Elements for \code{jsdmStanFamily} objects: | ||
#' \describe{ | ||
#' \item{\code{family}}{ | ||
#' A length one character vector describing family used to fit object. Options | ||
#' are \code{"gaussian"}, \code{"poisson"}, \code{"bernoulli"}, | ||
#' \code{"neg_binomial"}, \code{"binomial"}, \code{"zi_poisson"}, | ||
#' \code{"zi_neg_binomial"}, or \code{"multiple"}. | ||
#' } | ||
#' \item{\code{params}}{ | ||
#' A character vector that includes all the names of the family-specific parameters. | ||
#' } | ||
#' \item{\code{params_dataresp}}{ | ||
#' A character vector that includes any named family-specific parameters that are | ||
#' modelled in response to data. | ||
#' } | ||
#' \item{\code{preds}}{ | ||
#' A character vector of the measured predictors included if family parameters | ||
#' are modelled in response to data. If family parameters are not modelled in | ||
#' response to data this is left empty. | ||
#' } | ||
#' \item{\code{data_list}}{ | ||
#' A list containing the original data used to fit the model | ||
#' (empty when save_data is set to \code{FALSE} or family parameters are not | ||
#' modelled in response to data). | ||
#' } | ||
#' } | ||
#' | ||
jsdmStanFamily_empty <- function(){ | ||
res <- list(family = character(), | ||
params = character(), | ||
params_dataresp= character(), | ||
preds = character(), | ||
data_list = list()) | ||
class(res) <- "jsdmStanFamily" | ||
return(res) | ||
} | ||
|
||
# jsdmStanFamily methods | ||
|
||
#' Print jsdmStanFamily object | ||
#' | ||
#' @param x A jsdmStanFamily object | ||
#' @param ... Other arguments, not used at this stage. | ||
#' | ||
#' @export | ||
print.jsdmStanFamily <- function(x, ...){ | ||
cat(paste("Family:", x$family, "\n", | ||
ifelse(length(x$params)>0, | ||
paste("With parameters:", | ||
paste0(x$params, sep = ", "),"\n"), | ||
""))) | ||
if(length(x$params_dataresp)>0){ | ||
cat(paste("Family-specific parameter", | ||
paste0(x$params_dataresp,sep=", "), | ||
"is modelled in response to", length(x$preds), | ||
"predictors. These are named:", | ||
paste0(x$preds, sep = ", "))) | ||
} | ||
} |
Oops, something went wrong.