Skip to content

Commit

Permalink
Add datasets (#19)
Browse files Browse the repository at this point in the history
Added example datasets and documentation for them including citations.

* Added datasets and testing. Working on documentation.

* Updated data file documentation.

* Slightly updated description of metabolic data to not have a copy-paste of lizard size info.

* Forgot to change format reference name.

* Removed metabolic rate data as it's not set up for DE fitting.

* Removed .rd file for metabolic data.

* Updated vb model to have a y_max parameter pass in as the initial mean estimate of the maximum value in order to avoid intialisation problems.

* Updated example G. recondita data to avoid individuals with <1.5cm growth over observation period.

* Replaced G. recondita with H. triandra data because I forgot I need to not double-up on first paper.

* Removed vB model as it needs fixing on its own branch.

* Removed vb from the switch call in rmot_models.R

* Added P. tenufolium small tree data.

* Updated documentation of data to have correct sample size.

* Forcing update of documentation.

* Finally got the documentation to work.
  • Loading branch information
Tess-LaCoil authored May 3, 2024
1 parent 37693f7 commit c3ccaa8
Show file tree
Hide file tree
Showing 26 changed files with 255 additions and 2,349 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ src/rmot.dll

# Bugged directory from snapshot package
tests/testthat/_snaps

# Data prep files
data-raw/
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ Suggests:
mnormt
VignetteBuilder: knitr
Config/testthat/edition: 3
LazyData: true
87 changes: 87 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#' SUSTAIN Salmo trutta data
#'
#' A subset of data from the SUSTAIN trout capture-recapture data set
#' from Moe et al. (2020).
#' Data prepared by taking a stratified sample of individual IDs based on the
#' number of observations per individual: 25 individuals with 2 observations,
#' 15 with 3, 10 with 4. Within the groups a simple random sample
#' without replacement was used. Data was then transformed and
#' renamed to match the required structure to act as demonstration for
#' the package.
#'
#' @format ## `Trout_Size_Data`
#' A data frame with 135 rows and 4 columns:
#' \describe{
#' \item{ind_id}{ID number for individual}
#' \item{time}{Years since first capture and tagging of individual.}
#' \item{y_obs}{Individual length in centimetres.}
#' \item{obs_index}{Index of observations for individual}
#' }
#' @source <https://doi.org/10.3897/BDJ.8.e52157>
"Trout_Size_Data"

#' Skink size data - Lampropholis delicata
#'
#' A subset of data from Kar, Nakagawa, and Noble (2024), used to model growth
#' behaviour in a skink species.
#' Data was prepared by taking a simple random sample with replacement of 50
#' individual IDs among individuals with at least 5 observations each. Data was
#' then transformed to conform to the needs of a model data set in the package.
#'
#' @format ## `Lizard_Mass_Data`
#' A data frame with 336 rows and 4 columns:
#' \describe{
#' \item{ind_id}{ID number for individual}
#' \item{time}{Days since first observation.}
#' \item{y_obs}{Individual mass in kilograms.}
#' \item{obs_index}{Index of observations for individual}
#' }
#'
#' @source \url{https://osf.io/hjkxd/}
"Lizard_Mass_Data"

#' Protium tenufolium - Barro Colorado Island data
#'
#' A subset of data from the Barro Colorado Island long term forest plot
#' managed by the Smithsonian Tropical Research Institute (Condit et al. 2019).
#' Data was prepared by taking a simple random sample without replacement of
#' 30 individual IDs from Protium tenufolium.
#' The sampling frame was restricted to individuals with individuals under 10cm
#' for the max observed DBH, 6 observations since 1990. Data was then
#' transformed and renamed to match the required structure
#' to act as demonstration for the package.
#'
#' @format ## `Small_Tree_Size_Data`
#' A data frame with 180 rows and 4 columns:
#' \describe{
#' \item{ind_id}{ID number for individual}
#' \item{time}{Years since first observation.}
#' \item{y_obs}{Individual diameter at breast height (DBH) in centimetres.}
#' \item{obs_index}{Index of observations for individual}
#' }
#' @references \url{https://doi.org/10.1002/ecy.4140}
#' @source \url{https://doi.org/10.15146/5xcp-0d46}
"Small_Tree_Size_Data"

#' Hirtella triandra - Barro Colorado Island data
#'
#' A subset of data from the Barro Colorado Island long term forest plot
#' managed by the Smithsonian Tropical Research Institute (Condit et al. 2019).
#' Data was prepared by taking a simple random sample without replacement of
#' 30 individual IDs from Hirtella triandra. The sampling frame was restricted
#' to individuals with 6 observations since 1990, and a difference between
#' observed max and min sizes of more than 7cm in order to avoid identifiability
#' issues. Data was then transformed and renamed to match the required structure
#' to act as demonstration for the package.
#'
#' @format ## `Tree_Size_Data`
#' A data frame with 180 rows and 4 columns:
#' \describe{
#' \item{ind_id}{ID number for individual}
#' \item{time}{Years since first observation.}
#' \item{y_obs}{Individual diameter at breast height (DBH) in centimetres.}
#' \item{obs_index}{Index of observations for individual}
#' }
#' @references \url{https://doi.org/10.1002/ecy.4140}
#' @source \url{https://doi.org/10.15146/5xcp-0d46}
"Tree_Size_Data"
34 changes: 1 addition & 33 deletions R/rmot_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ rmot_model <- function(model=NULL){
canham_single_ind = rmot_canham_single_ind(),
canham_multi_ind = rmot_canham_multi_ind(),
power_single_ind = rmot_power_single_ind(),
power_multi_ind = rmot_power_multi_ind(),
vb_single_ind = rmot_vb_single_ind(),
vb_multi_ind = rmot_vb_multi_ind())
power_multi_ind = rmot_power_multi_ind())

