Iterative Algorithm Using EM Algorithm for Mixtures of Regressions with Local Lambda Estimates
regmixEM.loc.RdIterative algorithm returning EM algorithm output for mixtures of multiple regressions where the mixing proportions are estimated locally.
Usage
regmixEM.loc(y, x, lambda = NULL, beta = NULL, sigma = NULL,
k = 2, addintercept = TRUE, kern.l = c("Gaussian",
"Beta", "Triangle", "Cosinus", "Optcosinus"),
epsilon = 1e-08, maxit = 10000, kernl.g = 0,
kernl.h = 1, verb = FALSE)Arguments
- y
An n-vector of response values.
- x
An nxp matrix of predictors. See
addinterceptbelow.- lambda
An nxk matrix of initial local values of mixing proportions. Entries should sum to 1. This determines number of components. If NULL, then
lambdais simply one over the number of components.- beta
Initial global values of
betaparameters. Should be a pxk matrix, where p is the number of columns of x andkis number of components. If NULL, thenbetahas uniform standard normal entries. If bothlambdaandbetaare NULL, then number of components is determined bysigma.- sigma
A k-vector of initial global values of standard deviations. If NULL, then \(1/\code{sigma}^2\) has random standard exponential entries. If
lambda,beta, andsigmaare NULL, then number of components determined byk.- k
Number of components. Ignored unless all of
lambda,beta, andsigmaare NULL.- addintercept
If TRUE, a column of ones is appended to the x matrix before the value of p is calculated.
- kern.l
The type of kernel to use in the local estimation of
lambda.- epsilon
The convergence criterion.
- maxit
The maximum number of iterations.
- kernl.g
A shape parameter required for the symmetric beta kernel for local estimation of
lambda. The default is g = 0 which yields the uniform kernel. Some common values are g = 1 for the Epanechnikov kernel, g = 2 for the biweight kernel, and g = 3 for the triweight kernel.- kernl.h
The bandwidth controlling the size of the window used in the local estimation of lambda around x.
- verb
If TRUE, then various updates are printed during each iteration of the algorithm.
Value
regmixEM.loc returns a list of class mixEM with items:
- x
The set of predictors (which includes a column of 1's if
addintercept= TRUE).- y
The response values.
- lambda.x
The final local mixing proportions.
- beta
The final global regression coefficients.
- sigma
The final global standard deviations.
- loglik
The final log-likelihood.
- posterior
An nxk matrix of posterior probabilities for observations.
- all.loglik
A vector of each iteration's log-likelihood.
- restarts
The number of times the algorithm restarted due to unacceptable choice of initial values.
- ft
A character vector giving the name of the function.
Examples
## Compare a 2-component and 3-component fit to NOdata.
data(NOdata)
attach(NOdata)
#> The following objects are masked from NOdata (pos = 3):
#>
#> Equivalence, NO
#> The following objects are masked from NOdata (pos = 4):
#>
#> Equivalence, NO
#> The following objects are masked from NOdata (pos = 6):
#>
#> Equivalence, NO
#> The following objects are masked from NOdata (pos = 10):
#>
#> Equivalence, NO
#> The following objects are masked from NOdata (pos = 11):
#>
#> Equivalence, NO
set.seed(100)
out1 <- regmixEM.loc(Equivalence, NO, kernl.h = 2,
epsilon = 1e-02, verb = TRUE)
#> iteration= 1 diff= 2.388208 log-likelihood 123.0305
#> iteration= 2 diff= 0.2572424 log-likelihood 123.2877
#> iteration= 3 diff= 0.1430545 log-likelihood 123.4308
#> iteration= 4 diff= 0.08725284 log-likelihood 123.518
#> iteration= 5 diff= 0.05197595 log-likelihood 123.57
#> iteration= 6 diff= 0.02960221 log-likelihood 123.5996
#> iteration= 7 diff= 0.0163375 log-likelihood 123.616
#> iteration= 8 diff= 0.008939667 log-likelihood 123.6249
#> number of overall iterations= 8
out2 <- regmixEM.loc(Equivalence, NO, kernl.h = 2, k = 3,
epsilon = 1e-02, verb = TRUE)
#> iteration= 1 diff= 5.411406 log-likelihood 128.951
#> iteration= 2 diff= 2.953583 log-likelihood 131.9046
#> iteration= 3 diff= 2.455963 log-likelihood 134.3605
#> iteration= 4 diff= 1.379161 log-likelihood 135.7397
#> iteration= 5 diff= 0.5530315 log-likelihood 136.2927
#> iteration= 6 diff= 0.2597361 log-likelihood 136.5525
#> iteration= 7 diff= 0.1058256 log-likelihood 136.6583
#> iteration= 8 diff= 0.02072824 log-likelihood 136.679
#> iteration= 9 diff= 0.00573047 log-likelihood 136.6848
#> number of overall iterations= 9
c(out1$loglik, out2$loglik)
#> [1] 123.6249 136.6848