EM Algorithm for Mixtures of Regressions with Local Lambda Estimates
regmixEM.lambda.RdReturns output for one step of an EM algorithm output for mixtures of multiple regressions where the mixing proportions are estimated locally.
Usage
regmixEM.lambda(y, x, lambda = NULL, beta = NULL, sigma = NULL,
k = 2, addintercept = TRUE, arbmean = TRUE,
arbvar = TRUE, epsilon = 1e-8, maxit = 10000,
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 value of
betaparameters. Should be a pxk matrix, where p is the number of columns of x and k is number of components. If NULL, thenbetahas uniform standard normal entries. If bothlambdaandbetaare NULL, then number of components is determined bysigma.- sigma
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 is determined byk.- k
The 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.
- arbmean
If TRUE, each mixture component is assumed to have a different set of regression coefficients (i.e., the
betas).- arbvar
If TRUE, each mixture component is assumed to have a different
sigma.- epsilon
The convergence criterion.
- maxit
The maximum number of iterations.
- verb
If TRUE, then various updates are printed during each iteration of the algorithm.
Value
regmixEM.lambda 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
The inputted mixing proportions.
- beta
The final regression coefficients.
- sigma
The final standard deviations. If
arbmean= FALSE, then only the smallest standard deviation is returned. Seescalebelow.- scale
If
arbmean= FALSE, then the scale factor for the component standard deviations is returned. Otherwise, this is omitted from the output.- 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 = 5):
#>
#> Equivalence, NO
#> The following objects are masked from NOdata (pos = 9):
#>
#> Equivalence, NO
#> The following objects are masked from NOdata (pos = 10):
#>
#> Equivalence, NO
set.seed(100)
out1 <- regmixEM.lambda(Equivalence, NO)
out2 <- regmixEM.lambda(Equivalence, NO, k = 3)
c(out1$loglik, out2$loglik)
#> [1] 120.6423 123.5396