FLXMCLqda: Mixtures of Quadratic Discriminant Analysis Models

Description Usage Arguments Value Examples

View source: R/FLXMCLqda.R

Description

This is a model driver for flexmix from package flexmix implementing mixtures of Quadratic Discriminant Analysis Models.

Usage

1
2
  FLXMCLqda(formula = . ~ ., method = c("unbiased", "ML"),
    ...)

Arguments

formula

A formula which is interpreted relative to the formula specified in the call to flexmix using update.formula. Only the left-hand side (response) of the formula is used. Default is to use the original flexmix model formula.

method

Method for scaling the pooled weighted covariance matrix, either "unbiased" or maximum-likelihood ("ML"). Defaults to "unbiased".

...

Further arguments to and from other methods.

Value

Returns an object of class FLXMCLqda inheriting from FLXMCL.

Examples

 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
library(locClassData)
data <- flashData(1000)
grid <- expand.grid(x.1=seq(-6,6,0.2), x.2=seq(-4,4,0.2))

cluster <- kmeans(data$x, center = 2)$cluster
model <- FLXMCLqda()
fit <- flexmix(y ~ ., data = as.data.frame(data), concomitant = FLXPwlda(~ x.1 + x.2), model = model, cluster = cluster)

## prediction for single component models without aggregation
pred.grid <- predict(fit, newdata = grid)
image(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[1]][,1], length(seq(-6,6,0.2))))
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[1]][,1], length(seq(-6,6,0.2))), add = TRUE)
points(data$x, pch = as.character(data$y))

image(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[2]][,1], length(seq(-6,6,0.2))))
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[2]][,1], length(seq(-6,6,0.2))), add = TRUE)
points(data$x, pch = as.character(data$y))

## prediction with aggregation depending on membership in mixture components
pred.grid <- mypredict(fit, newdata = grid, aggregate = TRUE)
image(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[1]][,1], length(seq(-6,6,0.2))))
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[1]][,1], length(seq(-6,6,0.2))), add  = TRUE)
points(data$x, pch = as.character(data$y))

## local memberhsip
loc.grid <- prior(fit, newdata = grid)
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(loc.grid[,1], length(seq(-6,6,0.2))), add  = TRUE)

locClass documentation built on May 2, 2019, 5:21 p.m.

Related to FLXMCLqda in locClass...