FLXPwlda: Creator Functions for the Concomitant Variable Model based on...

Description Usage Arguments Value See Also Examples

Description

Creator function for the concomitant variable model. Priors are modeled by Linear or Quadratic Discriminant Analysis.

Usage

1
2
3

Arguments

formula

A formula for determining the model matrix of the concomitant variables.

Value

Object of class FLXPwlda or FLXPwqda which both extend class FLXP directly and are used for method dispatching.

See Also

FLXPmultinom.

Other mixtures: FLXMCL-class, FLXPwlda-class, myStepFlexmix, myfitted, mypredict

Other mixtures svm: FLXMCL-class, FLXMCLsvm

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

cluster <- kmeans(data$x, center = 2)$cluster
model <- FLXMCLmultinom(trace = FALSE)
fit <- flexmix(y ~ x.1 + x.2, data = as.data.frame(data), concomitant = FLXPwlda(~ x.1 + x.2), model = model, cluster = cluster, control = list(verb = 1))

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

image(x1, x2, matrix(pred.grid[[2]][,1], length(x1)))
contour(x1, x2, matrix(pred.grid[[2]][,1], length(x1)), 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(x1, x2, matrix(pred.grid[[1]][,1], length(x1)))
contour(x1, x2, matrix(pred.grid[[1]][,1], length(x1)), add  = TRUE)
points(data$x, pch = as.character(data$y))

## local membership
loc.grid <- prior(fit, newdata = grid)
contour(x1, x2, matrix(loc.grid[,1], length(x1)), add  = TRUE)

schiffner/locClass documentation built on May 29, 2019, 3:39 p.m.