emRHLP: emRHLP implements the EM algorithm to fit a RHLP model.

Description Usage Arguments Details Value See Also Examples

View source: R/emRHLP.R

Description

emRHLP implements the maximum-likelihood parameter estimation of the RHLP model by the Expectation-Maximization (EM) algorithm.

Usage

1
2
3
emRHLP(X, Y, K, p = 3, q = 1, variance_type = c("heteroskedastic",
  "homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
  verbose = FALSE, verbose_IRLS = FALSE)

Arguments

X

Numeric vector of length m representing the covariates/inputs x_{1},…,x_{m}.

Y

Numeric vector of length m representing the observed response/output y_{1},…,y_{m}.

K

The number of regimes (RHLP components).

p

Optional. The order of the polynomial regression. By default, p is set at 3.

q

Optional. The dimension of the logistic regression. For the purpose of segmentation, it must be set to 1 (which is the default value).

variance_type

Optional character indicating if the model is "homoskedastic" or "heteroskedastic". By default the model is "heteroskedastic".

n_tries

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

If n_tries > 1, then for the first run, parameters are initialized by uniformly segmenting the data into K segments, and for the next runs, parameters are initialized by randomly segmenting the data into K contiguous segments.

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.

Details

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

Value

EM returns an object of class ModelRHLP.

See Also

ModelRHLP, ParamRHLP, StatRHLP

Examples

1
2
3
4
5
6
7
data(univtoydataset)

rhlp <- emRHLP(univtoydataset$x, univtoydataset$y, K = 3, p = 1, verbose = TRUE)

rhlp$summary()

rhlp$plot()

samurais documentation built on July 28, 2019, 5:02 p.m.