Package 'bboutools'

Title: Boreal Caribou Survival, Recruitment and Population Growth
Description: Estimates annual survival, recruitment and population growth for boreal caribou populations using Bayesian and Maximum Likelihood models with fixed and random effects.
Authors: Seb Dalgarno [aut, cre] , Joe Thorley [aut] , John Boulanger [aut] , Ayla Pearson [aut], Environment and Climate Change Canada [cph]
Maintainer: Seb Dalgarno <[email protected]>
License: Apache License (== 2.0) | file LICENSE
Version: 0.1.0
Built: 2024-10-28 17:16:37 UTC
Source: https://github.com/poissonconsulting/bboutools

Help Index


Get Augmented Data from bboufit Object

Description

Get a tibble of the original data with augmentation.

Usage

## S3 method for class 'bboufit'
augment(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A tibble of the augmented data.

See Also

Other generics: augment.bboufit_ml(), glance.bboufit(), glance.bboufit_ml(), tidy.bboufit(), tidy.bboufit_ml()

Examples

if (interactive()) {
  fit <- bb_fit_survival(bboudata::bbousurv_a)
  augment(fit)
}

Get Augmented Data from bboufit_ml Object

Description

Get a tibble of the original data with augmentation.

Usage

## S3 method for class 'bboufit_ml'
augment(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A tibble of the augmented data.

See Also

Other generics: augment.bboufit(), glance.bboufit(), glance.bboufit_ml(), tidy.bboufit(), tidy.bboufit_ml()

Examples

if (interactive()) {
  fit <- bb_fit_survival_ml(bboudata::bbousurv_a)
  augment(fit)
}

Fit Recruitment Model

Description

Fit heirarchical Bayesian recruitment model using Nimble.

Usage

bb_fit_recruitment(
  data,
  adult_female_proportion = 0.65,
  sex_ratio = 0.5,
  min_random_year = 5,
  year_trend = FALSE,
  year_start = 4L,
  nthin = 10,
  niters = 1000,
  priors = NULL,
  quiet = FALSE
)

Arguments

data

The data.frame.

adult_female_proportion

A number between 0 and 1 of the expected proportion of adults that are female. If NULL, the proportion is estimated from the data (i.e., Cows ~ Binomial(adult_female_proportion, Cows + Bulls)) and a prior of dbeta(65, 35) is used. This prior can be changed via the priors argument.

sex_ratio

A number between 0 and 1 of the proportion of females at birth. This proportion is applied to yearlings.

min_random_year

A whole number of the minimum number of years required to fit year as a random effect (as opposed to a fixed effect).

year_trend

A flag indicating whether to fit a year trend effect. Year trend cannot be fit if there is also a fixed year effect (as opposed to random effect).

year_start

A whole number between 1 and 12 indicating the start of the caribou (i.e., biological) year. By default, April is set as the start of the caribou year.

nthin

A whole number of the thinning rate.

niters

A whole number of the number of iterations per chain after thinning and burn-in.

priors

A named vector of the parameter prior distribution values. Any missing values are assigned their default values in priors_survival() and priors_recruitment(). If NULL, all parameters are assigned their default priors.

quiet

A flag indicating whether to suppress messages and progress bars.

Details

If the number of years is > min_random_year, a fixed-effects model is fit. Otherwise, a mixed-effects model is fit with random intercept for each year. If year_trend is TRUE and the number of years is > min_random_year, the model will be fit with year as a continuous effect (i.e. trend) and no fixed effect of year. If year_trend is TRUE and the number of years is <= min_random_year, the model will be fit with year as a continuous effect and a random intercept for each year.

The start month of the Caribou year can be adjusted with year_start.

Value

A list of the Nimble model object, data and mcmcr samples.

See Also

Other model: bb_fit_recruitment_ml(), bb_fit_survival(), bb_fit_survival_ml()

Examples

if (interactive()) {
  fit <- bb_fit_recruitment(bboudata::bbourecruit_a)
}

Fit Recruitment Model with Maximum Likelihood

Description

Fit recruitment model with Maximum Likelihood using Nimble Laplace Approximation.

Usage

bb_fit_recruitment_ml(
  data,
  adult_female_proportion = 0.65,
  sex_ratio = 0.5,
  min_random_year = 5,
  year_trend = FALSE,
  year_start = 4L,
  inits = NULL,
  quiet = FALSE
)

Arguments

data

The data.frame.

adult_female_proportion

A number between 0 and 1 of the expected proportion of adults that are female. If NULL, the proportion is estimated from the data (i.e., Cows ~ Binomial(adult_female_proportion, Cows + Bulls)) and a prior of dbeta(65, 35) is used. This prior can be changed via the priors argument.

sex_ratio

A number between 0 and 1 of the proportion of females at birth. This proportion is applied to yearlings.

min_random_year

A whole number of the minimum number of years required to fit year as a random effect (as opposed to a fixed effect).

year_trend

A flag indicating whether to fit a year trend effect. Year trend cannot be fit if there is also a fixed year effect (as opposed to random effect).

year_start

A whole number between 1 and 12 indicating the start of the caribou (i.e., biological) year. By default, April is set as the start of the caribou year.

inits

A named vector of the parameter initial values. Any missing values are assigned a default value of 0. If NULL, all parameters are assigned a default value of 0.

quiet

A flag indicating whether to suppress messages and progress bars.

Details

If the number of years is > min_random_year, a fixed-effects model is fit. Otherwise, a mixed-effects model is fit with random intercept for each year. If year_trend is TRUE and the number of years is > min_random_year, the model will be fit with year as a continuous effect (i.e. trend) and no fixed effect of year. If year_trend is TRUE and the number of years is <= min_random_year, the model will be fit with year as a continuous effect and a random intercept for each year.

The start month of the Caribou year can be adjusted with year_start.

Value

A list of the Nimble model object and Maximum Likelihood output with estimates and standard errors on the transformed scale.

See Also

Other model: bb_fit_recruitment(), bb_fit_survival(), bb_fit_survival_ml()

Examples

if (interactive()) {
  fit <- bb_fit_recruitment_ml(bboudata::bbourecruit_a)
}

Fit Survival Model

Description

Fits hierarchical Bayesian survival model using Nimble.

Usage

bb_fit_survival(
  data,
  min_random_year = 5,
  year_trend = FALSE,
  include_uncertain_morts = TRUE,
  year_start = 4L,
  nthin = 10,
  niters = 1000,
  priors = NULL,
  quiet = FALSE
)

Arguments

data

The data.frame.

min_random_year

A whole number of the minimum number of years required to fit year as a random effect (as opposed to a fixed effect).

year_trend

A flag indicating whether to fit a year trend effect. Year trend cannot be fit if there is also a fixed year effect (as opposed to random effect).

include_uncertain_morts

A flag indicating whether to include uncertain mortalities in total mortalities.

year_start

A whole number between 1 and 12 indicating the start of the caribou (i.e., biological) year. By default, April is set as the start of the caribou year.

nthin

A whole number of the thinning rate.

niters

A whole number of the number of iterations per chain after thinning and burn-in.

priors

A named vector of the parameter prior distribution values. Any missing values are assigned their default values in priors_survival() and priors_recruitment(). If NULL, all parameters are assigned their default priors.

quiet

A flag indicating whether to suppress messages and progress bars.

Details

If the number of years is > min_random_year, a fixed-effects model is fit. Otherwise, a mixed-effects model is fit with random intercept for each year. If year_trend is TRUE and the number of years is > min_random_year, the model will be fit with year as a continuous effect (i.e. trend) and no fixed effect of year. If year_trend is TRUE and the number of years is <= min_random_year, the model will be fit with year as a continuous effect and a random intercept for each year.

The model is always fit with random intercept for each month.

The start month of the Caribou year can be adjusted with year_start.

Value

A list of the Nimble model object, data and mcmcr samples.

See Also

Other model: bb_fit_recruitment(), bb_fit_recruitment_ml(), bb_fit_survival_ml()

Examples

if (interactive()) {
  fit <- bb_fit_survival(bboudata::bbousurv_a)
}

Fit Survival Model with Maximum Likelihood

Description

Fits hierarchical survival model with Maximum Likelihood using Nimble Laplace approximation.

Usage

bb_fit_survival_ml(
  data,
  min_random_year = 5,
  year_trend = FALSE,
  include_uncertain_morts = FALSE,
  year_start = 4L,
  inits = NULL,
  quiet = FALSE
)

Arguments

data

The data.frame.

min_random_year

A whole number of the minimum number of years required to fit year as a random effect (as opposed to a fixed effect).

year_trend

A flag indicating whether to fit a year trend effect. Year trend cannot be fit if there is also a fixed year effect (as opposed to random effect).

include_uncertain_morts

A flag indicating whether to include uncertain mortalities in total mortalities.

year_start

A whole number between 1 and 12 indicating the start of the caribou (i.e., biological) year. By default, April is set as the start of the caribou year.

inits

A named vector of the parameter initial values. Any missing values are assigned a default value of 0. If NULL, all parameters are assigned a default value of 0.

quiet

A flag indicating whether to suppress messages and progress bars.

Details

If the number of years is > min_random_year, a fixed-effects model is fit. Otherwise, a mixed-effects model is fit with random intercept for each year. If year_trend is TRUE and the number of years is > min_random_year, the model will be fit with year as a continuous effect (i.e. trend) and no fixed effect of year. If year_trend is TRUE and the number of years is <= min_random_year, the model will be fit with year as a continuous effect and a random intercept for each year.

The model is always fit with random intercept for each month.

The start month of the Caribou year can be adjusted with year_start.

Value

A list of the Nimble model object and Maximum Likelihood output with estimates and standard errors on the transformed scale.

See Also

Other model: bb_fit_recruitment(), bb_fit_recruitment_ml(), bb_fit_survival()

Examples

if (interactive()) {
  fit <- bb_fit_survival_ml(bboudata::bbousurv_a)
}

Plot Month

Description

Plots month estimates with credible limits.

Usage

bb_plot_month(x, ...)

## S3 method for class 'data.frame'
bb_plot_month(x, ...)

## S3 method for class 'bboufit_survival'
bb_plot_month(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_month(data.frame): Plot monthly estimate for a data frame.

  • bb_plot_month(bboufit_survival): Plot monthly estimates for a bboufit_survival object.


Plot Monthly Survival

Description

Plots monthly survival estimates with credible limits. Estimates represent annual survival if a given month lasted the entire year.

Usage

bb_plot_month_survival(x, ...)

## S3 method for class 'data.frame'
bb_plot_month_survival(x, ...)

## S3 method for class 'bboufit_survival'
bb_plot_month_survival(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_month_survival(data.frame): Plot monthly survival estimate for a data frame.

  • bb_plot_month_survival(bboufit_survival): Plot monthly survival estimates for a bboufit_survival object.


Plot Year

Description

Plots annual estimates with credible limits.

Usage

bb_plot_year(x, ...)

## S3 method for class 'data.frame'
bb_plot_year(x, ...)

## S3 method for class 'bboufit'
bb_plot_year(x, conf_level = 0.95, estimate = median, ...)

## S3 method for class 'bboufit_ml'
bb_plot_year(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_year(data.frame): Plot annual estimate for a data frame.

  • bb_plot_year(bboufit): Plot annual estimates for a bboufit object.

  • bb_plot_year(bboufit_ml): Plot annual estimates for a bboufit_ml object.


Plot Year Population Growth

Description

Plots annual population growth with credible limits.

Usage

bb_plot_year_growth(x)

Arguments

x

A data frame of the lambda estimates (output of bb_predict_growth()).


Plot Year Population Change

Description

Plots annual population change (%) with credible limits.

Usage

bb_plot_year_population_change(x)

Arguments

x

A data frame of the population change estimates (output of bb_predict_population_change()).


Plot Year Recruitment

Description

Plot annual recruitment estimates with credible limits. Recruitment is adjusted following DeCesare et al. (2012) methods.

Usage

bb_plot_year_recruitment(x, ...)

## S3 method for class 'data.frame'
bb_plot_year_recruitment(x, ...)

## S3 method for class 'bboufit_recruitment'
bb_plot_year_recruitment(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_year_recruitment(data.frame): Plot annual recruitment estimate for a data frame.

  • bb_plot_year_recruitment(bboufit_recruitment): Plot annual recruitment estimates for a bboufit_recruitment object.

References

DeCesare, Nicholas J., Mark Hebblewhite, Mark Bradley, Kirby G. Smith, David Hervieux, and Lalenia Neufeld. 2012 “Estimating Ungulate Recruitment and Growth Rates Using Age Ratios.” The Journal of Wildlife Management 76 (1): 144–53 https://doi.org/10.1002/jwmg.244.


Plot Year Survival

Description

Plots annual survival estimates with credible limits.

Usage

bb_plot_year_survival(x, ...)

## S3 method for class 'data.frame'
bb_plot_year_survival(x, ...)

## S3 method for class 'bboufit_survival'
bb_plot_year_survival(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_year_survival(data.frame): Plot annual survival estimate for a data frame.

  • bb_plot_year_survival(bboufit_survival): Plot annual survival estimates for a bboufit_survival object.


Plot Annual Recruitment Trend

Description

Plots annual recruitment estimates as trend line with credible limits.

Usage

bb_plot_year_trend_recruitment(x, ...)

## S3 method for class 'data.frame'
bb_plot_year_trend_recruitment(x, ...)

## S3 method for class 'bboufit_recruitment'
bb_plot_year_trend_recruitment(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_year_trend_recruitment(data.frame): Plot annual recruitment estimate as trend line for a data frame.

  • bb_plot_year_trend_recruitment(bboufit_recruitment): Plot annual estimates as trend line for a bboufit_recruitment object.


Plot Annual Survival Trend

Description

Plots annual survival estimates as trend line with credible limits.

Usage

bb_plot_year_trend_survival(x, ...)

## S3 method for class 'data.frame'
bb_plot_year_trend_survival(x, ...)

## S3 method for class 'bboufit_survival'
bb_plot_year_trend_survival(x, conf_level = 0.95, estimate = median, ...)

Arguments

x

The object.

...

Unused parameters.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

Methods (by class)

  • bb_plot_year_trend_survival(data.frame): Plot annual survival estimate as trend line for a data frame.

  • bb_plot_year_trend_survival(bboufit_survival): Plot annual estimates as trend line for a bboufit_survival object.


Predict Calf-Cow Ratio

Description

Predict calves per adult female by year. If year is FALSE, predictions are made for a 'typical' year.

Usage

bb_predict_calf_cow_ratio(
  recruitment,
  year = TRUE,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3
)

Arguments

recruitment

An object of class 'bboufit_recruitment' (output of bb_fit_recruitment())

year

A flag indicating whether to predict by year.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the predicted estimates.

See Also

Other analysis: bb_predict_growth(), bb_predict_population_change(), bb_predict_recruitment(), bb_predict_recruitment_trend(), bb_predict_survival(), bb_predict_survival_trend()


Predict Population Growth Lambda

Description

Predicts population growth (lambda) from survival and recruitment fit objects using the Hatter-Bergerud equation (Hatter and Bergerud, 1991).

Usage

bb_predict_growth(
  survival,
  recruitment,
  sex_ratio = 0.5,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3
)

bb_predict_lambda(
  survival,
  recruitment,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3
)

Arguments

survival

An object of class 'bboufit_survival' (output of bb_fit_survival()).

recruitment

An object of class 'bboufit_recruitment' (output of bb_fit_recruitment())

sex_ratio

A number between 0 and 1 of the proportion of females at birth.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the lambda estimates with upper and lower credible intervals.

Functions

  • bb_predict_lambda(): Deprecated for bb_predict_growth() [Deprecated]

References

Hatter, Ian, and Wendy Bergerud. 1991. “Moose Recruitment, Adult Mortality and Rate of Change” 27: 65–73.

See Also

Other analysis: bb_predict_calf_cow_ratio(), bb_predict_population_change(), bb_predict_recruitment(), bb_predict_recruitment_trend(), bb_predict_survival(), bb_predict_survival_trend()

Examples

if (interactive()) {
  survival <- bb_fit_survival(bboudata::bbousurv_a)
  recruitment <- bb_fit_recruitment(bboudata::bbourecruit_a)
  growth <- bb_predict_growth(survival, recruitment)
}

Predict Population Change

Description

Predicts population change (%) from survival and recruitment fit objects. Population change is the cumulative product of population growth rate (i.e., output of bb_predict_growth())

Usage

bb_predict_population_change(
  survival,
  recruitment,
  sex_ratio = 0.5,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3
)

Arguments

survival

An object of class 'bboufit_survival' (output of bb_fit_survival()).

recruitment

An object of class 'bboufit_recruitment' (output of bb_fit_recruitment())

sex_ratio

A number between 0 and 1 of the proportion of females at birth.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the population change estimates with upper and lower credible intervals.

See Also

Other analysis: bb_predict_calf_cow_ratio(), bb_predict_growth(), bb_predict_recruitment(), bb_predict_recruitment_trend(), bb_predict_survival(), bb_predict_survival_trend()

Examples

if (interactive()) {
  survival <- bb_fit_survival(bboudata::bbousurv_a)
  recruitment <- bb_fit_recruitment(bboudata::bbourecruit_a)
  change <- bb_predict_population_change(survival, recruitment)
}

Predict Recruitment

Description

Predict adjusted recruitment by year using DeCesare et al. (2012) methods. If year is FALSE, predictions are made for a 'typical' year. See bb_predict_calf_cow_ratio() for unadjusted recruitment.

Usage

bb_predict_recruitment(
  recruitment,
  year = TRUE,
  sex_ratio = 0.5,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3
)

Arguments

recruitment

An object of class 'bboufit_recruitment' (output of bb_fit_recruitment())

year

A flag indicating whether to predict by year.

sex_ratio

A number between 0 and 1 of the proportion of females at birth.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the predicted estimates.

References

DeCesare, Nicholas J., Mark Hebblewhite, Mark Bradley, Kirby G. Smith, David Hervieux, and Lalenia Neufeld. 2012 “Estimating Ungulate Recruitment and Growth Rates Using Age Ratios.” The Journal of Wildlife Management 76 (1): 144–53 https://doi.org/10.1002/jwmg.244.

See Also

Other analysis: bb_predict_calf_cow_ratio(), bb_predict_growth(), bb_predict_population_change(), bb_predict_recruitment_trend(), bb_predict_survival(), bb_predict_survival_trend()


Predict Recruitment Trend

Description

Predict recruitment by year as trend line. Recruitment fit object provided must be created with year_trend = TRUE.

Usage

bb_predict_recruitment_trend(
  recruitment,
  sex_ratio = 0.5,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 5
)

Arguments

recruitment

An object of class 'bboufit_recruitment' (output of bb_fit_recruitment())

sex_ratio

A number between 0 and 1 of the proportion of females at birth.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the predicted estimates.

See Also

Other analysis: bb_predict_calf_cow_ratio(), bb_predict_growth(), bb_predict_population_change(), bb_predict_recruitment(), bb_predict_survival(), bb_predict_survival_trend()


Predict Survival

Description

Predict survival by year and/or month. If year and month are FALSE, predictions are made for a 'typical' year and month.

Usage

bb_predict_survival(
  survival,
  year = TRUE,
  month = FALSE,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3
)

Arguments

survival

An object of class 'bboufit_survival' (output of bb_fit_survival()).

year

A flag indicating whether to predict by year.

month

A flag indicating whether to predict by month.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the predicted estimates.

See Also

Other analysis: bb_predict_calf_cow_ratio(), bb_predict_growth(), bb_predict_population_change(), bb_predict_recruitment(), bb_predict_recruitment_trend(), bb_predict_survival_trend()


Predict Survival Trend

Description

Predict survival by year as trend line. Survival fit object provided must be created with year_trend = TRUE.

Usage

bb_predict_survival_trend(
  survival,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 5
)

Arguments

survival

An object of class 'bboufit_survival' (output of bb_fit_survival()).

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

Value

A tibble of the predicted estimates.

See Also

Other analysis: bb_predict_calf_cow_ratio(), bb_predict_growth(), bb_predict_population_change(), bb_predict_recruitment(), bb_predict_recruitment_trend(), bb_predict_survival()


Recruitment model default priors

Description

Prior distribution parameters and default values for recruitment model parameters.

Usage

bb_priors_recruitment()

Details

Intercept

b0 ~ Normal(mu = b0_mu, sd = b0_sd)

Year Trend

bYear ~ Normal(mu = bYear_mu, sd = bYear_sd)

Year fixed effect

bAnnual ~ Normal(mu = 0, sd = bAnnual_sd)

Standard deviation of annual random effect

sAnnual ~ Exponential(rate = sAnnual_rate)

Adult female proportion

adult_female_proportion ~ Beta(alpha = adult_female_proportion_alpha, beta = adult_female_proportion_beta)

Value

A named vector.

Examples

bb_priors_survival()

Survival model default priors

Description

Prior distribution parameters and default values for survival model parameters.

Usage

bb_priors_survival()

Details

Intercept

b0 ~ Normal(mu = b0_mu, sd = b0_sd)

Year Trend

bYear ~ Normal(mu = bYear_mu, sd = bYear_sd)

Year fixed effect

bAnnual ~ Normal(mu = 0, sd = bAnnual_sd)

Standard deviation of annual random effect

sAnnual ~ Exponential(rate = sAnnual_rate)

Standard deviation of month random effect

sMonth ~ Exponential(rate = sMonth_rate)

Value

A named vector.

Examples

bb_priors_survival()

Get Tidy Tibble from bboufit Object.

Description

A wrapper on tidy.bboufit().

Usage

## S3 method for class 'bboufit'
coef(object, ...)

Arguments

object

The object.

...

Unused parameters.

See Also

tidy.bboufit()

Examples

if (interactive()) {
  fit <- bb_fit_recruitment(bboudata::bbourecruit_a)
  coef(fit)
}

Get Tidy Tibble from bboufit_ml Object.

Description

A wrapper on tidy.bboufit_ml().

Usage

## S3 method for class 'bboufit_ml'
coef(object, ...)

Arguments

object

The object.

...

Unused parameters.

See Also

tidy.bboufit_ml()

Examples

if (interactive()) {
  fit <- bb_fit_recruitment_ml(bboudata::bbourecruit_a)
  coef(fit)
}

Get Convergence of bboufit Object

Description

Get Convergence of bboufit Object

Usage

## S3 method for class 'bboufit'
converged(x, rhat = 1.05, ...)

Arguments

x

The object.

rhat

A number greater than 1 of the maximum rhat value required for model convergence.

...

Unused parameters.

Value

A flag indicating convergence.


Get Convergence of bboufit_ml Object

Description

Successful convergence indicates that no convergence warnings were produced by optim and all standard errors could be estimated.

Usage

## S3 method for class 'bboufit_ml'
converged(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A flag indicating convergence.


Get Effective Sample Rate of bboufit Object

Description

Get Effective Sample Rate of bboufit Object

Usage

## S3 method for class 'bboufit'
esr(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of chains.


Estimates for bboufit Object

Description

Gets a named list of the estimated values by term.

Usage

## S3 method for class 'bboufit'
estimates(x, term = NULL, ...)

Arguments

x

The object.

term

A string of the term name.

...

Unused parameters.

Value

A named list of the estimates.

See Also

tidy.bboufit()

Examples

if (interactive()) {
  fit <- bb_fit_survival(bboudata::bbousurv_a)
  estimates(fit)
}

Estimates for bboufit_ml Object

Description

Gets a named list of the estimated values by term.

Usage

## S3 method for class 'bboufit_ml'
estimates(x, term = NULL, original_scale = FALSE, ...)

Arguments

x

The object.

term

A string of the term name.

original_scale

A flag indicating whether to return the estimates in the original scale.

...

Unused parameters.

Value

A named list of the estimates.

See Also

tidy.bboufit()

Examples

if (interactive()) {
  fit <- bb_fit_survival_ml(bboudata::bbousurv_a)
  estimates(fit)
}

Get a Glance Summary of bboufit Object

Description

Get a tibble of a one-row summary of the model fit.

Usage

## S3 method for class 'bboufit'
glance(x, rhat = 1.05, ...)

Arguments

x

The object.

rhat

A number greater than 1 of the maximum rhat value required for model convergence.

...

Unused parameters.

Value

A tibble of the glance summary.

See Also

Other generics: augment.bboufit(), augment.bboufit_ml(), glance.bboufit_ml(), tidy.bboufit(), tidy.bboufit_ml()

Examples

if (interactive()) {
  fit <- bb_fit_survival(bboudata::bbousurv_a)
  glance(fit)
}

Get a Glance Summary of bboufit_ml Object

Description

Get a tibble of a one-row summary of the model fit.

Usage

## S3 method for class 'bboufit_ml'
glance(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A tibble of the glance summary.

See Also

Other generics: augment.bboufit(), augment.bboufit_ml(), glance.bboufit(), tidy.bboufit(), tidy.bboufit_ml()

Examples

if (interactive()) {
  fit <- bb_fit_survival_ml(bboudata::bbousurv_a)
  glance(fit)
}

Get Model Code

Description

Get code from Nimble model.

Usage

model_code(x, ...)

## S3 method for class 'bboufit'
model_code(x, ...)

## S3 method for class 'bboufit_ml'
model_code(x, ...)

Arguments

x

The object.

...

Unused parameters.

Methods (by class)

  • model_code(bboufit): Get model code from bboufit object.

  • model_code(bboufit_ml): Get model code from bboufit_ml object.


Build Nimble recruitment model.

Description

This is for use by developers.

Usage

model_recruitment(
  data,
  year_random = TRUE,
  year_trend = TRUE,
  adult_female_proportion = 0.65,
  sex_ratio = 0.5,
  demographic_stochasticity = TRUE,
  priors = NULL
)

Arguments

data

The data.frame.

year_random

A flag indicating whether to include year random effect. If FALSE, year is fitted as a fixed effect.

year_trend

A flag indicating whether to fit a year trend effect. Year trend cannot be fit if there is also a fixed year effect (as opposed to random effect).

adult_female_proportion

A number between 0 and 1 of the expected proportion of adults that are female. If NULL, the proportion is estimated from the data (i.e., Cows ~ Binomial(adult_female_proportion, Cows + Bulls)) and a prior of dbeta(65, 35) is used. This prior can be changed via the priors argument.

sex_ratio

A number between 0 and 1 of the proportion of females at birth.

demographic_stochasticity

A flag indicating whether to include demographic_stochasticity in the recruitment model.

priors

A named vector of the parameter prior distribution values. Any missing values are assigned their default values in priors_survival() and priors_recruitment(). If NULL, all parameters are assigned their default priors.


Build Nimble survival model.

Description

This is for use by developers.

Usage

model_survival(
  data,
  year_random = TRUE,
  year_trend = FALSE,
  priors = NULL,
  build_derivs = TRUE
)

Arguments

data

The data.frame.

year_random

A flag indicating whether to include year random effect. If FALSE, year is fitted as a fixed effect.

year_trend

A flag indicating whether to fit a year trend effect. Year trend cannot be fit if there is also a fixed year effect (as opposed to random effect).

priors

A named vector of the parameter prior distribution values. Any missing values are assigned their default values in priors_survival() and priors_recruitment(). If NULL, all parameters are assigned their default priors.

build_derivs

A flag indicating whether to build derivatives Laplace approximation.


Get Number of Chains from bboufit Object

Description

Get Number of Chains from bboufit Object

Usage

## S3 method for class 'bboufit'
nchains(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of chains.


Get Number of Iterations from bboufit Object

Description

Get Number of Iterations from bboufit Object

Usage

## S3 method for class 'bboufit'
niters(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of iterations.


Get Number of Parameters from bboufit Object

Description

Get Number of Parameters from bboufit Object

Usage

## S3 method for class 'bboufit'
npars(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of parameters.


Get Number of Parameters from bboufit_ml Object

Description

Get Number of Parameters from bboufit_ml Object

Usage

## S3 method for class 'bboufit_ml'
npars(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of parameters.


Get Number of Terms from bboufit Object

Description

Get Number of Terms from bboufit Object

Usage

## S3 method for class 'bboufit'
nterms(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of terms.


Get Number of Terms from bboufit_ml Object

Description

Get Number of Terms from bboufit_ml Object

Usage

## S3 method for class 'bboufit_ml'
nterms(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of the number of terms.


Get Parameters from bboufit Object

Description

Get Parameters from bboufit Object

Usage

## S3 method for class 'bboufit'
pars(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A vector of the parameter names.


Get Parameters from bboufit_ml Object

Description

Get Parameters from bboufit_ml Object

Usage

## S3 method for class 'bboufit_ml'
pars(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A vector of the parameter names.


Predict Recruitment

Description

A wrapper on bb_predict_recruitment().

Usage

## S3 method for class 'bboufit_recruitment'
predict(
  object,
  year = TRUE,
  sex_ratio = 0.5,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3,
  ...
)

Arguments

object

The object.

year

A flag indicating whether to predict by year.

sex_ratio

A number between 0 and 1 of the proportion of females at birth.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

...

Unused parameters.

See Also

bb_predict_recruitment()


Predict Survival

Description

A wrapper on bb_predict_survival().

Usage

## S3 method for class 'bboufit_survival'
predict(
  object,
  year = TRUE,
  month = FALSE,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3,
  ...
)

Arguments

object

The object.

year

A flag indicating whether to predict by year.

month

A flag indicating whether to predict by month.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

...

Unused parameters.

See Also

bb_predict_survival()


Get Rhat of bboufit Object

Description

Get Rhat of bboufit Object

Usage

## S3 method for class 'bboufit'
rhat(x, ...)

Arguments

x

The object.

...

Unused parameters.

Value

A number of rhat value.


Get MCMC samples

Description

Get MCMC samples from Nimble model.

Usage

samples(x)

## S3 method for class 'bboufit'
samples(x)

## S3 method for class 'bboufit_ml'
samples(x)

Arguments

x

The object.

Methods (by class)

  • samples(bboufit): Get MCMC samples from bboufit object.

  • samples(bboufit_ml): Create MCMC samples (1 iteration, 1 chain) from bboufit_ml object.


Get Tidy Tibble from bboufit Object.

Description

Get a tidy tibble of the coefficient estimates and confidence intervals from Bayesian model fit.

Usage

## S3 method for class 'bboufit'
tidy(
  x,
  conf_level = 0.95,
  estimate = median,
  sig_fig = 3,
  include_random_effects = TRUE,
  ...
)

Arguments

x

The object.

conf_level

A number between 0 and 1 of the confidence level.

estimate

A function to calculate the estimate.

sig_fig

A whole number of the significant figures to round estimates by.

include_random_effects

A flag indicating whether to include random effects in coefficient table. Standard deviation estimates will always be included.

...

Unused parameters.

Value

A tibble of the tidy coefficient summary.

See Also

coef.bboufit()

Other generics: augment.bboufit(), augment.bboufit_ml(), glance.bboufit(), glance.bboufit_ml(), tidy.bboufit_ml()

Examples

if (interactive()) {
  fit <- bb_fit_survival(bboudata::bbousurv_a)
  tidy(fit)
}

Get Tidy Tibble from bboufit_ml Object.

Description

Get a tidy tibble of the coefficient estimates and confidence intervals from Maximum Likelihood model fit.

Usage

## S3 method for class 'bboufit_ml'
tidy(x, conf_level = 0.95, sig_fig = 3, include_random_effects = TRUE, ...)

Arguments

x

The object.

conf_level

A number between 0 and 1 of the confidence level.

sig_fig

A whole number of the significant figures to round estimates by.

include_random_effects

A flag indicating whether to include random effects in coefficient table. Standard deviation estimates will always be included.

...

Unused parameters.

Value

A tibble of the tidy coefficient summary.

See Also

coef.bboufit_ml()

Other generics: augment.bboufit(), augment.bboufit_ml(), glance.bboufit(), glance.bboufit_ml(), tidy.bboufit()

Examples

if (interactive()) {
  fit <- bb_fit_survival_ml(bboudata::bbousurv_a)
  tidy(fit)
}