R/RcppExports.R

Defines functions m_cpp em_cpp rcpp_mce_grid_factorial rcpp_mce_grid e_cpp explore_grid_cpp simulate_pd_trees_cpp simulate_single_pd_tree_cpp loglikelihood generateNonHomogeneousExpCpp explore_div_grid_cpp simulate_div_trees_cpp simulate_div_tree_cpp

Documented in e_cpp em_cpp loglikelihood m_cpp simulate_single_pd_tree_cpp

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

simulate_div_tree_cpp <- function(pars, max_t, max_N, max_tries) {
    .Call('_emphasis_simulate_div_tree_cpp', PACKAGE = 'emphasis', pars, max_t, max_N, max_tries)
}

simulate_div_trees_cpp <- function(pars, max_t, repl, max_N) {
    .Call('_emphasis_simulate_div_trees_cpp', PACKAGE = 'emphasis', pars, max_t, repl, max_N)
}

explore_div_grid_cpp <- function(par1, par2, par3, par4, par5, par6, max_t, num_repl, max_N) {
    .Call('_emphasis_explore_div_grid_cpp', PACKAGE = 'emphasis', par1, par2, par3, par4, par5, par6, max_t, num_repl, max_N)
}

generateNonHomogeneousExpCpp <- function(num_variates, covariates, parameters, start_time, max_time) {
    .Call('_emphasis_generateNonHomogeneousExpCpp', PACKAGE = 'emphasis', num_variates, covariates, parameters, start_time, max_time)
}

#' function to calculate log likelihood of pars for a tree set,
#' @param pars vector of parameter values
#' @param trees list of trees, e.g. a multiPhylo object
#' @param logg vector of logg values
#' @param plugin name of used plugin
#' @param num_rejected number of rejected trees
#' @return list with the following entries: 
#' \itemize{
#'  \item{logf}{logf values}
#'  \item{log_w}{log of weight}
#'  \item{fhat}{fhat values}
#'  \item{N}{number of trees}
#' }
#' @export
loglikelihood <- function(pars, trees, logg, plugin, num_rejected) {
    .Call('_emphasis_loglikelihood', PACKAGE = 'emphasis', pars, trees, logg, plugin, num_rejected)
}

simulate_single_pd_tree_cpp <- function(pars, max_t, max_N, max_tries) {
    .Call('_emphasis_simulate_single_pd_tree_cpp', PACKAGE = 'emphasis', pars, max_t, max_N, max_tries)
}

simulate_pd_trees_cpp <- function(pars, max_t, repl, max_N) {
    .Call('_emphasis_simulate_pd_trees_cpp', PACKAGE = 'emphasis', pars, max_t, repl, max_N)
}

explore_grid_cpp <- function(par1, par2, par3, par4, max_t, num_repl, max_N) {
    .Call('_emphasis_explore_grid_cpp', PACKAGE = 'emphasis', par1, par2, par3, par4, max_t, num_repl, max_N)
}

#' function to perform one step of the E-M algorithm
#' @param brts vector of branching times
#' @param init_pars vector of initial parameter files
#' @param sample_size number of samples
#' @param maxN maximum number of failed trees
#' @param soc number of lineages at the root/crown (1/2)
#' @param max_missing maximum number of species missing
#' @param max_lambda maximum speciation rate
#' @param lower_bound vector of lower bound values for optimization, should
#' be equal in length to the vector of init_pars
#' @param upper_bound vector of upper bound values for optimization, should
#' be equal in length to the vector of init_pars
#' @param xtol_rel relative tolerance for optimization
#' @param num_threads number of threads used.
#' @return a list with the following components: 
#' \itemize{
#'  \item{trees}{list of trees}
#'  \item{rejected}{number of rejected trees}
#'  \item{rejected_overruns}{number of trees rejected due to too large size}
#'  \item{rejected_lambda}{number of trees rejected due to lambda errors}
#'  \item{rejected_zero_weights}{number of trees rejected to zero weight}
#'  \item{time_elapsed}{time used}
#'  \item{weights}{vector of weights}
#'  \item{fhat}{vector of fhat values}
#'  \item{logf}{vector of logf values}
#'  \item{logg}{vector of logg values}
#' }
#' @export
e_cpp <- function(brts, init_pars, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads) {
    .Call('_emphasis_rcpp_mce', PACKAGE = 'emphasis', brts, init_pars, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads)
}

