R/RcppExports.R

Defines functions negll_lndscp_height negll_titer_lm calc_mean_titer_negll_without_sd calc_mean_titer_negll negll_cone_pars

Documented in calc_mean_titer_negll negll_lndscp_height negll_titer_lm

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

negll_cone_pars <- function(par, cone_heights, cone_slope, cone_coords, ag_coords, max_titers, min_titers, error_sd, optimise_cone_slope, optimise_cone_coords) {
    .Call('_ablandscapes_negll_cone_pars', PACKAGE = 'ablandscapes', par, cone_heights, cone_slope, cone_coords, ag_coords, max_titers, min_titers, error_sd, optimise_cone_slope, optimise_cone_coords)
}

#' Calculate log likelihood of single fitted HI titer
#' 
#' This is the base function for performing a maximum likelihood calculation for a 
#' single fitted HI titer given upper and lower limits of the measured value.
#'
#' @param max_titer The upper bound of the measured titer.
#' @param min_titer The lower bound of the measured titer.
#' @param pred_titer The predicted titer.
#' @param error_sd The standard deviation of the error.
#'
#' @details This function simply calculates to log likelihood of a predicted measurement 
#' given the upper and lower bounds of the measurement, the main assumption being that the 
#' associated error is normally distributed.
#'
#' @return Returns the log-likelihood of the measured titer given the measured titer 
#' bounds and error standard deviation supplied.
NULL

#' Calculate the total negative log-likelihood of a mean titer
#' 
#' This is a base function to sum the total _negative_ log likelihood of a mean titer.
#' 
#' @param max_titers Numeric vector of the upper bounds of the measured titers.
#' @param min_titers Numeric vector of the lower bounds of the measured titers.
#' @param predicted_mean The predicted mean titer.
#' @param titer_sd The expected standard deviation of titers.
#' 
#' @details This function calculates the total negative log-likelihood of a predicted mean 
#' titer given a set of titers. The main assumption is that both measurement error and 
#' titer variation are normally distributed. Note that the argument \code{titer_sd} is the 
#' total expected standard deviation of the titer set, i.e. measurement error plus titer 
#' variation.
#' 
calc_mean_titer_negll <- function(predicted_mean, max_titers, min_titers, titer_sd) {
    .Call('_ablandscapes_calc_mean_titer_negll', PACKAGE = 'ablandscapes', predicted_mean, max_titers, min_titers, titer_sd)
}

calc_mean_titer_negll_without_sd <- function(pars, max_titers, min_titers) {
    .Call('_ablandscapes_calc_mean_titer_negll_without_sd', PACKAGE = 'ablandscapes', pars, max_titers, min_titers)
}

#' Calculate the negative log likelihood of a linear model
#' 
#' This is the base function used by the optimizer to calculate the negative
#' log likelihood of a given set of linear model parameters
#' 
#' @param par A vector of parameters, intercept followed by coefficients for each
#'   coordinate dimension, or in the case of getting likelihood for a given height 
#'   simply the coefficients for each coordinate dimension
#' @param max_titers Numeric vector of the upper bounds of the measured titers
#' @param min_titers Numeric vector of the lower bounds of the measured titers
#' @param ag_coords Matrix of antigenic coordinates relative to the landscape
#'   coordinates being modelled
#' @param ag_weights A vector of weights to apply to each antigen, according to
#'   their distance from the point being modelled
#' @param error_sd The expected standard deviation of titer error
#' 
#' @name negll_titer_lm
#' 
NULL

#' @rdname negll_titer_lm
negll_titer_lm <- function(par, max_titers, min_titers, ag_coords, ag_weights, error_sd) {
    .Call('_ablandscapes_negll_titer_lm', PACKAGE = 'ablandscapes', par, max_titers, min_titers, ag_coords, ag_weights, error_sd)
}

#' @rdname negll_titer_lm
negll_lndscp_height <- function(par, lndscp_height, max_titers, min_titers, ag_coords, ag_weights, error_sd) {
    .Call('_ablandscapes_negll_lndscp_height', PACKAGE = 'ablandscapes', par, lndscp_height, max_titers, min_titers, ag_coords, ag_weights, error_sd)
}
acorg/ablandscapes documentation built on March 4, 2024, 7:50 a.m.