R/RcppExports.R

Defines functions toUnitScale fromUnitScale generate_foi generate_riskS generate_riskI generate_probM_aux generate_probM likelihood_probM likelihood_probM_norm average_buckets sum_buckets generate_probM_forecast generate_probM_forecast_OLD

Documented in average_buckets fromUnitScale generate_foi generate_probM generate_probM_aux generate_probM_forecast generate_probM_forecast_OLD generate_riskI generate_riskS likelihood_probM likelihood_probM_norm sum_buckets toUnitScale

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

#' Converts to unit scale
#'
#' @param x the double to be converted
#' @param min the minimum value on the linear scale
#' @param max the maximum value on the linear scale
#' @return the value converted to a unit scale
#' @export
toUnitScale <- function(x, min, max) {
    .Call(`_zikaInfer_toUnitScale`, x, min, max)
}

#' Converts to linear scale
#'
#' @param x the double to be converted back to linear scale
#' @param min the minimum value on the linear scale
#' @param max the maximum value on the linear scale
#' @return the value converted to a linear scale
#' @export
fromUnitScale <- function(x, min, max) {
    .Call(`_zikaInfer_fromUnitScale`, x, min, max)
}

#' FOI calculation
#'
#' Calculates the force of infection over time for an SEIR model
#' @param IM a numeric vector of number of infected mosquitoes over time
#' @param NH the constant human population size
#' @param b the per vector per day bite rate
#' @param pMH the probability of transmission upon bite
#' @param tstep the time step over which to bucket the force of infection. Best left to 1 for 1 day
#' @return the vector of FOI
#' @export
generate_foi <- function(IM, NH, b, pMH, tstep) {
    .Call(`_zikaInfer_generate_foi`, IM, NH, b, pMH, tstep)
}

#' Cumulative susceptible probability
#' 
#' Calculates the cumulative probability of remaining susceptible over the course of the epidemic
#' @param foi the time varying force of infection as generated by generate_foi
#' @param tstep the time step for the buckets. Best left to 1.
#' @return the vector of cumulative escape probabilities
#' @export
generate_riskS <- function(foi, tstep) {
    .Call(`_zikaInfer_generate_riskS`, foi, tstep)
}

#' Risk of infection
#' 
#' Calculates the relative risk of infection over time
#' @param foi the time varying force of infection as generated by generate_foi
#' @param riskS the cumulative probability of remaining susceptible over the course of the epidemic as generated by generate_riskS
#' @param tstep the time step for the buckets. Best left to 1.
#' @return the vector of relative infection risks
#' @export
generate_riskI <- function(foi, riskS, tstep) {
    .Call(`_zikaInfer_generate_riskI`, foi, riskS, tstep)
}

#' Time varying microcephaly risk AUX
#'
#' Calculates the probability of a birth having microcephaly at a given time
#' @param riskI the relative risk of infection over time as generated by generate_riskI
#' @param probM the time varying risk of developing microcephaly given infection over the course of gestation. Time steps should be the same as riskI
#' @param bp the baseline probability of microcephaly
#' @return the vector of microcephaly probabilities
#' @export
generate_probM_aux <- function(riskI, probM, bp) {
    .Call(`_zikaInfer_generate_probM_aux`, riskI, probM, bp)
}

#' Time varying microcephaly risk
#'
#' Given the epidemic model parameters and number of infected mosquitoes over time, calculates the probability of a birth having microcephaly at a given time
#' @param IM a numeric vector of number of infected mosquitoes over time
#' @param probM the time varying risk of developing microcephaly given infection over the course of gestation
#' @param NH the constant human population size
#' @param b the per vector per day bite rate
#' @param pMH the probability of transmission upon bite
#' @param bp the baseline probability of microcephaly
#' @param tstep the time step for the buckets. Best left to 1.
#' @return the vector of microcephaly probabilities
#' @export
generate_probM <- function(IM, NH, probM, b, pMH, bp, tstep) {
    .Call(`_zikaInfer_generate_probM`, IM, NH, probM, b, pMH, bp, tstep)
}

