Last data update: 2014.03.03

R: Plot Parameter Summaries, Density Estimates and Model...
plot.blcaR Documentation

Plot Parameter Summaries, Density Estimates and Model Diagnostics for Bayesian Latent Class Analysis

Description

Five plots are selectable: a plot summarising item and class probability, a mosaic plot representing classification uncertainty, item probability density estimates, conditional class probability density estimates, and a diagnostics plot. The default setting is for the first four plots to be displayed, with the exception of plot.blca.em, which cannot produce density plots and so only produces the first two plots by default.

Usage

## S3 method for class 'blca'
plot(x, which = 1L, main = "", col1 = heat.colors(12), ...)

Arguments

x

An object of class blca.

which

Which plots to select. May be any subset of 1:5, with some exceptions. See ‘Details’.

main

An overall title for the plot: see title.

col1

Specifies a list of colours to be used by the heat map plot used when which = 1.image. Uses heat.colors by default, but several other choices are available. See the help files of image.plot, image and palette for details.

...

Further arguments to be passed onto the plotting devices. When which = 1, the plotting device is image.plot, mosaicplot in the case of which=2, and when which=3:5, plot.

Details

Not all plots are available for some object classes. If the object is of class blca.em, density plots (which = 3:4) are unavailable, and a warning is returned. Similarly, diagnostic plots (which = 5) for blca.boot objects are unavailable.

The available diagnostic plots differ depending on the class of the object in question. For blca.em and blca.vb objects, the plot is intended as visual aid to check whether the respective algorithms have converged, i.e., that the log-posterior or lower bound have ceased increasing after successive iterations. The main aim of the diagnostic plot for blca.gibbs objects is to visually check diagnostic measures such as mixing and burn-in, and also to assess whether label-switching has occurred, or been corrected for satisfactorily.

Currently, the colors used in a plot can only be specified directly for which = 1. For classification uncertainty (which = 2) and density plots (which = 3:4), each group is colored by the palette function so that Group g takes color palette()[g+1]. For the default settings, Group 1 will then be colored red, Group 2 green, and so on.

Author(s)

Arthur White

References

Arthur White, Thomas Brendan Murphy (2014). BayesLCA: An R Package for Bayesian Latent Class Analysis." Journal of Statistical Software, 61(13), 1-28. URL: http://www.jstatsoft.org/v61/i13/.

See Also

image.plot, mosaicplot.

Examples

type1 <- c(0.8, 0.8, 0.2, 0.2)
type2 <- c(0.2, 0.2, 0.8, 0.8)
x<- rlca(1000, rbind(type1,type2), c(0.6,0.4))

fit <- blca.em(x, 2)
plot(fit, which = 1:2) ## Parameter summary and classification uncertainty plots.

palette(rainbow(6)) ## Change color scheme
plot(fit, which = 2) 
palette("default") ## Restore default color scheme

fit2<- blca.vb(x,2)
par(mfrow = c(3,4))
plot(fit2, which = 3) ## Approximate density plots for item probability parameters.
par(mfrow = c(1,1))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BayesLCA)
Loading required package: e1071
Loading required package: coda
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BayesLCA/plot.blca.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot.blca
> ### Title: Plot Parameter Summaries, Density Estimates and Model
> ###   Diagnostics for Bayesian Latent Class Analysis
> ### Aliases: plot.blca plot.blca.boot plot.blca.em plot.blca.gibbs
> ###   plot.blca.vb
> ### Keywords: blca plot
> 
> ### ** Examples
> 
> type1 <- c(0.8, 0.8, 0.2, 0.2)
> type2 <- c(0.2, 0.2, 0.8, 0.8)
> x<- rlca(1000, rbind(type1,type2), c(0.6,0.4))
> 
> fit <- blca.em(x, 2)
Restart number 1, logpost = -2476.99... 
New maximum found... Restart number 2, logpost = -2476.99... 
New maximum found... Restart number 3, logpost = -2476.99... 
Restart number 4, logpost = -2476.99... 
Restart number 5, logpost = -2476.99... 
> plot(fit, which = 1:2) ## Parameter summary and classification uncertainty plots.
> 
> palette(rainbow(6)) ## Change color scheme
> plot(fit, which = 2) 
> palette("default") ## Restore default color scheme
> 
> fit2<- blca.vb(x,2)
Restart number 1, logpost = -6938.87... 
> par(mfrow = c(3,4))
> plot(fit2, which = 3) ## Approximate density plots for item probability parameters.
> par(mfrow = c(1,1))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>