fmcfust.contour.2d: 2D and 3D Visualisation of Fitted Contours

Description Usage Arguments Details See Also Examples

View source: R/contour.R

Description

Create 2D or 3D contour plot.

Usage

1
2
3
4
5
6
7
   
fmcfust.contour.2d(dat, model, grid=50, drawpoints=TRUE, clusters=NULL,
    nlevels=10, map=c("scatter", "heat", "cluster"), 
    component=NULL, xlim, ylim, xlab, ylab, main, pcol=NULL, ccol=NULL, ...)     
fmcfust.contour.3d(dat, model, grid=20, drawpoints=TRUE, levels=0.9, 
    clusters=NULL, xlim, ylim, zlim, xlab, ylab, zlab, main, component=NULL, 
    pcol=NULL, ccol=NULL, ...)

Arguments

dat

the data matrix giving the coordinates of the point(s) where the density is evaluated. This must be a matrix with at least 2 columns for fmcfust.contour.2d or 3 columns for fmcfust.contour.3d. If dat is not provided, then xlim, ylim and zlim must be provided, and drawpoints must be set to FALSE.

model

a list containing the parameters of the model and also a vector of cluster labels for dat. This is typically an output from fmcfust, containing mu, sigma, delta, dof, pro and clusters; see fmcfust for structure of model.

grid

a positive integer specifying the grid size used to calculate the density map.

drawpoints

logical. Points are plotted if TRUE.

clusters

a vector of cluster labels to be applied when colouring the points. This only applies when drawpoints is TRUE.

nlevels

a positive integer specifying the number of contour levels

levels

either a positive integer or a numeric vector specifying the contour levels to be drawn for each component

map

character string specifying how to plot the points if drawpoints=TRUE. Possible values are "scatter" (default), "heat" and "cluster". See the 'Details' section.

component

the index of the components to be plotted. See the 'Details' section.

xlim, ylim, zlim

x-, y- and z- limits for the plot

xlab, ylab, zlab

labels for x-, y- and z- axis

main

title of the plot

pcol

the color(s) to be used for plotted points

ccol

the color(s) to be used for plotted contours

...

additional arguments to plot.default

Details

fmcfust.contour.2d draw contour plots for bivariate densities. The argument dat must be provided and must contain at least 2 columns. Note that only the first two columns of dat will be used if dat have more than 2 columns. For bivariate datset, the data points can be drawn as a scatter plot by specifying map="scatter" (default), or as an intensity plot (map="heat"). Alternatively, a cluster map can be drawn instead (map="cluster"). Note that if an intensity plot is used, the data points will not be drawn, that is, drawpoints will be set to FALSE.

The argument component specifies which individual component is drawn. When component=FALSE, the mixture contour is drawn. If specified, component is a integer vector of the index of the components to be drawn. It can only take values between 1 an g inclusive. For example, component=c(1,3) will draw the first and third component contours.

If the argument model contains the cluster labels (model$clusters), the data point will be coloured according to their cluster.

See Also

fmcfust, contour

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
          

#2D plots
data(iris)
iris.versicolor <- iris[iris$Species=="versicolor",2:3]
Fit.versicolor <- fmcfust(1, iris.versicolor)
fmcfust.contour.2d(iris.versicolor, Fit.versicolor, drawpoints=FALSE, main="versicolor")

#3D plot
obj <- list()
obj$mu <- list(matrix(c(0,0,0),3), matrix(c(5,5,5),3))
obj$sigma <- list(matrix(c(5,2,1,2,5,1,1,1,1),3,3), 2*diag(3))
obj$delta <- list(matrix(c(1,0,0,1,0,0,1,0,0),3,3), matrix(c(5,0,0,0,10,0,0,0,15),3,3))
obj$dof <- c(3,3)
obj$pro <- c(0.2, 0.8)
fmcfust.contour.3d(model=obj, level=0.98, drawpoints=FALSE, xlab="X", ylab="Y", zlab="Z", 
    xlim = c(-20, 50), ylim = c(-20, 50), zlim = c(-20, 80), ccol = "green")

EMMIXcskew documentation built on May 2, 2019, 6:59 a.m.