% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/apollo_mixEM.R
\name{apollo_mixEM}
\alias{apollo_mixEM}
\title{Uses EM for models with continuous random coefficients}
\usage{
apollo_mixEM(
  apollo_beta,
  apollo_fixed,
  apollo_probabilities,
  apollo_inputs,
  mixEM_settings = NA,
  estimate_settings = NA
)
}
\arguments{
\item{apollo_beta}{Named numeric vector. Names and values for parameters. These need to be provided in the following order. With K random parameters, K means for the underlying Normals, followed by the elements of the lower triangle of the Cholesky matrix, by row.}

\item{apollo_fixed}{Character vector. Names (as defined in \code{apollo_beta}) of parameters whose value should not change during estimation.}

\item{apollo_probabilities}{Function. Returns probabilities of the model to be estimated. Must receive three arguments:
\itemize{
  \item \strong{\code{apollo_beta}}: Named numeric vector. Names and values of model parameters.
  \item \strong{\code{apollo_inputs}}: List containing options of the model. See \link{apollo_validateInputs}.
  \item \strong{\code{functionality}}: Character. Can be either \strong{\code{"components"}}, \strong{\code{"conditionals"}}, \strong{\code{"estimate"}} (default), \strong{\code{"gradient"}}, \strong{\code{"output"}}, \strong{\code{"prediction"}}, \strong{\code{"preprocess"}}, \strong{\code{"raw"}}, \strong{\code{"report"}}, \strong{\code{"shares_LL"}}, \strong{\code{"validate"}} or \strong{\code{"zero_LL"}}.
}}

\item{apollo_inputs}{List grouping most common inputs. Created by function \link{apollo_validateInputs}.}

\item{mixEM_settings}{List. Contains settings for this function. User input is required for all settings except those with a default or marked as optional. 
         \itemize{
\item \strong{EMmaxIterations}: Numeric. Maximum number of iterations of the EM algorithm before 
                                stopping. Default is 100. 
\item \strong{postEM}: Numeric scalar. Determines the tasks performed by this function 
                       after the EM algorithm has converged. Can take values \code{0}, \code{1} 
                       or \code{2} only. If value is \code{0}, only the EM algorithm will be 
                       performed, and the results will be a model object without a covariance 
                       matrix (i.e. estimates only). If value is \code{1}, after the EM 
                       algorithm, the covariance matrix of the model will be calculated as well, 
                       and the result will be a model object with a covariance matrix. If value 
                       is \code{2}, after the EM algorithm, the estimated parameter values will 
                       be used as starting value for a maximum likelihood estimation process, 
                       which will render a model object with a covariance matrix. Performing 
                       maximum likelihood estimation after the EM algorithm is useful, as there 
                       may be room for further improvement. Default is \code{2}.
\item \strong{silent}: Boolean. If TRUE, no information is printed to the console during 
                       estimation. Default is FALSE.
\item \strong{stoppingCriterion}: Numeric. Convergence criterion. The EM process will stop when 
                                  improvements in the log-likelihood fall below this value. 
                                  Default is 10^-5.
           \item \strong{transforms}: List. Optional argument, with one entry per parameter, showing the inverse transform to return from beta to the underlying Normal. E.g. if the first parameter is specified as negative logormal inside apollo_randCoeff, then the entry in transforms should be transforms[[1]]=function(x) log(-x)
         }}

\item{estimate_settings}{List. Options controlling the estimation process within each EM iteration. See \link{apollo_estimate} for details.}
}
\value{
model object
}
\description{
Uses the EM algorithm for estimating a model with continuous random coefficients.
}
\details{
This function uses the EM algorithm for estimating a model with continuous random coefficients. It is only suitable for models where all parameters are random, with a full covariance matrix.
All random parameters need to be based on underlying Normals with a full covariance matrix, but any transform thereof can be used.
}