class(output) <- "rmot_object"

Expand Down Expand Up @@ -128,33 +126,3 @@ rmot_power_multi_ind <- function(){
y_0_obs = NULL,
model = "power_multi_ind")
}

#' Data configuration template for von Bertalanffy growth single individual model
#' @keywords internal
#' @noRd

rmot_vb_single_ind <- function(){
list(step_size = NULL,
n_obs = NULL,
y_obs = NULL,
obs_index = NULL,
time = NULL,
y_0_obs = NULL,
model = "vb_single_ind")
}

#' Data configuration template for von Bertalanffy growth single species model
#' @keywords internal
#' @noRd

rmot_vb_multi_ind <- function(){
list(step_size = NULL,
n_obs = NULL,
n_ind = NULL,
y_obs = NULL,
obs_index = NULL,
time = NULL,
ind_id = NULL,
y_0_obs = NULL,
model = "vb_multi_ind")
}
4 changes: 1 addition & 3 deletions R/rmot_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ rmot_run <- function(model_template, ...) {
canham_single_ind = rstan::sampling(stanmodels$canham_single_ind, data = model_template, ...),
canham_multi_ind = rstan::sampling(stanmodels$canham_multi_ind, data = model_template, ...),
power_single_ind = rstan::sampling(stanmodels$power_single_ind, data = model_template, ...),
power_multi_ind = rstan::sampling(stanmodels$power_multi_ind, data = model_template, ...),
vb_single_ind = rstan::sampling(stanmodels$vb_single_ind, data = model_template, ...),
vb_multi_ind = rstan::sampling(stanmodels$vb_multi_ind, data = model_template, ...))
power_multi_ind = rstan::sampling(stanmodels$power_multi_ind, data = model_template, ...))

return(out)
}
4 changes: 1 addition & 3 deletions R/stanmodels.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by rstantools. Do not edit by hand.

# names of stan models
stanmodels <- c("canham_multi_ind", "canham_single_ind", "constant_multi_ind", "constant_single_ind", "linear", "power_multi_ind", "power_single_ind", "vb_multi_ind", "vb_single_ind")
stanmodels <- c("canham_multi_ind", "canham_single_ind", "constant_multi_ind", "constant_single_ind", "linear", "power_multi_ind", "power_single_ind")

# load each stan module
Rcpp::loadModule("stan_fit4canham_multi_ind_mod", what = TRUE)
Expand All @@ -11,8 +11,6 @@ Rcpp::loadModule("stan_fit4constant_single_ind_mod", what = TRUE)
Rcpp::loadModule("stan_fit4linear_mod", what = TRUE)
Rcpp::loadModule("stan_fit4power_multi_ind_mod", what = TRUE)
Rcpp::loadModule("stan_fit4power_single_ind_mod", what = TRUE)
Rcpp::loadModule("stan_fit4vb_multi_ind_mod", what = TRUE)
Rcpp::loadModule("stan_fit4vb_single_ind_mod", what = TRUE)

# instantiate each stanmodel object
stanmodels <- sapply(stanmodels, function(model_name) {
Expand Down
Binary file added data/Lizard_Mass_Data.rda
Binary file not shown.
Binary file added data/Small_Tree_Size_Data.rda
Binary file not shown.
Binary file added data/Tree_Size_Data.rda
Binary file not shown.
Binary file added data/Trout_Size_Data.rda
Binary file not shown.
147 changes: 0 additions & 147 deletions inst/stan/vb_multi_ind.stan

This file was deleted.

Loading

0 comments on commit c3ccaa8

Please sign in to comment.