Title: | Model Builder Utility Functions and Virtual Classes |
---|---|
Description: | Utility functions and virtual classes shared by model builder packages such as tmbr, jmbr and smbr. |
Authors: | Joe Thorley [aut, cre] , Kirill Müller [aut] , Nicole Hill [ctb] , Ayla Pearson [ctb] , Nadine Hussein [ctb] , Poisson Consulting [cph, fnd] |
Maintainer: | Joe Thorley <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1.9037 |
Built: | 2024-12-20 21:19:18 UTC |
Source: | https://github.com/poissonconsulting/embr |
Add analyses
add_analyses(x, x2)
add_analyses(x, x2)
x |
An mb_analysis or mb_analyses object. |
x2 |
n mb_analysis or mb_analyses object. |
An object of class mb_analyses.
Add model(s)
add_models(x, x2)
add_models(x, x2)
x |
An mb_model or mb_models object. |
x2 |
n mb_model or mb_models object. |
An object of class mb_models.
Analyse
analyse(x, ...)
analyse(x, ...)
x |
The object to analyse. |
... |
Additional arguments. |
Analyse Residuals
analyse_residuals(x)
analyse_residuals(x)
x |
The mb_analysis object to analyse the residuals for. |
Analyse
## S3 method for class 'character' analyse( x, data, select_data = list(), nchains = getOption("mb.nchains", 3L), niters = getOption("mb.niters", 1000L), nthin = getOption("mb.nthin", 1L), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'character' analyse( x, data, select_data = list(), nchains = getOption("mb.nchains", 3L), niters = getOption("mb.niters", 1000L), nthin = getOption("mb.nthin", 1L), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
x |
An object inheriting from class mb_model or a list of such objects. |
data |
The data frame to analyse. |
select_data |
A named list specifying the columns to select and their associated classes and values as well as transformations and scaling options. |
nchains |
A count of the number of chains. |
niters |
A count of the number of simulations to save per chain. |
nthin |
A count of the thining interval or NULL (in which case taken from model). |
parallel |
A flag indicating whether to perform the analysis in parallel if possible. |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print a model summary. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
Analyse
## S3 method for class 'mb_model' analyse( x, data, nchains = getOption("mb.nchains", 3L), niters = getOption("mb.niters", 1000L), nthin = getOption("mb.thin", NULL), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_model' analyse( x, data, nchains = getOption("mb.nchains", 3L), niters = getOption("mb.niters", 1000L), nthin = getOption("mb.thin", NULL), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
x |
An object inheriting from class mb_model or a list of such objects. |
data |
The data frame to analyse. |
nchains |
A count of the number of chains. |
niters |
A count of the number of simulations to save per chain. |
nthin |
A count of the thining interval or NULL (in which case taken from model). |
parallel |
A flag indicating whether to perform the analysis in parallel if possible. |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print a model summary. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
Analyse
## S3 method for class 'mb_models' analyse( x, data, nchains = getOption("mb.nchains", 3L), niters = getOption("mb.niters", 1000L), nthin = getOption("mb.thin", NULL), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_models' analyse( x, data, nchains = getOption("mb.nchains", 3L), niters = getOption("mb.niters", 1000L), nthin = getOption("mb.thin", NULL), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
x |
An object inheriting from class mb_model or a list of such objects. |
data |
The data frame to analyse. |
nchains |
A count of the number of chains. |
niters |
A count of the number of simulations to save per chain. |
nthin |
A count of the thining interval or NULL (in which case taken from model). |
parallel |
A flag indicating whether to perform the analysis in parallel if possible. |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print a model summary. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
Analyse
analyse1( model, data, loaded, nchains, niters, nthin, quiet, glance, parallel, ... )
analyse1( model, data, loaded, nchains, niters, nthin, quiet, glance, parallel, ... )
model |
The mb_model to analyse. |
data |
The data. |
loaded |
The loaded model. |
nchains |
chains. |
niters |
iters |
nthin |
thin |
quiet |
quiet |
glance |
glance |
parallel |
parallel |
... |
Additional arguments. |
Creates an object inherting from class mb_analyses.
analyses(...)
analyses(...)
... |
Named objects. |
An object inheriting from class mb_analyses.
Coerce to an mb_analyses object
as.analyses(x, ...)
as.analyses(x, ...)
x |
object to coerce. |
... |
Unused. |
Coerce to an mb_model object
as.model(x, ...)
as.model(x, ...)
x |
object to coerce. |
... |
Unused. |
Coerce to an mb_models object
as.models(x, ...)
as.models(x, ...)
x |
object to coerce. |
... |
Unused. |
Perform backwards step-wise regression on a model. Returns a list of the analysis at each step starting with the full model.
backwards( model, data, drops = list(), conf_level = getOption("mb.conf_level", 0.95), beep = getOption("mb.beep", TRUE), ... )
backwards( model, data, drops = list(), conf_level = getOption("mb.conf_level", 0.95), beep = getOption("mb.beep", TRUE), ... )
model |
An object. |
data |
Data. |
drops |
A list of character vectors specifying the scalar parameters to consider. |
conf_level |
A number specifying the confidence level. By default 0.95. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Unused. |
drop is a list of character vectors specifying the scalar parameters to possibly drop. If a list element consists of two or more strings then the earlier strings are only available to drop after the later strings have been eliminated. This allows polynomial dependencies to be respected.
A list of the analyses.
Base Model
base_model(model, drops = list())
base_model(model, drops = list())
model |
The full model. |
drops |
A list of character vectors specifying possible drops. |
The base model (with all drops).
Check MB Analysis
check_mb_analysis(object, object_name = substitute(object))
check_mb_analysis(object, object_name = substitute(object))
object |
The object to check. |
object_name |
A string of the object name. |
The object or throws an informative error.
Check MB Code
check_mb_code(object, object_name = substitute(object))
check_mb_code(object, object_name = substitute(object))
object |
The object to check. |
object_name |
A string of the object name. |
The object or throws an informative error.
Check MB Model
check_mb_model(object, object_name = substitute(object))
check_mb_model(object, object_name = substitute(object))
object |
The object to check. |
object_name |
A string of the object name. |
The object or throws an informative error.
Check Model Parameters
check_model_pars(x, fixed, random, derived, drops)
check_model_pars(x, fixed, random, derived, drops)
x |
The model code to check. |
fixed |
A string of a regular expression specifying the fixed parameters to monitor. |
random |
NULL or a character vector of the random effects. |
derived |
NULL or a character vector of the derived parameters. |
drops |
NULL or a character vector of the parameters to drop. |
The possibly updated derived parameters.
Check Uniquely Named List
check_uniquely_named_list(x, x_name = substitute(x))
check_uniquely_named_list(x, x_name = substitute(x))
x |
The object to check. |
x_name |
A string of the objects name. |
The original object or throws an informative error.
Gets the MB code for an object.
code(object, ...)
code(object, ...)
object |
The object. |
... |
Additional arguments. |
An object inheriting from class mb_code.
Gets coef confidence limits by likelihood profiling.
coef_profile(object, ...)
coef_profile(object, ...)
object |
The object. |
... |
Unused. |
Coefficients for fixed parameters from an ML based MB analyses averaged by IC weights.
## S3 method for class 'mb_analyses' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_analyses' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.beep", TRUE), ... )
object |
The mb_analyses object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculate the estimate for Bayesian models. |
parallel |
A flag indicating whether to using parallel backend provided by foreach. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Not used. |
A tidy tibble of the coeffcient terms with the model averaged estimate, the Akaike's weight and the proportion of models including the term.
Coefficients for a analysis.
## S3 method for class 'mb_analysis' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.profile", TRUE), simplify = TRUE, ... )
## S3 method for class 'mb_analysis' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.profile", TRUE), simplify = TRUE, ... )
object |
The mb_analysis object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculating the estimate for Bayesian models. |
parallel |
A flag indicating whether to using parallel backend provided by foreach. |
beep |
A flag indicating whether to beep on completion of the analysis. |
simplify |
A flag specifying whether to simplify with svalue. |
... |
Not used. |
The zscore
is mean / sd.
A tidy tibble of the coefficient terms.
Coef TMB Meta Analyses
## S3 method for class 'mb_meta_analyses' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.parallel", TRUE), ... )
## S3 method for class 'mb_meta_analyses' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.parallel", TRUE), ... )
object |
The mb_meta_analyses object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculate the estimate. |
parallel |
A flag indicating whether to using parallel backend provided by foreach. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Not used. |
A tidy tibble.
Coef TMB Meta Analysis
## S3 method for class 'mb_meta_analysis' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_meta_analysis' coef_profile( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), parallel = getOption("mb.parallel", FALSE), beep = getOption("mb.beep", TRUE), ... )
object |
The mb_meta_analysis object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculate the estimate. |
parallel |
A flag indicating whether to using parallel backend provided by foreach. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Not used. |
A tidy tibble.
Coefficients for fixed parameters from an ML based MB analyses averaged by IC weights.
## S3 method for class 'mb_analyses' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), ... )
## S3 method for class 'mb_analyses' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), ... )
object |
The mb_analyses object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculate the estimate for Bayesian models. |
... |
Not used. |
A tidy tibble of the coeffcient terms with the model averaged estimate, the Akaike's weight and the proportion of models including the term.
Coefficients for a JAGS analysis.
## S3 method for class 'mb_analysis' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), simplify = FALSE, ... )
## S3 method for class 'mb_analysis' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), simplify = FALSE, ... )
object |
The mb_analysis object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculating the estimate for Bayesian models. |
simplify |
A flag specifying whether to drop sd and zscore columns and return svalue instead of pvalue. |
... |
Not used. |
The zscore
is mean / sd.
A tidy tibble of the coefficient terms.
Coef TMB Meta Analyses
## S3 method for class 'mb_meta_analyses' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), ... )
## S3 method for class 'mb_meta_analyses' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), ... )
object |
The mb_meta_analyses object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculate the estimate. |
... |
Not used. |
A tidy tibble.
Coef TMB Meta Analysis
## S3 method for class 'mb_meta_analysis' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), ... )
## S3 method for class 'mb_meta_analysis' coef( object, param_type = "fixed", include_constant = TRUE, conf_level = getOption("mb.conf_level", 0.95), estimate = getOption("mb.estimate", median), ... )
object |
The mb_meta_analysis object. |
param_type |
A flag specifying whether 'fixed', 'random' or 'derived' terms. |
include_constant |
A flag specifying whether to include constant terms. |
conf_level |
A number specifying the confidence level. By default 0.95. |
estimate |
The function to use to calculate the estimate. |
... |
Not used. |
A tidy tibble.
Returns the regular expression used to identify the start of a comment in an mb_code object.
comment_string(object, ...)
comment_string(object, ...)
object |
The mb code object. |
... |
Unused. |
A string of the regular expression.
Gets the data set for an object inheriting from class mb_analysis.
data_set( x, modify = FALSE, numericize_factors = FALSE, marginalize_random_effects = FALSE, ... )
data_set( x, modify = FALSE, numericize_factors = FALSE, marginalize_random_effects = FALSE, ... )
x |
The object. |
modify |
A flag indicating whether to modify the data. |
numericize_factors |
A flag indicating whether to convert factors to integers if modifying the data. |
marginalize_random_effects |
A flag indicating whether to set each factor in one or more random effects at its first level. |
... |
Unused. |
The data set as a tibble.
dummy data
density99
density99
An object of class data.frame
with 300 rows and 5 columns.
Drops named scalar fixed pars from an object by fixing them at 0.
drop_pars(x, pars = character(0), ...)
drop_pars(x, pars = character(0), ...)
x |
The object. |
pars |
A character vector of the pars to drop. |
... |
Not used. |
The updated object.
Get elapsed duration.
elapsed(x, ...)
elapsed(x, ...)
x |
The object to calculate it for. |
... |
Not used. |
Calculates the estimates for an MCMC object.
## S3 method for class 'mb_analysis' estimates(x, param_type = "fixed", ...)
## S3 method for class 'mb_analysis' estimates(x, param_type = "fixed", ...)
x |
An object. |
param_type |
A string indicating the type of terms to get the names for. |
... |
Other arguments passed to methods. |
A list of uniquely named numeric objects.
Other MCMC manipulations:
bind_chains()
,
bind_iterations()
,
collapse_chains()
,
split_chains()
Extract fitted values for a MB analysis.
## S3 method for class 'mb_analysis' fitted(object, ...)
## S3 method for class 'mb_analysis' fitted(object, ...)
object |
The MB analysis object. |
... |
Unused. |
The new_expr in the model must include the term 'fit'.
The analysis data set with the fitted values.
Gets analysis mode.
get_analysis_mode()
get_analysis_mode()
Retrieves what is set for each of the following package options.
A count of the number of chains.
A count of the number of simulations to save per chain.
A count of the thining interval.
A flag indicating whether to perform the analysis in parallel.
A flag indicating whether to disable tracing information.
A flag indicating whether to beep on completion of the analysis.
A flag indicating whether to print a model summary.
A count specifying the maximum number of reanalyses.
A number specifying the rhat threshold.
A number specifying the minimum effective sampling rate.
The maximum total time to spend on analysis and reanalysis.
A number specifying the confidence level.
A named list of the current package options.
## Not run: get_analysis_mode() ## End(Not run)
## Not run: get_analysis_mode() ## End(Not run)
Constucts a new analysis object
get_model(analysis)
get_model(analysis)
analysis |
An object of class '"mb_analysis"'. |
Calculates Information Criterion for an analysis.
IC(object, ...)
IC(object, ...)
object |
The object to calculate the IC for. |
... |
Not used. |
The Information Criteron as a number.
Test if is bayesian
is_bayesian(x, ...)
is_bayesian(x, ...)
x |
the object. |
... |
Unused |
A flag indicating wether bayesian.
Test if is frequentist
is_frequentist(x)
is_frequentist(x)
x |
the object. |
A flag indicating whether frequentist
Is Named List
is_namedlist(x)
is_namedlist(x)
x |
The object to test. |
A flag.
is_namedlist(1) is_namedlist(list()) is_namedlist(list(1)) is_namedlist(list(x = 1)) is_namedlist(list(x = list(y = 2)))
is_namedlist(1) is_namedlist(list()) is_namedlist(list(1)) is_namedlist(list(x = 1)) is_namedlist(list(x = list(y = 2)))
Tests whether x is an object of class 'lmb_analysis'
is.lmb_analysis(x)
is.lmb_analysis(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'lmb_code'
is.lmb_code(x)
is.lmb_code(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'lmb_model'
is.lmb_model(x)
is.lmb_model(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'mb_analyses'
is.mb_analyses(x)
is.mb_analyses(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'mb_analysis'
is.mb_analysis(x)
is.mb_analysis(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'mb_model'
is.mb_code(x)
is.mb_code(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'mb_model'
is.mb_model(x)
is.mb_model(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'mb_models'
is.mb_models(x)
is.mb_models(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Tests whether x is an object of class 'mb_null_analysis'
is.mb_null_analysis(x)
is.mb_null_analysis(x)
x |
The object to test. |
A flag indicating whether the test was positive.
Is syntactic
is.syntactic(x)
is.syntactic(x)
x |
A character of possible variable names. |
A logical vector indicating whether a syntactically correct variable name.
is.syntactic(c("0", "x", "1x", "x y", "x1"))
is.syntactic(c("0", "x", "1x", "x y", "x1"))
Load Model
load_model(x, quiet, ...)
load_model(x, quiet, ...)
x |
The model to load. |
quiet |
A flag indicating whether to suppress warnings and output. |
... |
Additional arguments. |
Log-Likelihood for a MB analysis.
## S3 method for class 'mb_analysis' logLik(object, ...)
## S3 method for class 'mb_analysis' logLik(object, ...)
object |
The mb_analysis object. |
... |
unused. |
Log-Likelihood for a MB NULL analysis.
## S3 method for class 'mb_null_analysis' logLik(object, ...)
## S3 method for class 'mb_null_analysis' logLik(object, ...)
object |
The mb_analysis object. |
... |
unused. |
Make All Models
make_all_models(model, drops = list())
make_all_models(model, drops = list())
model |
The full model. |
drops |
A list of character vectors specifying possible drops. |
A list of objects inheriting from class mb_model.
Identifies the type of the code and creates an object of the appropriate class.
mb_code(template) new_mb_code(x, class)
mb_code(template) new_mb_code(x, class)
template |
A string, a braced '' expression (unquoted or quoted), or an object of class '"mb_code"'. |
x |
A string or a braced '' expression. |
class |
The class of the new object. |
An object inheriting from class mb_code.
x <- mb_code( "#include <TMB.hpp> template<class Type> Type objective_function<Type>::operator() () { DATA_VECTOR(Count); PARAMETER(bIntercept); int n = Count.size(); Type nll = 0.0; for(int i = 0; i < n; i++){ nll -= dpois(Count(i), bIntercept, true); } return nll; } " ) class(x)
x <- mb_code( "#include <TMB.hpp> template<class Type> Type objective_function<Type>::operator() () { DATA_VECTOR(Count); PARAMETER(bIntercept); int n = Count.size(); Type nll = 0.0; for(int i = 0; i < n; i++){ nll -= dpois(Count(i), bIntercept, true); } return nll; } " ) class(x)
Calculate derived parameters.
## S3 method for class 'mb_analyses' mcmc_derive_data( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analyses' mcmc_derive_data( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
An object inheriting from class mb_analysis. |
new_data |
The data frame to calculate the predictions for. |
new_expr |
A string of R code specifying the predictive relationship. |
new_values |
A named list of new or replacement values to pass to new_expr. |
term |
A string of the term in new_expr. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
ref_data |
A flag or a data frame with 1 row indicating the reference values for calculating the effects size. |
ref_fun2 |
A function whose first argument takes a vector of two numbers and returns a scalar of a metric of the difference between them. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
A object of class mcmc_data.
Calculate derived parameters.
## S3 method for class 'mb_analysis' mcmc_derive_data( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), random_effects = NULL, parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analysis' mcmc_derive_data( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), random_effects = NULL, parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
An object inheriting from class mb_analysis. |
new_data |
The data frame to calculate the predictions for. |
new_expr |
A string of R code specifying the predictive relationship. |
new_values |
A named list of new or replacement values to pass to new_expr. |
term |
A string of the term in new_expr. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
ref_data |
A flag or a data frame with 1 row indicating the reference values for calculating the effects size. |
ref_fun2 |
A function whose first argument takes a vector of two numbers and returns a scalar of a metric of the difference between them. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
random_effects |
A named list specifying the random effects and the associated factors. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
A object of class mcmc_data.
Calculate derived parameters.
## S3 method for class 'mb_analyses' mcmc_derive( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analyses' mcmc_derive( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
An object inheriting from class mb_analysis. |
new_data |
The data frame to calculate the predictions for. |
new_expr |
A string of R code specifying the predictive relationship. |
new_values |
A named list of new or replacement values to pass to new_expr. |
term |
A string of the term in new_expr. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
ref_data |
A flag or a data frame with 1 row indicating the reference values for calculating the effects size. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
A object of class mcmcr.
Calculate derived parameters.
## S3 method for class 'mb_analysis' mcmc_derive( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, random_effects = NULL, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analysis' mcmc_derive( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, random_effects = NULL, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
An object inheriting from class mb_analysis. |
new_data |
The data frame to calculate the predictions for. |
new_expr |
A string of R code specifying the predictive relationship. |
new_values |
A named list of new or replacement values to pass to new_expr. |
term |
A string of the term in new_expr. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
ref_data |
A flag or a data frame with 1 row indicating the reference values for calculating the effects size. |
ref_fun2 |
A function whose first argument takes a vector of two numbers and returns a scalar of a metric of the difference between them. |
random_effects |
A named list specifying the random effects and the associated factors. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
A object of class mcmcr.
Creates MB model.
model( x = NULL, ..., code = NULL, gen_inits = NULL, random_effects = list(), fixed = getOption("mb.fixed", "^[^e]"), derived = character(0), select_data = list(), center = character(0), scale = character(0), modify_data = identity, nthin = getOption("mb.nthin", 1L), new_expr = NULL, new_expr_vec = getOption("mb.new_expr_vec", FALSE), modify_new_data = identity, drops = list() )
model( x = NULL, ..., code = NULL, gen_inits = NULL, random_effects = list(), fixed = getOption("mb.fixed", "^[^e]"), derived = character(0), select_data = list(), center = character(0), scale = character(0), modify_data = identity, nthin = getOption("mb.nthin", 1L), new_expr = NULL, new_expr_vec = getOption("mb.new_expr_vec", FALSE), modify_new_data = identity, drops = list() )
x |
A string, or an object inheriting from class '"mb_code"'. |
... |
Unused arguments. |
code |
Passed on to [mb_code()]. If 'x' is not 'NULL', 'code' must be 'NULL', and vice versa. |
gen_inits |
A single argument function taking the modified data and returning a named list of initial values. |
random_effects |
A named list specifying the random effects and the associated factors. |
fixed |
A string of a regular expression specifying the fixed pars to monitor. |
derived |
A character vector of the derived pars to monitor. |
select_data |
A named list specifying the columns to select and their associated classes and values as well as transformations and scaling options. |
center |
A character vector of the columns to center. |
scale |
A character vector of the columns to scale (after centering). |
modify_data |
A single argument function to modify the data (in list form) immediately prior to the analysis. |
nthin |
A count specifying the thinning interval. |
new_expr |
A string of R code specifying the predictive relationships. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
drops |
A list of character vector of possible scalar pars to drop (fix at 0). |
For tmb models gen_inits must specify all the fixed pars. Missing random pars are assigned the value 0.
For jmb models unspecified the initial values for each chain are drawn from the prior distributions.
An object inherting from class mb_model.
Creates an object inherting from class mb_models.
models(...)
models(...)
... |
Named objects. |
An object inheriting from class mb_models.
Modifies a data frame to the form it will be passed to the analysis code.
modify_data(data, model, numericize_factors = FALSE)
modify_data(data, model, numericize_factors = FALSE)
data |
The data to modify. |
model |
An object inheriting from class mb_model. |
numericize_factors |
A flag indicating whether to convert factors to integer. |
The modified data in list form.
Modifies a data frame to the form it will be passed to the analysis code.
modify_new_data( data, data2, model, modify_new_data = NULL, numericize_factors = FALSE )
modify_new_data( data, data2, model, modify_new_data = NULL, numericize_factors = FALSE )
data |
The data to modify. |
data2 |
The base data. |
model |
An object inheriting from class mb_model. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
numericize_factors |
A flag indicating whether to convert factors to integer. |
The modified data in list form.
pars to monitor
monitor(object, param_type = "all")
monitor(object, param_type = "all")
object |
An mb model object to get the pars for. |
param_type |
A string specifying the type of pars to get. |
A character vector of the pars to monitor.
Constucts a new analysis object
new_analysis(x, class)
new_analysis(x, class)
x |
A list. |
class |
The class of the new object. |
new_expr
new_expr(object, ...)
new_expr(object, ...)
object |
The object to get for. |
... |
Not used. |
The new_expr
new_expr set
new_expr(object) <- value
new_expr(object) <- value
object |
The object to set for. |
value |
The new value of new expr. |
The modified object.
Total Number of MCMC simulations generated (including warmup)
ngens(x, ...)
ngens(x, ...)
x |
The object |
... |
Unused. |
A count.
Number Models
nmodels(x, ...)
nmodels(x, ...)
x |
the object. |
... |
Named objects. |
An integer of the number of models
Number of terms
## S3 method for class 'mb_analysis' nterms(x, param_type = "fixed", include_constant = TRUE, ...)
## S3 method for class 'mb_analysis' nterms(x, param_type = "fixed", include_constant = TRUE, ...)
x |
The object to get the nterms for |
param_type |
A string indicating the type of terms to get the names for. |
include_constant |
A flag specifying whether to include constant terms. |
... |
unused |
Thinning Rate
nthin(x, ...)
nthin(x, ...)
x |
The object |
... |
Unused. |
A count.
Parameter Descriptions
param_type |
A string indicating the type of terms to get the names for. |
type |
A string of the residual type. |
... |
Unused. |
Plot Data
plot_data(x, ...)
plot_data(x, ...)
x |
The object to plot the data for. |
... |
Unused. |
Plot Residuals
plot_residuals(x, ...)
plot_residuals(x, ...)
x |
The object to plot the residuals for. |
... |
Unused. |
Plot Analysis
## S3 method for class 'mb_analysis' plot(x, param_type = "fixed", ...)
## S3 method for class 'mb_analysis' plot(x, param_type = "fixed", ...)
x |
The analysis object to plot |
param_type |
A string indicating the type of terms to get the names for. |
... |
Unused. |
Simulates
posterior_predictive_check(x, ...)
posterior_predictive_check(x, ...)
x |
The object |
... |
Unused. |
A tibble of the checks.
Posterior Predictive Check
## S3 method for class 'mb_analysis' posterior_predictive_check(x, zeros = TRUE, ...)
## S3 method for class 'mb_analysis' posterior_predictive_check(x, zeros = TRUE, ...)
x |
The MB analysis object. |
zeros |
A flag specifying whether to perform a posterior predictive check on the number of zeros in the data. |
... |
Unused. |
A tibble of the checks.
Predict
## S3 method for class 'mb_analyses' predict( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", conf_level = getOption("mb.conf_level", 0.95), modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analyses' predict( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", conf_level = getOption("mb.conf_level", 0.95), modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
An object inheriting from class mb_analysis. |
new_data |
The data frame to calculate the predictions for. |
new_expr |
A string of R code specifying the predictive relationship. |
new_values |
A named list of new or replacement values to pass to new_expr. |
term |
A string of the term in new_expr. |
conf_level |
A number specifying the confidence level. By default 0.95. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
ref_data |
A flag or a data frame with 1 row indicating the reference values for calculating the effects size. |
ref_fun2 |
A function whose first argument takes a vector of two numbers and returns a scalar of a metric of the difference between them. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
Predict
## S3 method for class 'mb_analysis' predict( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", conf_level = getOption("mb.conf_level", 0.95), modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), random_effects = NULL, parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analysis' predict( object, new_data = data_set(object), new_expr = NULL, new_values = list(), term = "prediction", conf_level = getOption("mb.conf_level", 0.95), modify_new_data = NULL, ref_data = FALSE, ref_fun2 = proportional_change2, new_expr_vec = getOption("mb.new_expr_vec", FALSE), random_effects = NULL, parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
An object inheriting from class mb_analysis. |
new_data |
The data frame to calculate the predictions for. |
new_expr |
A string of R code specifying the predictive relationship. |
new_values |
A named list of new or replacement values to pass to new_expr. |
term |
A string of the term in new_expr. |
conf_level |
A number specifying the confidence level. By default 0.95. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
ref_data |
A flag or a data frame with 1 row indicating the reference values for calculating the effects size. |
ref_fun2 |
A function whose first argument takes a vector of two numbers and returns a scalar of a metric of the difference between them. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
random_effects |
A named list specifying the random effects and the associated factors. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Additional arguments. |
Gets the R2 value for an object.
R2(object, ...)
R2(object, ...)
object |
The object. |
... |
Unused. |
An index of the R2 value.
Gets the conditional (or marginal) R2 value for the 'response' for an mb_analysis object.
## S3 method for class 'mb_analysis' R2( object, response, marginal = FALSE, term = "prediction", parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
## S3 method for class 'mb_analysis' R2( object, response, marginal = FALSE, term = "prediction", parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), beep = getOption("mb.beep", FALSE), ... )
object |
The object. |
response |
A string specifying the column in the data corresponding to the response. |
marginal |
A flag indicating whether to calculate the marginal or conditional R2 value. |
term |
A string of the term in new_expr. |
parallel |
A flag indicating whether to do predictions using parallel backend provided by foreach. |
quiet |
A flag indicating whether to disable tracing information. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Unused |
The conditional R2 value is the proportion of the variance in the response predicted by the full model. The marginal R2 values is just for the fixed effects ie after marginalizing out the random effects.
A number of the R2 value.
Gets the random effects definitions for an object inheriting from class mb_model or mb_analysis.
random_effects(object, ...)
random_effects(object, ...)
object |
The object. |
... |
Unused. |
The random effects as a sorted named list.
Reanalyse an analysis.
reanalyse(object, ...)
reanalyse(object, ...)
object |
The object to reanalyse. |
... |
Additional arguments. |
Reanalyse
## S3 method for class 'mb_analyses' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_analyses' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
object |
The object to reanalyse. |
rhat |
A number specifying the rhat threshold. |
esr |
A number specifying the effective sampling rate. |
nreanalyses |
A count between 1 and 7 specifying the maximum number of reanalyses. |
duration |
The maximum total time to spend on analysis/reanalysis. |
parallel |
A flag indicating whether to perform the analysis in parallel if possible |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print summary of model. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Unused arguments. |
Reanalyse
## S3 method for class 'mb_analysis' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_analysis' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
object |
The object to reanalyse. |
rhat |
A number specifying the rhat threshold. |
esr |
A number specifying the minimum effective sampling rate. |
nreanalyses |
A count between 0 and 4 specifying the maximum number of reanalyses. |
duration |
The maximum total time to spend on analysis and reanalysis. |
parallel |
A flag indicating whether to perform the analysis in parallel if possible. |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print summary of model. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Unused arguments. |
Reanalyse
## S3 method for class 'mb_meta_analyses' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_meta_analyses' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
object |
The object to reanalyse. |
rhat |
A number specifying the rhat threshold. |
esr |
A number specifying the effective sampling rate. |
nreanalyses |
A count between 1 and 7 specifying the maximum number of reanalyses. |
duration |
The maximum total time to spend on analysis/reanalysis. |
parallel |
A flag indicating whether to perform the analysis in parallel if possible |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print summary of model. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Unused arguments. |
Reanalyse
## S3 method for class 'mb_meta_analysis' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
## S3 method for class 'mb_meta_analysis' reanalyse( object, rhat = getOption("mb.rhat", 1.1), esr = getOption("mb.esr", 0.33), nreanalyses = getOption("mb.nreanalyses", 1L), duration = getOption("mb.duration", dhours(1)), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
object |
The object to reanalyse. |
rhat |
A number specifying the rhat threshold. |
esr |
A number specifying the effective sampling rate. |
nreanalyses |
A count between 1 and 7 specifying the maximum number of reanalyses. |
duration |
The maximum total time to spend on analysis/reanalysis. |
parallel |
A flag indicating whether to perform the analysis in parallel if possible |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print summary of model. |
beep |
A flag indicating whether to beep on completion of the analysis. |
... |
Unused arguments. |
Reanalyse an analysis. For user to override.
reanalyse1(object, parallel, quiet, ...)
reanalyse1(object, parallel, quiet, ...)
object |
The object to reanalyse. |
parallel |
A flag indicating whether to perform the reanalysis in parallel. |
quiet |
A flag indicating whether to capture output. |
... |
Additional arguments. |
Extract residual values for an MB analysis.
## S3 method for class 'mb_analysis' residuals(object, type = NULL, ...)
## S3 method for class 'mb_analysis' residuals(object, type = NULL, ...)
object |
The MB analysis object. |
type |
A string of the residual type. |
... |
Unused. |
The new_expr in the model must include the term 'residual'.
The analysis data set with the residual values.
Removes comments from the template strings(s) of an mb object or a character vector.
rm_comments(object, ...)
rm_comments(object, ...)
object |
The mb object or character vector. |
... |
Unused. |
The mb object or character vector without comments in its template string(s).
Get sample size.
sample_size(object, ...)
sample_size(object, ...)
object |
The object to calculate the sample size for. |
... |
Not used. |
A count of the sample size.
Filters a named list so only scalar elements remain.wiby its names.
scalar_nlist(x)
scalar_nlist(x)
x |
The named list to sort. |
The sorted named list.
scalar_nlist(list(y = 2, x = 1, a = c(10, 1)))
scalar_nlist(list(y = 2, x = 1, a = c(10, 1)))
Multiply Standard Deviation of Priors By
sd_priors_by(x, by = 10, distributions = c("normal", "lognormal", "t"), ...) ## S3 method for class 'mb_model' sd_priors_by(x, by = 10, distributions = c("normal", "lognormal", "t"), ...) ## S3 method for class 'mb_analysis' sd_priors_by( x, by = 10, distributions = c("normal", "lognormal", "t"), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
sd_priors_by(x, by = 10, distributions = c("normal", "lognormal", "t"), ...) ## S3 method for class 'mb_model' sd_priors_by(x, by = 10, distributions = c("normal", "lognormal", "t"), ...) ## S3 method for class 'mb_analysis' sd_priors_by( x, by = 10, distributions = c("normal", "lognormal", "t"), parallel = getOption("mb.parallel", FALSE), quiet = getOption("mb.quiet", TRUE), glance = getOption("mb.glance", TRUE), beep = getOption("mb.beep", TRUE), ... )
x |
The object. |
by |
A double scalar of the multiplier. |
distributions |
A character vector of the distributions to adjust. Possible values are "laplace" (double exponential), "logistic", "lognormal", "normal", "t" and "nt" (non-central Student t). |
... |
Not used. |
parallel |
A flag indicating whether to perform the analysis in parallel if possible. |
quiet |
A flag indicating whether to disable tracing information. |
glance |
A flag indicating whether to print a model summary. |
beep |
A flag indicating whether to beep on completion of the analysis. |
The updated object.
sd_priors_by(mb_model)
: Multiply Standard Deviation of Priors for an MB model
sd_priors_by(mb_analysis)
: Multiply Standard Deviation of Priors for an MB analysis
Selects and rescales data.
select_rescale_data(data, model, data2 = data)
select_rescale_data(data, model, data2 = data)
data |
The data to modify. |
model |
An object inheriting from class mb_model. |
data2 |
The base data. |
The modified data in list form.
Sets analysis mode.
set_analysis_mode(mode = "report")
set_analysis_mode(mode = "report")
mode |
A string of the analysis mode. |
The possible modes are as follows:
To rapidly identify problems with a model definition.
To quickly test code runs.
To produce results for a report.
To produce results for a peer-reviewed paper.
To run when checking a package.
To reset all the options to NULL so that they are the default values for each function call.
In each case the mode is a unique combination of the following package options
A count of the number of chains.
A count of the number of simulations to save per chain.
A count of the thining interval.
A flag indicating whether to perform the analysis in parallel.
A flag indicating whether to disable tracing information.
A flag indicating whether to beep on completion of the analysis.
A flag indicating whether to print a model summary.
A count specifying the maximum number of reanalyses.
A number specifying the rhat threshold.
A number specifying the minimum effective sampling rate.
The maximum total time to spend on analysis and reanalysis.
A number specifying the confidence level.
The old options.
## Not run: set_analysis_mode("reset") ## End(Not run)
## Not run: set_analysis_mode("reset") ## End(Not run)
Requires that new_expr includes 'residual <- res_bern(' or 'residual[i] <- res_norm('.
simulate_residuals(x, type = NULL)
simulate_residuals(x, type = NULL)
x |
The MB analysis object. |
type |
A string of the residual type. |
An mcmc_data of the simulated residuals.
extras::res_binom
Sort Analyses by IC
sort_by_ic(x, ...)
sort_by_ic(x, ...)
x |
the object. |
... |
Unused |
The sorted object
Sorts a named list by its names.
sort_nlist(x)
sort_nlist(x)
x |
The named list to sort. |
The sorted named list.
sort_nlist(list(y = 2, x = 1, a = 10))
sort_nlist(list(y = 2, x = 1, a = 10))
Gets the template string for an object.
template(object, ...)
template(object, ...)
object |
The object. |
... |
Additional arguments. |
The template model code as a string.
Sets the template for an object.
template(object) <- value
template(object) <- value
object |
The object. |
value |
A string of the new template |
terms
## S3 method for class 'mb_analysis' terms(x, param_type = "fixed", include_constant = TRUE, ...)
## S3 method for class 'mb_analysis' terms(x, param_type = "fixed", include_constant = TRUE, ...)
x |
The mb_analysis object. |
param_type |
A string indicating the type of terms to get the names for. |
include_constant |
A flag specifying whether to include constant terms. |
... |
Not used. |
Updates an object inherting from class mb_model.
update_model( model, code = NULL, gen_inits = NULL, random_effects = NULL, fixed = NULL, derived = NULL, select_data = NULL, center = NULL, scale = NULL, modify_data = NULL, nthin = NULL, new_expr = NULL, new_expr_vec = getOption("mb.new_expr_vec", FALSE), modify_new_data = NULL, drops = NULL, ... )
update_model( model, code = NULL, gen_inits = NULL, random_effects = NULL, fixed = NULL, derived = NULL, select_data = NULL, center = NULL, scale = NULL, modify_data = NULL, nthin = NULL, new_expr = NULL, new_expr_vec = getOption("mb.new_expr_vec", FALSE), modify_new_data = NULL, drops = NULL, ... )
model |
The model to update. |
code |
A string of the model template or an object inheriting from class mb_code. |
gen_inits |
A single argument function taking the modified data and returning a named list of initial values. |
random_effects |
A named list specifying the random effects and the associated factors. |
fixed |
A string of a regular expression specifying the fixed pars to monitor. |
derived |
A character vector of the derived pars to monitor. |
select_data |
A named list specifying the columns to select and their associated classes and values as well as transformations and scaling options. |
center |
A character vector of the columns to center. |
scale |
A character vector of the columns to scale (after centering). |
modify_data |
A single argument function to modify the data (in list form) immediately prior to the analysis. |
nthin |
A count specifying the thinning interval. |
new_expr |
A string of R code specifying the predictive relationships. |
new_expr_vec |
A flag specifying whether to vectorize the new_expr code. |
modify_new_data |
A single argument function to modify new data (in list form) immediately prior to calculating new_expr. |
drops |
A list of character vector of possible scalar pars to drop (fix at 0). |
... |
Unused arguments. |
An object inheriting from class mb_model.