Description Usage Arguments Details See Also Examples
Create 2D or 3D contour plot.
1 2 3 4 5 6 |
fmmst.contour.2d(dat, model, grid = 50, drawpoints = TRUE, clusters=NULL, levels = 10,
map = c("scatter", "heat", "cluster"), component = NULL,
xlim, ylim, xlab, ylab, main, tmethod=1, ...)
fmmst.contour.3d(dat, model, grid=20, drawpoints=TRUE, levels=0.9,
clusters=NULL, xlim, ylim, zlim, xlab, ylab, zlab, main, component=NULL, ...)
|
dat |
the data matrix giving the coordinates of the point(s) where the density is evaluated.
This must be a matrix with at least |
model |
a list containing the parameters of the model and also a vector of cluster labels for |
grid |
a positive integer specifying the grid size used to calculate the density map. |
drawpoints |
logical. Points are plotted if |
clusters |
a vector of cluster labels to be applied when colouring the points.
This only applies when |
levels |
either a positive integer specifying the number of contour levels to draw or a numeric vector of contour levels to be drawn |
map |
character string specifying how to plot the points if |
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 |
tmethod |
(optional) an integer indicating which method to use when computing t distribution function values.
See |
... |
additional arguments to |
fmmst.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.
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 34 35 | #2D plots
obj <- list()
obj$mu <- list(c(17,19), c(5,22), c(6,10))
obj$sigma <- list(diag(2), matrix(c(2,0,0,1),2), matrix(c(3,7,7,24),2))
obj$delta <- list(c(3,1.5), c(5,10), c(2,0))
obj$dof <- c(1, 2, 3)
obj$pro <- c(0.25, 0.25, 0.5)
mySample <- rfmmst(3, 500,known=obj)
obj$clusters <- mySample[,3]
par(mfrow=c(2,2))
fmmst.contour.2d(mySample, model=obj, clusters=obj$clusters)
fmmst.contour.2d(mySample[,1:2], model=obj, clusters=obj$clusters, map="heat")
fmmst.contour.2d(mySample[,1:2], model=obj, clusters=obj$clusters, map="cluster")
fmmst.contour.2d(mySample[,1:2], model=obj, clusters=obj$clusters, component=1)
#3D plot
## Not run:
obj <- list()
obj$mu <- list(c(420,360,425), c(160,570,200), c(320,540,260), c(530,80,450))
obj$sigma <-
list(matrix(c(9160,5580,7000,5580,12105,7160,7000,7160,7250),3,3),
matrix(c(3870,1810,1770,1810,2900,1270,1770,1270,1320),3,3),
matrix(c(1695,1190,2280,1190,2780,2010,2280,2010,3720),3,3),
matrix(c(1590,590,15,590,2425,415,15,415,1870),3,3))
obj$delta <- list(c(4.8,-17,-50), c(-4,-80,-60), c(-40,8,-10), c(-60,90,-6))
obj$dof <- c(10,30,40,40)
obj$pro <- c(0.125, 0.19, 0.135, 0.55)
mySample <- rfmmst(4, 10000, known=obj)
obj$clusters <- mySample[,4]
fmmst.contour.3d(mySample[,1:3], model=obj, levels=0.95,
drawpoints=F, clusters=obj$clusters, component=1:4)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.