Skip to content

Commit

Permalink
Adds Tweedie closes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
kellijohnson-NOAA committed Apr 15, 2022
1 parent c359cde commit e4eeae9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions R/VAST_spp.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
#' }
#'
VAST_spp <- function(dir, species,
dist = c("lognormal", "gamma")) {
dist = c("lognormal", "gamma", "tweedie")) {

#### Get species, survey, and strata info
info <- nwfscSurvey::GetSpp.fn(species)
Expand All @@ -107,7 +107,8 @@ VAST_spp <- function(dir, species,
for (obs in dist) {
obs_model <- switch(obs,
lognormal = c(1, 0),
gamma = c(2, 0)
gamma = c(2, 0),
tweedie = c(10, 2)
)
modeldir <- file.path(sppdir, paste(survey, obs, sep = "_"))
settings <- list(
Expand Down
5 changes: 5 additions & 0 deletions R/get_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ get_settings <- function(settings = NULL, verbose = FALSE) {
default = c(Beta1 = 0, Beta2 = 0, Epsilon1 = 0, Epsilon2 = 0))
Settings_all$FieldConfig <- get_settings_single(Settings_all$field,
default = c(Omega1 = 1, Epsilon1 = 1, Omega2 = 1, Epsilon2 = 1))
if (Settings_all[["ObsModelcondition"]][1] == 10) {
# Following items are specific to the Tweedie distribution #43
Settings_all[["FieldConfig"]][c("Omega1", "Epsilon1")] <- 0
Settings_all[["RhoConfig"]][c("Beta1")] <- 3
}

# Overdispersion
if (is.null(Settings_all[["overdispersion"]])) {
Expand Down
4 changes: 4 additions & 0 deletions R/plot_qq.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ plot_qq <- function(outdir, model) {
),
MoreArgs = list(shape = 1 / (sigmaM^2))))
}
if (model[["data_list"]][["ObsModel_ez"]][1] == 10) {
message("QQ plot is not yet implemented for the Tweedie distribution. See #45.")
return(invisible())
}

grDevices::png(file.path(outdir, "VASTWestCoast_QQ.png"), height = 18, width = 18, units = "cm",
res = 300)
Expand Down
4 changes: 3 additions & 1 deletion R/summary_nwfsc.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ summary_nwfsc <- function(obj, parameter_estimates, savedir = NULL) {
"Poisson-link",
switch(as.character(obj$env$data$ObsModel[1]),
"1" = "Lognormal",
"2" = "Gamma")))
"2" = "Gamma",
"10" = "Tweedie"))
)
TableA[6, ] <- c("Spatial effect for encounter probability",
ifelse(obj$env$data$FieldConfig[1, 2] < 0, "No", "Yes"))
TableA[7, ] <- c("Spatio-temporal effect for encounter probability",
Expand Down
2 changes: 1 addition & 1 deletion man/VAST_spp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4eeae9

Please sign in to comment.