plot_fitted | R Documentation |
plot_fitted makes plots bycatch estimates (lambda of Poisson), accounting for effort but not accounting for observer coverage
plot_fitted(
fitted_model,
xlab = "Time",
ylab = "Events",
include_points = FALSE,
alpha = 0.05
)
fitted_model |
Data and fitted model returned from fit_bycatch(). If a hurdle model, then only then the plot returns the total bycatch rate (including zero and non-zero components). |
xlab |
X-axis label for plot |
ylab |
Y-axis label for plot |
include_points |
whether or not to include raw bycatch events on plots, defaults to FALSE |
alpha |
The alpha level for the credible interval, defaults to 0.05 |
plot called from ggplot
d <- data.frame(
"Year" = 2002:2014,
"Takes" = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0),
"expansionRate" = c(24, 22, 14, 32, 28, 25, 30, 7, 26, 21, 22, 23, 27),
"Sets" = c(391, 340, 330, 660, 470, 500, 330, 287, 756, 673, 532, 351, 486)
)
fit <- fit_bycatch(Takes ~ 1,
data = d, time = "Year", effort = "Sets",
family = "poisson", time_varying = FALSE
)
plot_fitted(fit,
xlab = "Year", ylab = "Fleet-level bycatch",
include_points = TRUE
)
# fit a negative binomial model, with more chains and control arguments
fit_nb <- fit_bycatch(Takes ~ 1,
data = d, time = "Year",
effort = "Sets", family = "nbinom2",
time_varying = FALSE, iter = 2000, chains = 4,
control = list(adapt_delta = 0.99, max_treedepth = 20)
)
# fit a time varying model
fit <- fit_bycatch(Takes ~ 1,
data = d, time = "Year",
effort = "Sets", family = "poisson", time_varying = TRUE
)
# include data for expansion to unobserved sets
fit_nb <- fit_bycatch(Takes ~ 1,
data = d, time = "Year",
effort = "Sets", family = "nbinom2",
expansion_rate = "expansionRate",
time_varying = FALSE, iter = 2000, chains = 4,
control = list(adapt_delta = 0.99, max_treedepth = 20)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.