This function takes in SRJPEdata::observed_adult_input and SRJPEdata::adult_model_covariates_standard and runs the Passage to Spawner (P2S) model for a selected stream and environmental covariate. The function will return a formatted list of parameter estimates and the full fitted stanfit object. See vignette("passage_to_spawner_submodel.Rmd", package = "SRJPEmodel") for more details.

run_passage_to_spawner_model(
  observed_adult_input,
  adult_model_covariates,
  stream_name,
  selected_covariate,
  extract_predicted_spawners = c(FALSE, TRUE)
)

Arguments

observed_adult_input:

The exported data object SRJPEdata::observed_adult_input. See ?SRJPEdata::observed_adult_input for details on data structure.

adult_model_covariates_standard:

The exported data object SRJPEdata::adult_model_covariates_standard. See ?SRJPEdata::adult_model_covariates_standard for details on data structure.

stream_name:

The name of the stream for which you would like to run the P2S model. Can be battle creek, clear creek, deer creek, mill creek, or (draft form) butte creek.

selected_covariate:

The environmental covariate you'd like to run the model for. Can be either wy_type (water year type), max_flow_std (maximum flow), gdd_std (growing degree days), passage_index (total upstream passage), median_passage_timing_std (median passage timing), or null_covar (no environmental covariate).

extract_predicted_spawners:

If TRUE, will only produce a tibble with median predicted spawners with upper (97.5%) and lower (2.5%) confidence intervals. If FALSE, returns a list with all parameter estimates and the full stanfit object. See vignette("prep_environmental_covariates.Rmd", package = "SRJPEdata") for more details.

Value

If extracted_predicted_spawners == TRUE, Returns a tibble containing the following variables:

  • stream Stream name

  • year Year observed data came from

  • median_predicted_spawners Median predicted spawner value for a given stream and year

  • lcl 2.5% confidence interval for predicted spawner value

  • ucl 97.5% confidence interval for predicted spawner value

  • data_type Data type: P2S_predicted_spawners

If extracted_predicted_spawners == FALSE, returns a list containing full_object, the full fitted stanfit object (see details), and formatted_pars, a formatted data table containing the following variables:

  • par_names Parameter name

  • mean Mean of the posterior distribution for a parameter

  • se_mean Monte Carlo standard error for summary of all chains merged (see details)

  • sd Standard deviation of the posterior distribution for a parameter

  • 2.5% 2.5% quantile of posterior distribution for a parameter.

  • 25% 25% quantile of posterior distribution for a parameter.

  • 50% 50% quantile of posterior distribution for a parameter.

  • 75% 75% quantile of posterior distribution for a parameter.

  • 97.5% 97.5% quantile of posterior distribution for a parameter.

  • n_eff Effective sample size for a parameter

  • Rhat Split Rhats for a parameter

  • stream Stream name for the parameter estimate

  • year Year observed data came from

See also