FLXMRglmnet | R Documentation |
This is a driver which allows fitting of mixtures of GLMs where the coefficients are penalized using the (adaptive) lasso or the elastic net by reusing functionality from package glmnet.
FLXMRglmnet(formula = . ~ ., family = c("gaussian", "binomial", "poisson"),
adaptive = TRUE, select = TRUE, offset = NULL, ...)
formula |
A formula which is interpreted relative to the formula
specified in the call to |
family |
A character string naming a |
adaptive |
A logical indicating if the adaptive lasso should be
used. By default equal to |
select |
A logical vector indicating which variables in the
model matrix should be included in the penalized part. By default
equal to |
offset |
This can be used to specify an a priori known component to be included in the linear predictor during fitting. |
... |
Additional arguments to be passed to
|
Some care is needed to ensure convergence of the algorithm, which is
computationally more challenging than a standard EM. In the proposed
method, not only are cluster allocations identified and component
parameters estimated as commonly done in mixture models, but there is
also variable selection via penalized regression using $k$-fold
cross-validation to choose the penalty parameter. For the algorithm
to converge, it is necessary that the same cross-validation
partitioning be used across the EM iterations, i.e., the subsamples
for cross-validation must be defined at the beginning This is
accomplished using the foldid
option as an additional parameter
to be passed to cv.glmnet
(see
glmnet package documentation).
Returns an object of class FLXMRglm
.
Frederic Mortier and Nicolas Picard.
Frederic Mortier, Dakis-Yaoba Ouedraogo, Florian Claeys, Mahlet G. Tadesse, Guillaume Cornu, Fidele Baya, Fabrice Benedet, Vincent Freycon, Sylvie Gourlet-Fleury and Nicolas Picard. Mixture of inhomogeneous matrix models for species-rich ecosystems. Environmetrics, 26(1), 39-51, 2015. doi:10.1002/env.2320
FLXMRglm
set.seed(12)
p <- 10
beta <- matrix(0, nrow = p + 1, ncol = 2)
beta[1,] <- c(-1, 1)
beta[cbind(c(5, 10), c(1, 2))] <- 1
nobs <- 100
X <- matrix(rnorm(nobs * p), nobs, p)
mu <- cbind(1, X) %*% beta
z <- sample(1:ncol(beta), nobs, replace = TRUE)
y <- mu[cbind(1:nobs, z)] + rnorm(nobs)
data <- data.frame(y, X)
## The maximum number of iterations is reduced to
## avoid a long running time.
fo <- sample(rep(seq(10), length = nrow(data)))
ex1 <- flexmix(y ~ ., data = data, k = 2, cluster = z,
model = FLXMRglmnet(foldid = fo),
control = list(iter.max = 2))
parameters(ex1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.