rcpp_mce_grid <- function(pars_R, brts, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads) {
    .Call('_emphasis_rcpp_mce_grid', PACKAGE = 'emphasis', pars_R, brts, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads)
}

rcpp_mce_grid_factorial <- function(pars_R, brts, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads) {
    .Call('_emphasis_rcpp_mce_grid_factorial', PACKAGE = 'emphasis', pars_R, brts, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads)
}

#' function to perform one step of the E-M algorithm
#' @param brts vector of branching times
#' @param init_pars vector of initial parameter files
#' @param sample_size number of samples
#' @param maxN maximum number of failed trees
#' @param soc number of lineages at the root/crown (1/2)
#' @param max_missing maximum number of species missing
#' @param max_lambda maximum speciation rate
#' @param lower_bound vector of lower bound values for optimization, should
#' be equal in length to the vector of init_pars
#' @param upper_bound vector of upper bound values for optimization, should
#' be equal in length to the vector of init_pars
#' @param xtol_rel relative tolerance for optimization
#' @param num_threads number of threads used.
#' @param copy_trees if set to true, the trees generated are returned as well
#' @param rconditional R function that evaluates the GAM function.
#' @return a list with the following components: 
#' \itemize{
#'  \item{trees}{list of trees}
#'  \item{rejected}{number of rejected trees}
#'  \item{rejected_overruns}{number of trees rejected due to too large size}
#'  \item{rejected_lambda}{number of trees rejected due to lambda errors}
#'  \item{rejected_zero_weights}{number of trees rejected to zero weight}
#'  \item{estimates}{vector of estimates}
#'  \item{nlopt}{nlopt status}
#'  \item{fhat}{vector of fhat values}
#'  \item{time}{time elapsed}
#'  \item{weights}{vector of weights}
#' }
#' @export
em_cpp <- function(brts, init_pars, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads, copy_trees, rconditional = NULL) {
    .Call('_emphasis_rcpp_mcem', PACKAGE = 'emphasis', brts, init_pars, sample_size, maxN, soc, max_missing, max_lambda, lower_bound, upper_bound, xtol_rel, num_threads, copy_trees, rconditional)
}

#' function to perform one step of the E-M algorithm
#' @param e_step result of e_step function, as a list
#' @param init_pars vector of initial parameter values
#' @param plugin string indicating plugin used, currently available: 'rpd1' and
#' 'rpd5c'
#' @param lower_bound vector of lower bound values for optimization, should
#' be equal in length to the vector of init_pars
#' @param upper_bound vector of upper bound values for optimization, should
#' be equal in length to the vector of init_pars 
#' @param xtol_rel relative tolerance for optimization
#' @param num_threads number of threads used.
#' @param rconditional R function that evaluates the GAM function.
#' @return list with the following entries:
#' \itemize{
#'  \item{estimates}{vector of estimates}
#'  \item{nlopt}{nlopt status}
#'  \item{time}{used computation time} 
#' }
#' @export
m_cpp <- function(e_step, init_pars, plugin, lower_bound, upper_bound, xtol_rel, num_threads, rconditional = NULL) {
    .Call('_emphasis_rcpp_mcm', PACKAGE = 'emphasis', e_step, init_pars, plugin, lower_bound, upper_bound, xtol_rel, num_threads, rconditional)
}
franciscorichter/emphasis documentation built on Feb. 19, 2024, 7:36 p.m.