# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Density matrix calculation
#'
#' Calculate conditional joint densities for each association pattern, given marginal
#' null and alternative densities, under the assumption of independence.
#'
#' @param Q matrix of association patterns.
#' @param D0 matrix of density estimates under the null distribution.
#' @param D1 matrix of density estimates under the alternative distributions.
#'
#' @return A matrix estimating the conditional joint densities
#' under each association pattern for each observation (e.g SNP).
#'
#' @export
#'
calc_Dmatrix <- function(Q, D0, D1) {
.Call(`_Primo_calc_Dmatrix`, Q, D0, D1)
}
#' E-step
#'
#' Calculate posterior expectations given maximized estimate for \eqn{\pi}, the
#' proportion of observations (e.g. SNPs) coming from each association pattern.
#'
#' @param old_pi vector of association pattern proportions, fit through maximization.
#' @param Dmat matrix of conditional joint densities under each association pattern.
#'
#' @return A matrix estimating the posterior expectations
#' (i.e. estimated proportion of observations belonging to each association pattern).
#'
#' @export
#'
e_step <- function(old_pi, Dmat) {
.Call(`_Primo_e_step`, old_pi, Dmat)
}
#' E-step, with column sums of posterior probabilities
#'
#' Calculate posterior expectations given maximized estimate for \eqn{\pi} (the
#' proportion of observations coming from each association pattern). Return column sums of the posterior
#' expectations. This allows the M-step to be completed in chunks (dividing a running sum
#' by the total number of rows at the end to obtain the mean), alleviating potential memory issues.
#'
#' @inheritParams e_step
#'
#' @return A row vector of column sums of posterior expectations
#' (allows M-step to be performed in chunks).
#'
#' @export
#'
e_step_withColSums <- function(old_pi, Dmat) {
.Call(`_Primo_e_step_withColSums`, old_pi, Dmat)
}
#' M-step
#'
#' Estimates the \eqn{\pi} vector that maximizes the posterior expectation function from the E-step.
#'
#' @param old_B matrix of posterior expectations/probabilities (e.g. from an E-step).
#'
#' @return A row vector estimating the proportion of observations coming from each association pattern.
#'
#' @export
#'
m_step <- function(old_B) {
.Call(`_Primo_m_step`, old_B)
}
#' EM Iteration
#'
#' Complete one iteration of the EM-algorithm (combines E-step and M-step).
#' Calculate posterior expectations given current estimate for \eqn{\pi},the
#' proportion of observations (e.g. SNPs) coming from each association pattern
#' (i.e. E-Step). Re-estimate the \eqn{\pi} vector that maximizes the posterior
#' expectations (i.e. M-step).
#'
#' @inheritParams e_step
#'
#' @inherit m_step return
#'
#' @export
#'
em_iter <- function(old_pi, Dmat) {
.Call(`_Primo_em_iter`, old_pi, Dmat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.