Skip to contents

This function calculates the log-likelihood using the expectation maximization algorithm with the Normal-Uniform Distribution. This code is not identical to nQuire and uses an augmented likelihood.

Usage

emstepNUA(parmlist, xi, niter, epsilon, trunc, type = "free", glreturn = FALSE)

Arguments

parmlist

A list containing initial alpha, mean, and variance values. The list of alpha must include a proportion for the uniform mixture.

xi

List of observations, in this case allele frequencies.

niter

Max number of iterates.

epsilon

Epsilon value for convergence tolerance. When the absolute delta log-likelihood is below this value, convergence is reached.

trunc

List of two values representing the lower and upper bounds, \(c_{L}\) and \(c_{U}\).

type

String indicating model type. Options: "free" (estimated parameter(s): alpha, mean, and variance), "fixed" (estimated parameter(s): alpha), "fixed_2" (estimated parameter(s): alpha and variance), or "fixed_3" (estimated parameter(s): variance).

glreturn

Logical statement, if true, the function will return the log-likelihood, negative log-likelihood, optimized parameter values, number of iterates, and the probability of each observation belonging to each mixture model. If false, the function will return the log-likelihood, negative log-likelihood, optimized parameter values, and number of iterates.

Value

List of elements including the log-likelihood, the number of iterates, and the optimized parameter values.

Examples

if(exists("crazy")){
  xi <- (xm[,2]/xm[,1])
  p = list(avec = c(0.18, 0.18, 0.18, 0.18, 0.18, 0.1),
           mvec = c(0.20, 0.33, 0.50, 0.67, 0.80),
           svec = c(0.01, 0.01, 0.01, 0.01, 0.01));
  mout <- emstepNUA(p,
                    xi,
                    niter = 100,
                    epsilon = 0.1,
                    trunc = c(0.0,0.0))
}