#' Likelihood function for time-varying microcephaly
#'
#' Calculates the likelihood of observing a vector of microcephaly births given the total number of births and microcephaly probabilities. Note that all vectors must be equal lengths.. Assuming binomial distribution.
#' @param microBirths the vector of observed microcephaly cases over time
#' @param allBirths the corresponding total number of births
#' @param probM the corresponding vector of microcephaly probabilities as calculated by generate_probM.
#' @return a single likelihood value
#' @export
likelihood_probM <- function(microBirths, allBirths, probM) {
    .Call(`_zikaInfer_likelihood_probM`, microBirths, allBirths, probM)
}

#' Likelihood function for time-varying microcephaly
#'
#' Calculates the likelihood of observing a vector of microcephaly births given the total number of births and microcephaly probabilities. Note that all vectors must be equal lengths. Assuming normal distribution.
#' @param microBirths the vector of observed microcephaly cases over time
#' @param allBirths the corresponding total number of births
#' @param probM the corresponding vector of microcephaly probabilities as calculated by generate_probM.
#' @param lik_sd assumed standard deviation of the likelihood function
#' @return a single likelihood value
#' @export
likelihood_probM_norm <- function(microBirths, allBirths, probM, lik_sd) {
    .Call(`_zikaInfer_likelihood_probM_norm`, microBirths, allBirths, probM, lik_sd)
}

#' Averages a vector based on bucket sizes
#'
#' Given a vector (a) and another vector of bucket sizes, returns the averaged vector (a)
#' @param a the vector to be bucketed and averaged
#' @param buckets the vector of bucket sizes to average a over
#' @return the vector of averaged a
#' @export
average_buckets <- function(a, buckets) {
    .Call(`_zikaInfer_average_buckets`, a, buckets)
}

#' Sums a vector based on bucket sizes
#'
#' Given a vector (a) and another vector of bucket sizes, returns the summed vector (a)
#' @param a the vector to be bucketed
#' @param buckets the vector of bucket sizes to sum a over
#' @return the vector of summed a
#' @export
sum_buckets <- function(a, buckets) {
    .Call(`_zikaInfer_sum_buckets`, a, buckets)
}

#' Time varying microcephaly risk not aborted
#'
#' Calculates the probability of a birth having microcephaly at a given time
#' @param riskI the relative risk of infection over time as generated by generate_riskI
#' @param probM the time varying risk of developing microcephaly given infection over the course of gestation. Time steps should be the same as riskI
#' @param bp the baseline probability of microcephaly
#' @param abortion_rate probability of a women having an abortion given that she was infected
#' @param birth_reduction reduced probability of getting infected, synonymous with probability of avoiding pregnancy
#' @param switch_t integer for index after which behaviour changes
#' @param abortion_time integer for last allowable abortion day/week in gestational time
#' @param ABORTED if TRUE, then return the number of aborted cases. If FALSE, return the number of not aborted cases.
#' @return the vector of microcephaly probabilities
#' @export
generate_probM_forecast <- function(riskI, probM, bp, abortion_rate, birth_reduction, switch_t, abortion_time, ABORTED) {
    .Call(`_zikaInfer_generate_probM_forecast`, riskI, probM, bp, abortion_rate, birth_reduction, switch_t, abortion_time, ABORTED)
}

#' Time varying microcephaly risk AUX
#'
#' Calculates the probability of a birth having microcephaly at a given time
#' @param riskI the relative risk of infection over time as generated by generate_riskI
#' @param probM the time varying risk of developing microcephaly given infection over the course of gestation. Time steps should be the same as riskI
#' @param bp the baseline probability of microcephaly
#' @param abortion_rate probability of a women getting an abortion given that she was infected
#' @param birth_reduction reduced probability of getting infected, synonymous with probability of avoiding pregnancy
#' @param switch_t integer for index after which behaviour changes
#' @param abortion_time integer for last allowable abortion day/week
#' @return the vector of microcephaly probabilities
#' @export
generate_probM_forecast_OLD <- function(riskI, probM, bp, abortion_rate, birth_reduction, switch_t, abortion_time) {
    .Call(`_zikaInfer_generate_probM_forecast_OLD`, riskI, probM, bp, abortion_rate, birth_reduction, switch_t, abortion_time)
}
jameshay218/zikaProj documentation built on Jan. 9, 2020, 7:26 p.m.