Skip to content

Commit

Permalink
version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Quang Huynh authored and cran-robot committed Jun 12, 2018
1 parent 75c6968 commit 8315764
Show file tree
Hide file tree
Showing 26 changed files with 116 additions and 72 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: MLZ
Title: Mean Length-Based Estimators of Mortality using TMB
Version: 0.1.0
Version: 0.1.1
Authors@R: c(person("Quang", "Huynh", email = "q.huynh@oceans.ubc.ca", role = c("aut", "cre")),
person("Todd", "Gedamke", rol = "ctb"), person("Amy", "Then", rol = "ctb"))
Maintainer: Quang Huynh <q.huynh@oceans.ubc.ca>
Expand All @@ -16,9 +16,9 @@ Suggests: knitr, rmarkdown
VignetteBuilder: knitr
LinkingTo: TMB, RcppEigen
NeedsCompilation: yes
Packaged: 2018-05-25 17:21:55 UTC; Quang Huynh
Packaged: 2018-06-11 20:13:46 UTC; qhuynh
Author: Quang Huynh [aut, cre],
Todd Gedamke [ctb],
Amy Then [ctb]
Repository: CRAN
Date/Publication: 2018-05-27 16:34:47 UTC
Date/Publication: 2018-06-12 11:29:34 UTC
50 changes: 25 additions & 25 deletions MD5
@@ -1,14 +1,14 @@
a2bfbd5da3f81d1c4bed190d5a9f9d47 *DESCRIPTION
db88f280098c9b516e15c78710e67ae3 *DESCRIPTION
bd7b960b2ee2342aaec4f321f6552744 *NAMESPACE
737465c1192a238eadf58a9b54d56099 *R/compare_models.R
5ed4f9241521b338c8e65507203ee6bf *R/data_document.R
a3eb6ad1d483fa89b6d054c2477201cd *R/data_process.R
e057c1fb14d9db30ba366b1a4b99017e *R/estimation.R
40458cbe2cb1a732448375f0f78444e2 *R/compare_models.R
4a8acb0898d0ecbb620ffd2e6ce1455b *R/data_document.R
b956432b23ec81da3e35d9651c06715d *R/data_process.R
b1f60b696693c7dd765f953e6d9e32eb *R/estimation.R
7bfbc7515b12d01d9865b891d014a7f1 *R/internal.R
8ebaa83110642299a0f3082a400aa7f6 *R/internal_misc.R
f0e96c14b186dbfeb2d750258215e1a5 *R/methods.R
635309fad397a9fff68bdf66b96d6c90 *R/profile.R
0e9f1c06e6acd9d71ae55055951e9001 *R/sensitivity.R
777b4d1eec3871790ac32e7361ccbad2 *R/methods.R
6141e7563204fd91c8295fa763c9b538 *R/profile.R
912b8c7dccaabefcbb13bc7ec27d4e2c *R/sensitivity.R
fb7d415b92cf7f3f7133eb7df2acd2fa *README.md
d0442b41afed0f4264784a5fa2e6b6fd *build/vignette.rds
6fc1d38997fe7471562ff5c5b6529afa *data/Goosefish.rda
Expand All @@ -26,27 +26,27 @@ d465768704f11e6424f4d7cc8b06a848 *inst/include/MSM1S.h
a6678ea34d3acdd3d5f89cbc27508c8d *inst/include/MSM23.h
2a529262feeaf80b141a8d710e199dd3 *inst/include/functions.h
566a5c9c0afe7c37a49265145177ed1c *man/Goosefish.Rd
829c0c6e77aad5933276d71db6e60d3f *man/ML.Rd
128eda608ea95ea79749bb49c5076dbb *man/MLCR.Rd
5453eef399eb01017515755a2c2ee2c7 *man/ML.Rd
f2304d106b2d81daa040bd011f673759 *man/MLCR.Rd
51dde9b4e7c80ffb204aa1e85d32fe0b *man/MLZ_data-class.Rd
1b35dbd1596a27e8fffd273b0becb9dc *man/MLZ_model-class.Rd
ec4b2e9492457afd7242d9b482c26dbe *man/MLeffort.Rd
130a035db98552a0a6571844643840e7 *man/MLmulti.Rd
70762f0b28ac4c3e4a19aad2d33a576c *man/MLZ_model-class.Rd
4e558fe154d3f83986820e994c21dd7b *man/MLeffort.Rd
ce0b0d4372ab1e4efb50cd056d7757ca *man/MLmulti.Rd
457a5417f5668da705683b6a654a790d *man/MuttonSnapper.Rd
d7eaa40f07c00520e418b12df0c6add8 *man/Nephrops.Rd
94d8bc6de6b4cdba2cf29378e5ef7a07 *man/PRSnapper.Rd
6fb93e1a695923594456ed249b6f0e0f *man/SilkSnapper.Rd
6385bd46be6ffb6078f987019c9aace9 *man/bin_length.Rd
ac202d9bfa288488c95a4eaa1c27ac4d *man/calc_ML.Rd
04d17841f4e4551dc098f20ceb2d4cb2 *man/compare_models.Rd
36db446899f91a56100ef188739f16d4 *man/modal_length.Rd
efb010b7533f9c3224ac7fe480f78c09 *man/plot-MLZ_data-method.Rd
76274a033a3512810256cf87f980dec0 *man/plot-MLZ_model-method.Rd
8955fcd70f7819c418676ab88713b665 *man/profile_ML.Rd
9d36de24def67ac35214b77c5ae448dc *man/profile_MLCR.Rd
d66c6044b011e884373666e15b8368b0 *man/profile_MLmulti.Rd
ca53e6a32a1c268832ea5d76f799c378 *man/sensitivity_Lc.Rd
cd5fe95478822f9a6529f275e6ccfc4a *man/SilkSnapper.Rd
361b547958f7cddeb616a1278a99cc4a *man/bin_length.Rd
b1dc13eda0629e54e1b10039e936add7 *man/calc_ML.Rd
429ac4199fae7babb434c35dadf4414a *man/compare_models.Rd
55035f52905f5b11745766bb251b07a5 *man/modal_length.Rd
5d6ebe4523b7b188956241be014a354b *man/plot-MLZ_data-method.Rd
234925402657d752b6171cfd21add595 *man/plot-MLZ_model-method.Rd
289e0f88495c137b3bb1abe3ad6e7c10 *man/profile_ML.Rd
fa08698f8988f98090f5ce002e154e94 *man/profile_MLCR.Rd
1f25227fb8469ccb249f34fff791a5ba *man/profile_MLmulti.Rd
088af9a14c4535b8ec24ab67875a85e1 *man/sensitivity_Lc.Rd
5633222b73797e32834522c5b935a430 *man/summary-MLZ_data-method.Rd
a158a78441758dab98d0d4b2d268947f *man/summary-MLZ_model-method.Rd
ca835f2d5e1e8ff904a81d5c7b3d89e6 *man/summary-MLZ_model-method.Rd
50496dbd034f885c421cd9f1021d7d9a *src/MLZ.cpp
d48d29b5eb3a75ebcd5f87b0896a41a0 *vignettes/MLZ.Rmd
3 changes: 2 additions & 1 deletion R/compare_models.R
Expand Up @@ -10,6 +10,7 @@
#' will be used.
#'
#' @examples
#' \dontrun{
#' data(Goosefish)
#' goose <- ML(Goosefish, ncp = 0)
#' goose1 <- ML(Goosefish, ncp = 1)
Expand All @@ -24,7 +25,7 @@
#' msm3 <- MLmulti(PRSnapper, ncp = 1, model = "MSM3")
#'
#' compare_models(list(ssm, msm1, msm2, msm3))
#'
#' }
#' @export
compare_models <- function(MLZ_model.list, figure = TRUE, color = NULL) {
old_par <- par(no.readonly = TRUE)
Expand Down
3 changes: 2 additions & 1 deletion R/data_document.R
Expand Up @@ -77,7 +77,8 @@
#' Length-Based Mortality Estimator. Marine and Coastal Fisheries.
#'
#' @examples
#' \dontrun{
#' data(SilkSnapper)
#' new("MLZ_data", Len_df = SilkSnapper)
#'
#' }
"SilkSnapper"
8 changes: 6 additions & 2 deletions R/data_process.R
Expand Up @@ -14,14 +14,15 @@
#' Length frequency matrix from \code{Len_df} are created by using \code{\link[graphics]{hist}} function.
#'
#' @examples
#' \dontrun{
#' data(Nephrops)
#' modal_length(Nephrops)
#'
#' data(SilkSnapper)
#' new.dataset <- new("MLZ_data", Year = 1983:2013, Len_df = SilkSnapper)
#' modal_length(new.dataset)
#' modal_length(new.dataset, breaks = seq(80, 830, 10))
#'
#' }
#' @references
#' Hordyk, A. Ono, K., Sainsbury, K., Loneragan, N., and Prince, J. 2015. Some explorations of the
#' life history ratios to describe length composition, spawning-per-recruit, and the
Expand Down Expand Up @@ -94,10 +95,12 @@ modal_length <- function(MLZ_data, length.slot = c("Len_df", "Len_matrix"), brea
#' (whether mean lengths are calculated).
#' @return An object of class \code{\linkS4class{MLZ_data}} to fill slots \code{MeanLength}, \code{ss}.
#' @examples
#' \dontrun{
#' data(Nephrops)
#' Nephrops <- calc_ML(Nephrops, sample.size = FALSE)
#' Nephrops@MeanLength
#' plot(Nephrops)
#' }
#' @export
calc_ML <- function(MLZ_data, length.slot = c("Len_df", "Len_matrix"), sample.size = TRUE) {
length.slot <- match.arg(length.slot)
Expand Down Expand Up @@ -145,12 +148,13 @@ calc_ML <- function(MLZ_data, length.slot = c("Len_df", "Len_matrix"), sample.si
#'
#' @return A list with length bins, years, and frequency matrix.
#' @examples
#' \dontrun{
#' data(SilkSnapper)
#' Silk.matrix <- bin_length(SilkSnapper, breaks = seq(80, 830, 10))
#' Silk.matrix <- bin_length(SilkSnapper)
#' new.dataset <- new("MLZ_data", Year = Silk.matrix$Year, Len_bins = Silk.matrix$Len_bins,
#' Len_matrix = Silk.matrix$Len_matrix)
#'
#' }
#' @export
bin_length <- function(df, breaks = NULL) {
df <- as.data.frame(df)
Expand Down
30 changes: 18 additions & 12 deletions R/estimation.R
Expand Up @@ -29,11 +29,12 @@
#' Transactions of the American Fisheries Society 135:476-487.
#' @return An object of class \code{\linkS4class{MLZ_model}}.
#' @examples
#' \dontrun{
#' data(Goosefish)
#' ML(Goosefish, ncp = 2)
#' ML(Goosefish, ncp = 2, start = list(Z = c(0.1, 0.3, 0.5), yearZ = c(1978, 1988)))
#' ML(Goosefish, ncp = 2, grid.search = TRUE)
#'
#' res <- ML(Goosefish, ncp = 2)
#' res <- ML(Goosefish, ncp = 2, start = list(Z = c(0.1, 0.3, 0.5), yearZ = c(1978, 1988)))
#' res <- ML(Goosefish, ncp = 2, grid.search = TRUE)
#' }
#' @seealso \code{\link{profile_ML}}
#' @export
ML <- function(MLZ_data, ncp, start = NULL, grid.search = TRUE,
Expand Down Expand Up @@ -160,9 +161,10 @@ ML <- function(MLZ_data, ncp, start = NULL, grid.search = TRUE,
#' Otherwise, the starting values for \code{yearZ} evenly divide the time series.
#'
#' @examples
#' \dontrun{
#' data(MuttonSnapper)
#' MLCR(MuttonSnapper, ncp = 2, CPUE.type = "WPUE", grid.search = TRUE)
#'
#' }
#' @seealso \code{\link{profile_MLCR}}
#'
#' @export
Expand Down Expand Up @@ -342,22 +344,24 @@ MLCR <- function(MLZ_data, ncp, CPUE.type = c(NA, "WPUE", "NPUE"), loglikeCPUE =
#' @seealso \code{\link{profile_MLmulti}}
#'
#' @examples
#' \dontrun{
#' data(PRSnapper)
#' MLmulti(PRSnapper, ncp = 0, start = list(Z = matrix(0.5, nrow = 1, ncol = 3)))
#' MLmulti(PRSnapper, ncp = 1, model = "SSM")
#' res_eq <- MLmulti(PRSnapper, ncp = 0, start = list(Z = matrix(0.5, nrow = 1, ncol = 3)))
#' res_SSM <- MLmulti(PRSnapper, ncp = 1, model = "SSM")
#'
#' MSM1.start.Z <- matrix(0.5, nrow = 2, ncol = 3)
#' MSM1.start.yearZ <- 1990
#' start.list <- list(Z = MSM1.start.Z, yearZ = MSM1.start.yearZ)
#' MLmulti(PRSnapper, ncp = 1, model = "MSM1", start = start.list, grid.search = FALSE)
#' res_MSM1 <- MLmulti(PRSnapper, ncp = 1, model = "MSM1", start = start.list, grid.search = FALSE)
#'
#' MLmulti(PRSnapper, ncp = 1, model = "MSM2")
#' res_MSM2 <- MLmulti(PRSnapper, ncp = 1, model = "MSM2")
#'
#' st.Z1 <- rep(0.5, 3)
#' st.yearZ <- 1990
#' st.delta <- 1
#' start.list <- list(Z1 = st.Z1, yearZ = st.yearZ, delta = st.delta)
#' MLmulti(PRSnapper, ncp = 1, model = "MSM3", start = start.list)
#' resMSM3 <- MLmulti(PRSnapper, ncp = 1, model = "MSM3", start = start.list)
#' }
#' @export
MLmulti <- function(MLZ.list, ncp, model = c("SSM", "MSM1", "MSM2", "MSM3"), start = NULL,
grid.search = TRUE, parallel = ifelse(ncp > 2, TRUE, FALSE),
Expand Down Expand Up @@ -589,10 +593,12 @@ MLmulti <- function(MLZ.list, ncp, model = c("SSM", "MSM1", "MSM2", "MSM3"), sta
#' @return An object of class \code{\linkS4class{MLZ_model}}.
#'
#' @examples
#' \dontrun{
#' data(Nephrops)
#' Nephrops <- calc_ML(Nephrops, sample.size = FALSE)
#' MLeffort(Nephrops, start = list(q = 0.1, M = 0.2),
#' n_age = 24, eff_init = Nephrops@Effort[1])
#' res <- MLeffort(Nephrops, start = list(q = 0.1, M = 0.2),
#' n_age = 24, eff_init = Nephrops@@Effort[1])
#' }
#' @export
MLeffort <- function(MLZ_data, start, n_age, estimate.M = TRUE, log.par = FALSE,
eff_init = 0, n_season = 1L, obs_season = 1L, timing = 0, figure = TRUE) {
Expand Down
11 changes: 8 additions & 3 deletions R/methods.R
Expand Up @@ -65,13 +65,14 @@ MLZ_data <- setClass("MLZ_data", slots = c(Stock = "character", Year = "vector",
#' @slot length.units Unit of measurement for lengths, i.e. "cm" or "mm".
#'
#' @examples
#' \dontrun{
#' data(Goosefish)
#' goose.model <- ML(Goosefish, ncp = 2, grid.search = FALSE, figure = FALSE)
#' class(goose.model)
#'
#' summary(goose.model)
#' plot(goose.model, residuals = FALSE)
#'
#' }
#' @export
setClass("MLZ_model", slots = c(Stock = "character", Model = "character", time.series = "data.frame",
estimates = "matrix", negLL = "numeric",
Expand Down Expand Up @@ -106,10 +107,11 @@ setMethod("summary", signature(object = "MLZ_data"), function(object) {
#'
#' @param object An object of class \code{MLZ_model}.
#' @examples
#' \dontrun{
#' data(Goosefish)
#' goose.model <- ML(Goosefish, ncp = 2, grid.search = FALSE)
#' summary(goose.model)
#'
#' }
#' @export
setMethod("summary", signature(object = "MLZ_model"), function(object)
list(Stock = object@Stock, Model = object@Model, Estimates = round(object@estimates, 3)))
Expand All @@ -128,9 +130,10 @@ setMethod("summary", signature(object = "MLZ_model"), function(object)
#' @param x An object of class \code{MLZ_data}.
#' @param ggplot_layer Layers to add to ggplot2 plot.
#' @examples
#' \dontrun{
#' data(Nephrops)
#' plot(Nephrops)
#'
#' }
#' @export
setMethod("plot", signature(x = "MLZ_data"), function(x, ggplot_layer = NULL) {
MLZ_data <- x
Expand Down Expand Up @@ -216,9 +219,11 @@ setMethod("plot", signature(x = "MLZ_data"), function(x, ggplot_layer = NULL) {
#' @param x An object of class \code{MLZ_model}.
#' @param residuals logical; whether a plot of residuals will also be produced.
#' @examples
#' \dontrun{
#' data(Goosefish)
#' goose.model <- ML(Goosefish, ncp = 2, grid.search = FALSE, figure = FALSE)
#' plot(goose.model)
#' }
#' @export
setMethod("plot", signature(x = "MLZ_model"), function(x, residuals = TRUE) {
MLZ_model <- x
Expand Down
8 changes: 6 additions & 2 deletions R/profile.R
Expand Up @@ -15,10 +15,11 @@
#' \code{ncp = 2}.
#' @return A matrix of change points with the negative log-likelihood values.
#' @examples
#' \dontrun{
#' data(Goosefish)
#' profile_ML(Goosefish, ncp = 1)
#' profile_ML(Goosefish, ncp = 2)
#'
#' }
#' @references
#' Gedamke, T. and Hoenig, J.M. 2006. Estimating mortality from mean length data in
#' nonequilibrium situations, with application to the assessment of goosefish.
Expand Down Expand Up @@ -148,8 +149,10 @@ profile_ML <- function(MLZ_data, ncp, startZ = rep(0.5, ncp+1), min.time = 3,
#' to a Nonequilibrium Length-Based Mortality Estimator. Marine and Coastal Fisheries 9:68-78.
#'
#' @examples
#' \dontrun{
#' data(MuttonSnapper)
#' profile_MLCR(MuttonSnapper, ncp = 1, CPUE.type = 'WPUE')
#' }
#' @export
profile_MLCR <- function(MLZ_data, ncp, CPUE.type = c(NA, "NPUE", "WPUE"),
loglikeCPUE = c("normal", "lognormal"), startZ = rep(0.5, ncp+1), min.time = 3,
Expand Down Expand Up @@ -277,9 +280,10 @@ profile_MLCR <- function(MLZ_data, ncp, CPUE.type = c(NA, "NPUE", "WPUE"),
#' to a Nonequilibrium Length-Based Mortality Estimator. Marine and Coastal Fisheries 9:68-78.
#'
#' @examples
#' \dontrun{
#' data(PRSnapper)
#' profile_MLmulti(PRSnapper, ncp = 1, model = "MSM1")
#'
#' }
#' @export
profile_MLmulti <- function(MLZ.list, ncp, model = c("SSM", "MSM1", "MSM2", "MSM3"),
startZ1 = rep(0.5, length(MLZ.list)),
Expand Down
3 changes: 2 additions & 1 deletion R/sensitivity.R
Expand Up @@ -17,6 +17,7 @@
#' to a Nonequilibrium Length-Based Mortality Estimator. Marine and Coastal Fisheries 9:68-78.
#'
#' @examples
#' \dontrun{
#' data(SilkSnapper)
#' new.dataset <- new("MLZ_data", Year = 1983:2013, Len_df = SilkSnapper, length.units = "mm",
#' vbLinf = 794, vbK = 0.1)
Expand All @@ -28,7 +29,7 @@
#' Lc.vec <- seq(240, 340, 5)
#'
#' sensitivity_Lc(new.dataset, first.MLZmodel, Lc.vec)
#'
#' }
#' @seealso \code{\link{ML}}
#' @export
sensitivity_Lc <- function(MLZ_data, MLZ_model, Lc.vec, grid.search = FALSE, figure = TRUE) {
Expand Down
9 changes: 5 additions & 4 deletions man/ML.Rd

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

3 changes: 2 additions & 1 deletion man/MLCR.Rd

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

3 changes: 2 additions & 1 deletion man/MLZ_model-class.Rd

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

6 changes: 4 additions & 2 deletions man/MLeffort.Rd

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

0 comments on commit 8315764

Please sign in to comment.