Description Details Author(s) See Also Examples
Extension of package flexmix for fitting mixtures of
Generalized Nonlinear Models.
The package flexmixNL implements an extension for the package
flexmix for fitting mixtures of Generalized Nonlinear Models
(GNMs). The package provides a specified M-step for the EM-algorithm within the
FlexMix framework (see also flexmix) for fitting
GNMs for the normal and gamma distribution.
The mixture model is specified by the function FLXMRnlm.
Sanela Omerovic
See also flexmix for finite mixtures of regression models and
gnm for the fitting of Generalized Nonlinear Models (GNMs) for
further information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # example 1.
data("NReg", package = "flexmixNL")
# mixture of two nonlinear regression models (normal distribution).
start1 <- list(a = 170, b = 5)
start2 <- list(a = 130, b = 5)
model <- flexmix(yn ~ x, k = 2, data = NReg,
model = list(FLXMRnlm(formula = yn ~ a*x / (b+x),
family = "gaussian",
start = list(start1, start2))))
# final cluster assignments.
plot(yn ~ x, col = clusters(model), data = NReg)
# example 2.
data("GReg", package = "flexmixNL")
# mixture of two nonlinear regression models (gamma distribution).
exp.1 = function(x,predictors){
list(predictors = list(a = 1, b = 1),
variables = list(substitute(x)),
term = function(predictors, variables){
sprintf("exp( %s + %s * %s)",
predictors[1], predictors[2], variables)
})
}
class(exp.1) = "nonlin"
start1 <- list(a = -0.4, b = 0.3)
start2 <- list(a = -0.1, b = 0.4)
model2 <- flexmix(yg ~ x, k = 2, data = GReg,
model = list(FLXMRnlm(formula = yg ~ -1 + exp.1(x),
family = "Gamma",
start = list(start1, start2))))
# final cluster assignments.
plot(yg ~ x, col = clusters(model2), data = GReg)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.