Title: | Mixture-of-Experts Modeling for Complex Non-Normal Distributions |
---|---|
Description: | Provides a unified mixture-of-experts (ME) modeling and estimation framework with several original and flexible ME models to model, cluster and classify heterogeneous data in many complex situations where the data are distributed according to non-normal, possibly skewed distributions, and when they might be corrupted by atypical observations. Mixtures-of-Experts models for complex and non-normal distributions ('meteorits') are originally introduced and written in 'Matlab' by Faicel Chamroukhi. The references are mainly the following ones. The references are mainly the following ones. Chamroukhi F., Same A., Govaert, G. and Aknin P. (2009) <doi:10.1016/j.neunet.2009.06.040>. Chamroukhi F. (2010) <https://chamroukhi.com/FChamroukhi-PhD.pdf>. Chamroukhi F. (2015) <arXiv:1506.06707>. Chamroukhi F. (2015) <https://chamroukhi.com/FChamroukhi-HDR.pdf>. Chamroukhi F. (2016) <doi:10.1109/IJCNN.2016.7727580>. Chamroukhi F. (2016) <doi:10.1016/j.neunet.2016.03.002>. Chamroukhi F. (2017) <doi:10.1016/j.neucom.2017.05.044>. |
Authors: | Faicel Chamroukhi [aut] , Florian Lecocq [aut, trl, cre] (R port), Marius Bartcus [aut, trl] (R port) |
Maintainer: | Florian Lecocq <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.1 |
Built: | 2024-11-27 06:51:39 UTC |
Source: | CRAN |
meteorits
is a package containing several original and
flexible mixtures-of-experts models to model, cluster and classify
heteregenous data in many complex situations where the data are distributed
according to non-normal and possibly skewed distributions, and when they
might be corrupted by atypical observations. The toolbox also contains
sparse mixture-of-experts models for high-dimensional data.
meteorits
contains the following Mixture-of-Experts models:
NMoE (Normal Mixtures-of-Experts) provides a flexible framework for heterogenous data with Normal expert regressors network;
SNMoE (Skew-Normal Mixtures-of-Experts) provides a flexible modeling framework for heterogenous data with possibly skewed distributions to generalize the standard Normal mixture of expert model;
tMoE (t Mixtures-of-Experts) provides a flexible and robust modeling framework for heterogenous data with possibly heavy-tailed distributions and corrupted by atypical observations;
StMoE (Skew t Mixtures-of-Experts) provides a flexible and robust modeling framework for heterogenous data with possibly skewed, heavy-tailed distributions and corrupted by atypical observations.
For the advantages/differences of each of them, the user is referred to our mentioned paper references.
To learn more about meteorits
, start with the vignettes:
browseVignettes(package = "meteorits")
Maintainer: Florian Lecocq [email protected] (R port) [translator]
Authors:
Faicel Chamroukhi [email protected] (0000-0002-5894-3103)
Marius Bartcus [email protected] (R port) [translator]
Chamroukhi, F. 2017. Skew-T Mixture of Experts. Neurocomputing - Elsevier 266: 390–408. https://chamroukhi.com/papers/STMoE.pdf.
Chamroukhi, F. 2016a. Robust Mixture of Experts Modeling Using the T-Distribution. Neural Networks - Elsevier 79: 20–36. https://chamroukhi.com/papers/TMoE.pdf.
Chamroukhi, F. 2016b. Skew-Normal Mixture of Experts. In The International Joint Conference on Neural Networks (IJCNN). Vancouver, Canada. https://chamroukhi.com/papers/Chamroukhi-SNMoE-IJCNN2016.pdf.
Chamroukhi, F. 2015a. Non-Normal Mixtures of Experts. http://arxiv.org/pdf/1506.06707.pdf.
Chamroukhi, F. 2015b. Statistical Learning of Latent Data Models for Complex Data Analysis. Habilitation Thesis (HDR), Universite de Toulon. https://chamroukhi.com/FChamroukhi-HDR.pdf.
Chamroukhi, F. 2010. Hidden Process Regression for Curve Modeling, Classification and Tracking. Ph.D. Thesis, Universite de Technologie de Compiegne. https://chamroukhi.com/FChamroukhi-PhD.pdf.
Chamroukhi, F., A. Same, G. Govaert, and P. Aknin. 2009. Time Series Modeling by a Regression Approach Based on a Latent Process. Neural Networks 22 (5-6): 593–602. https://chamroukhi.com/papers/Chamroukhi_Neural_Networks_2009.pdf.
Useful links:
Report bugs at https://github.com/fchamroukhi/MEteorits/issues
emNMoE implements the maximum-likelihood parameter estimation of a Normal Mixture of Experts (NMoE) model by the Expectation-Maximization (EM) algorithm.
emNMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
emNMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
X |
Numeric vector of length n representing the covariates/inputs
|
Y |
Numeric vector of length n representing the observed
response/output |
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. |
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).
EM returns an object of class ModelNMoE.
ModelNMoE, ParamNMoE, StatNMoE
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly nmoe <- emNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) nmoe$summary() nmoe$plot()
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly nmoe <- emNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) nmoe$summary() nmoe$plot()
emSNMoE implements the maximum-likelihood parameter estimation of a Skew-Normal Mixture of Experts (SNMoE) model by the Expectation Conditional Maximization (ECM) algorithm.
emSNMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
emSNMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
X |
Numeric vector of length n representing the covariates/inputs
|
Y |
Numeric vector of length n representing the observed
response/output |
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 ECM algorithm. The solution providing the highest log-likelihood will be returned. |
max_iter |
Optional. The maximum number of iterations for the ECM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the ECM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during ECM 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 ECM algorithm. |
emSNMoE function implements the ECM algorithm for the SNMoE model.
This function starts with an initialization of the parameters done by the
method initParam
of the class ParamSNMoE, then it
alternates between the E-Step (method of the class StatSNMoE)
and the M-Step (method of the class ParamSNMoE) until
convergence (until the relative variation of log-likelihood between two
steps of the ECM algorithm is less than the threshold
parameter).
ECM returns an object of class ModelSNMoE.
ModelSNMoE, ParamSNMoE, StatSNMoE
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly snmoe <- emSNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) snmoe$summary() snmoe$plot()
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly snmoe <- emSNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) snmoe$summary() snmoe$plot()
emStMoE implements the maximum-likelihood parameter estimation of a Skew-t Mixture of Experts (StMoE) model by the Expectation Conditional Maximization (ECM) algorithm.
emStMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
emStMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
X |
Numeric vector of length n representing the covariates/inputs
|
Y |
Numeric vector of length n representing the observed
response/output |
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 ECM algorithm. The solution providing the highest log-likelihood will be returned. |
max_iter |
Optional. The maximum number of iterations for the ECM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the ECM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during ECM 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 ECM algorithm. |
emStMoE function implements the ECM algorithm for the StMoE model.
This function starts with an initialization of the parameters done by the
method initParam
of the class ParamStMoE, then it
alternates between the E-Step (method of the class StatStMoE)
and the M-Step (method of the class ParamStMoE) until
convergence (until the relative variation of log-likelihood between two
steps of the ECM algorithm is less than the threshold
parameter).
ECM returns an object of class ModelStMoE.
ModelStMoE, ParamStMoE, StatStMoE
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly stmoe <- emStMoE(X = x, Y = y, K = 2, p = 1, threshold = 1e-4, verbose = TRUE) stmoe$summary() stmoe$plot()
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly stmoe <- emStMoE(X = x, Y = y, K = 2, p = 1, threshold = 1e-4, verbose = TRUE) stmoe$summary() stmoe$plot()
emTMoE implements the maximum-likelihood parameter estimation of a Student Mixture of Experts (TMoE) model by the Conditional Expectation Maximization (ECM) algorithm.
emTMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
emTMoE(X, Y, K, p = 3, q = 1, n_tries = 1, max_iter = 1500, threshold = 1e-06, verbose = FALSE, verbose_IRLS = FALSE)
X |
Numeric vector of length n representing the covariates/inputs
|
Y |
Numeric vector of length n representing the observed
response/output |
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 ECM algorithm. The solution providing the highest log-likelihood will be returned. |
max_iter |
Optional. The maximum number of iterations for the ECM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the ECM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during ECM 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 ECM algorithm. |
emTMoE function implements the ECM algorithm for the TMoE model. This
function starts with an initialization of the parameters done by the method
initParam
of the class ParamTMoE, then it alternates between
the E-Step (method of the class StatTMoE) and the M-Step
(method of the class ParamTMoE) until convergence (until the
relative variation of log-likelihood between two steps of the ECM algorithm
is less than the threshold
parameter).
ECM returns an object of class ModelTMoE.
ModelTMoE, ParamTMoE, StatTMoE
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly tmoe <- emTMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) tmoe$summary() tmoe$plot()
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly tmoe <- emTMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) tmoe$summary() tmoe$plot()
ModelNMoE represents an estimated NMoE model.
param
A ParamNMoE object. It contains the estimated values of the parameters.
stat
A StatNMoE object. It contains all the statistics associated to the NMoE model.
plot(what = c("meancurve", "confregions", "clusters", "loglikelihood"), ...)
Plot method.
what
The type of graph requested:
"meancurve" =
Estimated mean and estimated
experts means given the input X
(fields Ey
and
Ey_k
of class StatNMoE).
"confregions" =
Estimated mean and confidence
regions. Confidence regions are computed as plus and minus twice
the estimated standard deviation (the squarre root of the field
Vary
of class StatNMoE).
"clusters" =
Estimated experts means (field
Ey_k
) and hard partition (field klas
of class
StatNMoE).
"loglikelihood" =
Value of the log-likelihood for
each iteration (field stored_loglik
of class
StatNMoE).
...
Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))
Summary method.
digits
The number of significant digits to use when printing.
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly nmoe <- emNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) # nmoe is a ModelNMoE object. It contains some methods such as 'summary' and 'plot' nmoe$summary() nmoe$plot() # nmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: nmoe$stat$loglik # Parameters of the polynomial regressions: nmoe$param$beta
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly nmoe <- emNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) # nmoe is a ModelNMoE object. It contains some methods such as 'summary' and 'plot' nmoe$summary() nmoe$plot() # nmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: nmoe$stat$loglik # Parameters of the polynomial regressions: nmoe$param$beta
ModelSNMoE represents an estimated SNMoE model.
param
A ParamSNMoE object. It contains the estimated values of the parameters.
stat
A StatSNMoE object. It contains all the statistics associated to the SNMoE model.
plot(what = c("meancurve", "confregions", "clusters", "loglikelihood"), ...)
Plot method.
what
The type of graph requested:
"meancurve" =
Estimated mean and estimated
experts means given the input X
(fields Ey
and
Ey_k
of class StatSNMoE).
"confregions" =
Estimated mean and confidence
regions. Confidence regions are computed as plus and minus twice
the estimated standard deviation (the squarre root of the field
Vary
of class StatSNMoE).
"clusters" =
Estimated experts means (field
Ey_k
) and hard partition (field klas
of class
StatSNMoE).
"loglikelihood" =
Value of the log-likelihood for
each iteration (field stored_loglik
of class
StatSNMoE).
...
Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))
Summary method.
digits
The number of significant digits to use when printing.
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly snmoe <- emSNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) # snmoe is a ModelSNMoE object. It contains some methods such as 'summary' and 'plot' snmoe$summary() snmoe$plot() # snmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: snmoe$stat$loglik # Parameters of the polynomial regressions: snmoe$param$beta
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly snmoe <- emSNMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) # snmoe is a ModelSNMoE object. It contains some methods such as 'summary' and 'plot' snmoe$summary() snmoe$plot() # snmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: snmoe$stat$loglik # Parameters of the polynomial regressions: snmoe$param$beta
ModelStMoE represents an estimated StMoE model.
param
A ParamStMoE object. It contains the estimated values of the parameters.
stat
A StatStMoE object. It contains all the statistics associated to the StMoE model.
plot(what = c("meancurve", "confregions", "clusters", "loglikelihood"), ...)
Plot method.
what
The type of graph requested:
"meancurve" =
Estimated mean and estimated
experts means given the input X
(fields Ey
and
Ey_k
of class StatStMoE).
"confregions" =
Estimated mean and confidence
regions. Confidence regions are computed as plus and minus twice
the estimated standard deviation (the squarre root of the field
Vary
of class StatStMoE).
"clusters" =
Estimated experts means (field
Ey_k
) and hard partition (field klas
of class
StatStMoE).
"loglikelihood" =
Value of the log-likelihood for
each iteration (field stored_loglik
of class
StatStMoE).
...
Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))
Summary method.
digits
The number of significant digits to use when printing.
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly stmoe <- emStMoE(X = x, Y = y, K = 2, p = 1, threshold = 1e-4, verbose = TRUE) # stmoe is a ModelSTMoE object. It contains some methods such as 'summary' and 'plot' stmoe$summary() stmoe$plot() # stmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: stmoe$stat$loglik # Parameters of the polynomial regressions: stmoe$param$beta
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly stmoe <- emStMoE(X = x, Y = y, K = 2, p = 1, threshold = 1e-4, verbose = TRUE) # stmoe is a ModelSTMoE object. It contains some methods such as 'summary' and 'plot' stmoe$summary() stmoe$plot() # stmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: stmoe$stat$loglik # Parameters of the polynomial regressions: stmoe$param$beta
ModelTMoE represents an estimated TMoE model.
param
A ParamTMoE object. It contains the estimated values of the parameters.
stat
A StatTMoE object. It contains all the statistics associated to the TMoE model.
plot(what = c("meancurve", "confregions", "clusters", "loglikelihood"), ...)
Plot method.
what
The type of graph requested:
"meancurve" =
Estimated mean and estimated
experts means given the input X
(fields Ey
and
Ey_k
of class StatTMoE).
"confregions" =
Estimated mean and confidence
regions. Confidence regions are computed as plus and minus twice
the estimated standard deviation (the squarre root of the field
Vary
of class StatTMoE).
"clusters" =
Estimated experts means (field
Ey_k
) and hard partition (field klas
of class
StatTMoE).
"loglikelihood" =
Value of the log-likelihood for
each iteration (field stored_loglik
of class
StatTMoE).
...
Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))
Summary method.
digits
The number of significant digits to use when printing.
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly tmoe <- emTMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) # tmoe is a ModelTMoE object. It contains some methods such as 'summary' and 'plot' tmoe$summary() tmoe$plot() # tmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: tmoe$stat$loglik # Parameters of the polynomial regressions: tmoe$param$beta
data(tempanomalies) x <- tempanomalies$Year y <- tempanomalies$AnnualAnomaly tmoe <- emTMoE(X = x, Y = y, K = 2, p = 1, verbose = TRUE) # tmoe is a ModelTMoE object. It contains some methods such as 'summary' and 'plot' tmoe$summary() tmoe$plot() # tmoe has also two fields, stat and param which are reference classes as well # Log-likelihood: tmoe$stat$loglik # Parameters of the polynomial regressions: tmoe$param$beta
ParamNMoE contains all the parameters of a NMoE model.
X
Numeric vector of length n representing the covariates/inputs
.
Y
Numeric vector of length n representing the observed
response/output .
n
Numeric. Length of the response/output vector Y
.
K
The number of experts.
p
The order of the polynomial regression for the experts.
q
The order of the logistic regression for the gating network.
alpha
Parameters of the gating network. is a matrix of dimension
, with
q
the order of the logistic regression for the gating network.
q
is fixed to 1 by default.
beta
Polynomial regressions coefficients for each expert.
is a matrix of dimension
,
with
p
the order of the polynomial regression. p
is fixed to 3 by
default.
sigma2
The variances for the K
mixture components (matrix of size
).
df
The degree of freedom of the NMoE model representing the complexity of the model.
initParam(segmental = FALSE)
Method to initialize parameters alpha
, beta
and
sigma2
.
If segmental = TRUE
then alpha
, beta
and
sigma2
are initialized by clustering the response Y
uniformly into K
contiguous segments. Otherwise, alpha
,
beta
and sigma2
are initialized by clustering randomly
the response Y
into K
segments.
ParamSNMoE contains all the parameters of a SNMoE model.
X
Numeric vector of length n representing the covariates/inputs
.
Y
Numeric vector of length n representing the observed
response/output .
n
Numeric. Length of the response/output vector Y
.
K
The number of experts.
p
The order of the polynomial regression for the experts.
q
The order of the logistic regression for the gating network.
alpha
Parameters of the gating network. is a matrix of dimension
, with
q
the order of the logistic regression for the gating network.
q
is fixed to 1 by default.
beta
Polynomial regressions coefficients for each expert.
is a matrix of dimension
,
with
p
the order of the polynomial regression. p
is fixed to 3 by
default.
sigma2
The variances for the K
mixture components (matrix of size
).
lambda
The skewness parameters for each experts (matrix of size
).
delta
delta is equal to .
df
The degree of freedom of the SNMoE model representing the complexity of the model.
initParam(segmental = FALSE)
Method to initialize parameters alpha
, beta
and
sigma2
.
If segmental = TRUE
then alpha
, beta
and
sigma2
are initialized by clustering the response Y
uniformly into K
contiguous segments. Otherwise, alpha
,
beta
and sigma2
are initialized by clustering randomly
the response Y
into K
segments.
MStep(statSNMoE, verbose_IRLS)
Method which implements the M-step of the EM algorithm to learn the
parameters of the SNMoE model based on statistics provided by the object
statSNMoE
of class StatSNMoE (which contains the E-step).
ParamStMoE contains all the parameters of a StMoE model.
X
Numeric vector of length n representing the covariates/inputs
.
Y
Numeric vector of length n representing the observed
response/output .
n
Numeric. Length of the response/output vector Y
.
K
The number of experts.
p
The order of the polynomial regression for the experts.
q
The order of the logistic regression for the gating network.
alpha
Parameters of the gating network. is a matrix of dimension
, with
q
the order of the logistic regression for the gating network.
q
is fixed to 1 by default.
beta
Polynomial regressions coefficients for each expert.
is a matrix of dimension
,
with
p
the order of the polynomial regression. p
is fixed to 3 by
default.
sigma2
The variances for the K
mixture components (matrix of size
).
lambda
The skewness parameters for each experts (matrix of size
).
delta
delta is equal to .
nu
The degree of freedom for the Student distribution for each
experts (matrix of size ).
df
The degree of freedom of the StMoE model representing the complexity of the model.
initParam(segmental = FALSE)
Method to initialize parameters alpha
, beta
and
sigma2
.
If segmental = TRUE
then alpha
, beta
and
sigma2
are initialized by clustering the response Y
uniformly into K
contiguous segments. Otherwise, alpha
,
beta
and sigma2
are initialized by clustering randomly
the response Y
into K
segments.
MStep(statStMoE, calcAlpha = FALSE, calcBeta = FALSE, calcSigma2 = FALSE,
calcLambda = FALSE, calcNu = FALSE, verbose_IRLS = FALSE)
Method which implements the M-step of the EM algorithm to learn the
parameters of the StMoE model based on statistics provided by the object
statStMoE
of class StatStMoE (which contains the E-step).
ParamTMoE contains all the parameters of a TMoE model.
X
Numeric vector of length n representing the covariates/inputs
.
Y
Numeric vector of length n representing the observed
response/output .
n
Numeric. Length of the response/output vector Y
.
K
The number of experts.
p
The order of the polynomial regression for the experts.
q
The order of the logistic regression for the gating network.
alpha
Parameters of the gating network. is a matrix of dimension
, with
q
the order of the logistic regression for the gating network.
q
is fixed to 1 by default.
beta
Polynomial regressions coefficients for each expert.
is a matrix of dimension
,
with
p
the order of the polynomial regression. p
is fixed to 3 by
default.
sigma2
The variances for the K
mixture components (matrix of size
).
nu
The degree of freedom for the Student distribution for each
experts (matrix of size ).
df
The degree of freedom of the TMoE model representing the complexity of the model.
initParam(segmental = FALSE)
Method to initialize parameters alpha
, beta
and
sigma2
.
If segmental = TRUE
then alpha
, beta
and
sigma2
are initialized by clustering the response Y
uniformly into K
contiguous segments. Otherwise, alpha
,
beta
and sigma2
are initialized by clustering randomly
the response Y
into K
segments.
MStep(statTMoE, verbose_IRLS)
Method which implements the M-step of the EM algorithm to learn the
parameters of the TMoE model based on statistics provided by the object
statTMoE
of class StatTMoE (which contains the E-step).
Draw a sample from a normal mixture of linear experts model.
sampleUnivNMoE(alphak, betak, sigmak, x)
sampleUnivNMoE(alphak, betak, sigmak, x)
alphak |
The parameters of the gating network. |
betak |
Matrix of size (p + 1, K) representing the regression coefficients of the experts network. |
sigmak |
Vector of length K giving the standard deviations of the experts network. |
x |
A vector og length n representing the inputs (predictors). |
A list with the output variable y
and statistics.
y
Vector of length n giving the output variable.
zi
A vector of size n giving the hidden label of the
expert component generating the i-th observation. Its elements are
, if the i-th observation has been generated by the
k-th expert.
z
A matrix of size (n, K) giving the values of the binary
latent component indicators such that
iff
.
stats
A list whose elements are:
Ey_k
Matrix of size (n, K) giving the conditional
expectation of Yi the output variable given the value of the
hidden label of the expert component generating the ith observation
zi = k, and the value of predictor X = xi.
Ey
Vector of length n giving the conditional expectation
of Yi given the value of predictor X = xi.
Vary_k
Vector of length k representing the conditional
variance of Yi given zi = k, and X = xi.
Vary
Vector of length n giving the conditional expectation
of Yi given X = xi.
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts sigmak <- c(1, 1) # Standard deviations of the experts x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivNMoE(alphak = alphak, betak = betak, sigmak = sigmak, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts sigmak <- c(1, 1) # Standard deviations of the experts x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivNMoE(alphak = alphak, betak = betak, sigmak = sigmak, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
Draw a sample from a skew-normal mixture of linear experts model.
sampleUnivSNMoE(alphak, betak, sigmak, lambdak, x)
sampleUnivSNMoE(alphak, betak, sigmak, lambdak, x)
alphak |
The parameters of the gating network. |
betak |
Matrix of size (p + 1, K) representing the regression coefficients of the experts network. |
sigmak |
Vector of length K giving the standard deviations of the experts network. |
lambdak |
Vector of length K giving the skewness parameter of each experts. |
x |
A vector og length n representing the inputs (predictors). |
A list with the output variable y
and statistics.
y
Vector of length n giving the output variable.
zi
A vector of size n giving the hidden label of the
expert component generating the i-th observation. Its elements are
, if the i-th observation has been generated by the
k-th expert.
z
A matrix of size (n, K) giving the values of the binary
latent component indicators such that
iff
.
stats
A list whose elements are:
Ey_k
Matrix of size (n, K) giving the conditional
expectation of Yi the output variable given the value of the
hidden label of the expert component generating the ith observation
zi = k, and the value of predictor X = xi.
Ey
Vector of length n giving the conditional expectation
of Yi given the value of predictor X = xi.
Vary_k
Vector of length k representing the conditional
variance of Yi given zi = k, and X = xi.
Vary
Vector of length n giving the conditional expectation
of Yi given X = xi.
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts lambdak <- c(3, 5) # Skewness parameters of the experts sigmak <- c(1, 1) # Standard deviations of the experts x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivSNMoE(alphak = alphak, betak = betak, sigmak = sigmak, lambdak = lambdak, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts lambdak <- c(3, 5) # Skewness parameters of the experts sigmak <- c(1, 1) # Standard deviations of the experts x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivSNMoE(alphak = alphak, betak = betak, sigmak = sigmak, lambdak = lambdak, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
Draw a sample from a univariate skew-t mixture.
sampleUnivStMoE(alphak, betak, sigmak, lambdak, nuk, x)
sampleUnivStMoE(alphak, betak, sigmak, lambdak, nuk, x)
alphak |
The parameters of the gating network. |
betak |
Matrix of size (p + 1, K) representing the regression coefficients of the experts network. |
sigmak |
Vector of length K giving the standard deviations of the experts network. |
lambdak |
Vector of length K giving the skewness parameter of each experts. |
nuk |
Vector of length K giving the degrees of freedom of the experts network t densities. |
x |
A vector og length n representing the inputs (predictors). |
A list with the output variable y
and statistics.
y
Vector of length n giving the output variable.
zi
A vector of size n giving the hidden label of the
expert component generating the i-th observation. Its elements are
, if the i-th observation has been generated by the
k-th expert.
z
A matrix of size (n, K) giving the values of the binary
latent component indicators such that
iff
.
stats
A list whose elements are:
Ey_k
Matrix of size (n, K) giving the conditional
expectation of Yi the output variable given the value of the
hidden label of the expert component generating the ith observation
zi = k, and the value of predictor X = xi.
Ey
Vector of length n giving the conditional expectation
of Yi given the value of predictor X = xi.
Vary_k
Vector of length k representing the conditional
variance of Yi given zi = k, and X = xi.
Vary
Vector of length n giving the conditional expectation
of Yi given X = xi.
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts sigmak <- c(0.5, 0.5) # Standard deviations of the experts lambdak <- c(3, 5) # Skewness parameters of the experts nuk <- c(5, 7) # Degrees of freedom of the experts network t densities x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivStMoE(alphak = alphak, betak = betak, sigmak = sigmak, lambdak = lambdak, nuk = nuk, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts sigmak <- c(0.5, 0.5) # Standard deviations of the experts lambdak <- c(3, 5) # Skewness parameters of the experts nuk <- c(5, 7) # Degrees of freedom of the experts network t densities x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivStMoE(alphak = alphak, betak = betak, sigmak = sigmak, lambdak = lambdak, nuk = nuk, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
Draw a sample from a univariate t mixture of experts (TMoE).
sampleUnivTMoE(alphak, betak, sigmak, nuk, x)
sampleUnivTMoE(alphak, betak, sigmak, nuk, x)
alphak |
The parameters of the gating network. |
betak |
Matrix of size (p + 1, K) representing the regression coefficients of the experts network. |
sigmak |
Vector of length K giving the standard deviations of the experts network. |
nuk |
Vector of length K giving the degrees of freedom of the experts network t densities. |
x |
A vector of length n representing the inputs (predictors). |
A list with the output variable y
and statistics.
y
Vector of length n giving the output variable.
zi
A vector of size n giving the hidden label of the
expert component generating the i-th observation. Its elements are
, if the i-th observation has been generated by the
k-th expert.
z
A matrix of size (n, K) giving the values of the binary
latent component indicators such that
iff
.
stats
A list whose elements are:
Ey_k
Matrix of size (n, K) giving the conditional
expectation of Yi the output variable given the value of the
hidden label of the expert component generating the ith observation
zi = k, and the value of predictor X = xi.
Ey
Vector of length n giving the conditional expectation
of Yi given the value of predictor X = xi.
Vary_k
Vector of length k representing the conditional
variance of Yi given zi = k, and X = xi.
Vary
Vector of length n giving the conditional expectation
of Yi given X = xi.
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts sigmak <- c(0.5, 0.5) # Standard deviations of the experts nuk <- c(5, 7) # Degrees of freedom of the experts network t densities x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivTMoE(alphak = alphak, betak = betak, sigmak = sigmak, nuk = nuk, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
n <- 500 # Size of the sample alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts sigmak <- c(0.5, 0.5) # Standard deviations of the experts nuk <- c(5, 7) # Degrees of freedom of the experts network t densities x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors) # Generate sample of size n sample <- sampleUnivTMoE(alphak = alphak, betak = betak, sigmak = sigmak, nuk = nuk, x = x) # Plot points and estimated means plot(x, sample$y, pch = 4) lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5) lines(x, sample$stats$Ey, col = "red", lwd = 1.5)
StatNMoE contains all the statistics associated to a NMoE model. It mainly includes the E-Step of the EM algorithm calculating the posterior distribution of the hidden variables, as well as the calculation of the log-likelhood.
piik
Matrix of size representing the probabilities
of
the latent variable
.
z_ik
Hard segmentation logical matrix of dimension
obtained by the Maximum a posteriori (MAP) rule:
,
.
klas
Column matrix of the labels issued from z_ik
. Its elements are
,
.
tik
Matrix of size giving the posterior probability
that the observation
originates
from the
-th expert.
Ey_k
Matrix of dimension (n, K) giving the estimated means of the experts.
Ey
Column matrix of dimension n giving the estimated mean of the NMoE.
Var_yk
Column matrix of dimension K giving the estimated means of the experts.
Vary
Column matrix of dimension n giving the estimated variance of the response.
loglik
Numeric. Observed-data log-likelihood of the NMoE model.
com_loglik
Numeric. Complete-data log-likelihood of the NMoE model.
stored_loglik
Numeric vector. Stored values of the log-likelihood at each EM iteration.
BIC
Numeric. Value of BIC (Bayesian Information Criterion).
ICL
Numeric. Value of ICL (Integrated Completed Likelihood).
AIC
Numeric. Value of AIC (Akaike Information Criterion).
log_piik_fik
Matrix of size giving the values of the
logarithm of the joint probability
,
.
log_sum_piik_fik
Column matrix of size m giving the values of
,
.
computeLikelihood(reg_irls)
Method to compute the log-likelihood. reg_irls
is the value of
the regularization part in the IRLS algorithm.
computeStats(paramNMoE)
Method used in the EM algorithm to compute statistics based on
parameters provided by the object paramNMoE
of class
ParamNMoE.
EStep(paramNMoE)
Method used in the EM algorithm to update statistics based on parameters
provided by the object paramNMoE
of class ParamNMoE
(prior and posterior probabilities).
MAP()
MAP calculates values of the fields z_ik
and klas
by applying the Maximum A Posteriori Bayes allocation rule.
StatSNMoE contains all the statistics associated to a SNMoE model. It mainly includes the E-Step of the ECM algorithm calculating the posterior distribution of the hidden variables, as well as the calculation of the log-likelhood.
piik
Matrix of size representing the probabilities
of
the latent variable
.
z_ik
Hard segmentation logical matrix of dimension
obtained by the Maximum a posteriori (MAP) rule:
,
.
klas
Column matrix of the labels issued from z_ik
. Its elements are
,
.
tik
Matrix of size giving the posterior probability
that the observation
originates
from the
-th expert.
Ey_k
Matrix of dimension (n, K) giving the estimated means of the experts.
Ey
Column matrix of dimension n giving the estimated mean of the SNMoE.
Var_yk
Column matrix of dimension K giving the estimated means of the experts.
Vary
Column matrix of dimension n giving the estimated variance of the response.
loglik
Numeric. Observed-data log-likelihood of the SNMoE model.
com_loglik
Numeric. Complete-data log-likelihood of the SNMoE model.
stored_loglik
Numeric vector. Stored values of the log-likelihood at each ECM iteration.
BIC
Numeric. Value of BIC (Bayesian Information Criterion).
ICL
Numeric. Value of ICL (Integrated Completed Likelihood).
AIC
Numeric. Value of AIC (Akaike Information Criterion).
log_piik_fik
Matrix of size giving the values of the
logarithm of the joint probability
,
.
log_sum_piik_fik
Column matrix of size m giving the values of
,
.
E1ik
Conditional expectations of (Matrix of size
).
E2ik
Conditional expectations of (Matrix of size
).
computeLikelihood(reg_irls)
Method to compute the log-likelihood. reg_irls
is the value of
the regularization part in the IRLS algorithm.
computeStats(paramSNMoE)
Method used in the ECM algorithm to compute statistics based on
parameters provided by the object paramSNMoE
of class
ParamSNMoE.
EStep(paramSNMoE)
Method used in the ECM algorithm to update statistics based on parameters
provided by the object paramSNMoE
of class ParamSNMoE
(prior and posterior probabilities).
MAP()
MAP calculates values of the fields z_ik
and klas
by applying the Maximum A Posteriori Bayes allocation rule.
StatStMoE contains all the statistics associated to a StMoE model. It mainly includes the E-Step of the ECM algorithm calculating the posterior distribution of the hidden variables, as well as the calculation of the log-likelhood.
piik
Matrix of size representing the probabilities
of the latent
variable
.
z_ik
Hard segmentation logical matrix of dimension
obtained by the Maximum a posteriori (MAP) rule:
,
.
klas
Column matrix of the labels issued from z_ik
. Its elements are
,
.
tik
Matrix of size giving the posterior probability
that the observation
originates
from the
-th expert.
Ey_k
Matrix of dimension (n, K) giving the estimated means of the experts.
Ey
Column matrix of dimension n giving the estimated mean of the StMoE.
Var_yk
Column matrix of dimension K giving the estimated means of the experts.
Vary
Column matrix of dimension n giving the estimated variance of the response.
loglik
Numeric. Observed-data log-likelihood of the StMoE model.
com_loglik
Numeric. Complete-data log-likelihood of the StMoE model.
stored_loglik
Numeric vector. Stored values of the log-likelihood at each ECM iteration.
BIC
Numeric. Value of BIC (Bayesian Information Criterion).
ICL
Numeric. Value of ICL (Integrated Completed Likelihood).
AIC
Numeric. Value of AIC (Akaike Information Criterion).
log_piik_fik
Matrix of size giving the values of the
logarithm of the joint probability
,
.
log_sum_piik_fik
Column matrix of size m giving the values of
,
.
dik
It represents the value of .
wik
Conditional expectations .
E1ik
Conditional expectations .
E2ik
Conditional expectations .
E3ik
Conditional expectations .
stme_pdf
Skew-t mixture of experts density.
computeLikelihood(reg_irls)
Method to compute the log-likelihood. reg_irls
is the value of
the regularization part in the IRLS algorithm.
computeStats(paramStMoE)
Method used in the ECM algorithm to compute statistics based on
parameters provided by the object paramStMoE
of class
ParamStMoE.
EStep(paramStMoE, calcTau = FALSE, calcE1 = FALSE, calcE2 = FALSE,
calcE3 = FALSE)
Method used in the ECM algorithm to update statistics based on parameters
provided by the object paramStMoE
of class ParamStMoE
(prior and posterior probabilities).
MAP()
MAP calculates values of the fields z_ik
and klas
by applying the Maximum A Posteriori Bayes allocation rule.
StatTMoE contains all the statistics associated to a TMoE model. It mainly includes the E-Step of the ECM algorithm calculating the posterior distribution of the hidden variables, as well as the calculation of the log-likelhood.
piik
Matrix of size representing the probabilities
of
the latent variable
.
z_ik
Hard segmentation logical matrix of dimension
obtained by the Maximum a posteriori (MAP) rule:
,
.
klas
Column matrix of the labels issued from z_ik
. Its elements are
,
.
tik
Matrix of size giving the posterior probability
that the observation
originates
from the
-th expert.
Ey_k
Matrix of dimension (n, K) giving the estimated means of the experts.
Ey
Column matrix of dimension n giving the estimated mean of the TMoE.
Var_yk
Column matrix of dimension K giving the estimated means of the experts.
Vary
Column matrix of dimension n giving the estimated variance of the response.
loglik
Numeric. Observed-data log-likelihood of the TMoE model.
com_loglik
Numeric. Complete-data log-likelihood of the TMoE model.
stored_loglik
Numeric vector. Stored values of the log-likelihood at each ECM iteration.
BIC
Numeric. Value of BIC (Bayesian Information Criterion).
ICL
Numeric. Value of ICL (Integrated Completed Likelihood).
AIC
Numeric. Value of AIC (Akaike Information Criterion).
log_piik_fik
Matrix of size giving the values of the
logarithm of the joint probability
,
.
log_sum_piik_fik
Column matrix of size m giving the values of
,
.
Wik
Conditional expectations .
computeLikelihood(reg_irls)
Method to compute the log-likelihood. reg_irls
is the value of
the regularization part in the IRLS algorithm.
computeStats(paramTMoE)
Method used in the ECM algorithm to compute statistics based on
parameters provided by the object paramTMoE
of class
ParamTMoE.
EStep(paramTMoE)
Method used in the ECM algorithm to update statistics based on parameters
provided by the object paramTMoE
of class ParamTMoE
(prior and posterior probabilities).
MAP()
MAP calculates values of the fields z_ik
and klas
by applying the Maximum A Posteriori Bayes allocation rule.
This dataset is from https://cdiac.ess-dive.lbl.gov/ftp/trends/temp/hansen/gl_land.txt.
tempanomalies
tempanomalies
A data frame with 136 rows and 3 columns:
Year of observation.
Value in degrees C of the global annual temperature anomaly.
5-Year mean of temperature anomalies.
Global annual temperature anomalies (degrees C) computed using data from land meteorological stations, 1880-2015. Anomalies are relative to the 1951-1980 base period means.
Non-computed values are indicated by "-99.99".