-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from poissonconsulting/dev
add predict/plot functionality for ML fit objects
- Loading branch information
Showing
63 changed files
with
839 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
priors_survival <- function(){ | ||
c( | ||
b0_mu = 4, | ||
b0_sd = 2, | ||
bYear_mu = 0, | ||
bYear_sd = 1, | ||
bAnnual_sd = 1, | ||
sAnnual_rate = 1, | ||
sMonth_rate = 1 | ||
) | ||
} | ||
|
||
priors_recruitment <- function(){ | ||
c( | ||
b0_mu = -1.4, | ||
b0_sd = 0.5, | ||
bYear_mu = 0, | ||
bYear_sd = 1, | ||
bAnnual_sd = 1, | ||
sAnnual_rate = 1, | ||
adult_female_proportion_alpha = 65, | ||
adult_female_proportion_beta = 35 | ||
) | ||
} | ||
|
||
#' Survival model default priors | ||
#' | ||
#' Prior distribution parameters and default values for survival model parameters. | ||
#' | ||
#' 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)` | ||
#' | ||
#' @return A named vector. | ||
#' @export | ||
#' | ||
#' @examples bb_priors_survival() | ||
bb_priors_survival <- function() { | ||
priors_survival() | ||
} | ||
|
||
#' Recruitment model default priors | ||
#' | ||
#' Prior distribution parameters and default values for recruitment model parameters. | ||
#' | ||
#' 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)` | ||
#' | ||
#' @return A named vector. | ||
#' @export | ||
#' | ||
#' @examples bb_priors_survival() | ||
bb_priors_recruitment <- function() { | ||
priors_recruitment() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#' Get MCMC samples | ||
#' | ||
#' Get MCMC samples from Nimble model. | ||
#' @inheritParams params | ||
#' @export | ||
samples <- function(x) { | ||
UseMethod("samples") | ||
} | ||
|
||
#' @describeIn samples Get MCMC samples from bboufit object. | ||
#' | ||
#' @export | ||
samples.bboufit <- function(x) { | ||
x$samples | ||
} | ||
|
||
#' @describeIn samples Create MCMC samples (1 iteration, 1 chain) from bboufit_ml object. | ||
#' | ||
#' @export | ||
samples.bboufit_ml <- function(x) { | ||
mcmcr::as.mcmcr(estimates(x)) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.