Learn R Programming

meteorits (version 0.1.1)

emNMoE: emNMoE implements the EM algorithm to fit a Normal Mixture of Experts (NMoE).

Description

emNMoE implements the maximum-likelihood parameter estimation of a Normal Mixture of Experts (NMoE) model by the Expectation-Maximization (EM) algorithm.

Usage

emNMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500,
  threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)

Arguments

X

Numeric vector of length n representing the covariates/inputs \(x_{1},\dots,x_{n}\).

Y

Numeric vector of length n representing the observed response/output \(y_{1},\dots,y_{n}\).

K

The number of experts.

p

Optional. The order of the polynomial regression for the experts.

q

Optional. The order of the logistic regression for the gating network.

n_tries

Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned.

max_iter

Optional. The maximum number of iterations for the EM algorithm.

threshold

Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria.

verbose

Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations.

verbose_IRLS

Optional. A logical value indicating whether or not values of the criterion optimized by IRLS should be printed at each step of the EM algorithm.

Value

EM returns an object of class ModelNMoE.

Details

emNMoE function implements the EM algorithm for the NMoE model. This function starts with an initialization of the parameters done by the method initParam of the class ParamNMoE, then it alternates between the E-Step (method of the class StatNMoE) and the M-Step (method of the class ParamNMoE) until convergence (until the relative variation of log-likelihood between two steps of the EM algorithm is less than the threshold parameter).

See Also

ModelNMoE, ParamNMoE, StatNMoE

Examples

Run this code
# NOT RUN {
data(tempanomalies)
x <- tempanomalies$Year
y <- tempanomalies$AnnualAnomaly

nmoe <- emNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE)

nmoe$summary()

nmoe$plot()
# }

Run the code above in your browser using DataLab