[R] Labeling/identifying observations in plot after MclustDR from Mclust

Mark Manger mark.manger at utoronto.ca
Thu Apr 17 05:01:41 CEST 2014


Hi,

I’m trying to figure out how to label points in a contour plot produced from the output of MclustDR, the dimension reduction function in the Mclust package.

The original data frame has row names

		RRcoarse govtDeficit    res_gdp GrossFixedCapForm_UN fuelExports
AUS_76    2.000  -4.5125520  1.5197260              26.5169  12.7851900
AUS_81    3.500  -3.6041720  3.7029600              27.1058  20.8597300
AUS_91    4.000  -1.2131010  3.8150380              24.1444  20.5832700
AUS_01    4.000   0.0279132  4.4617860              26.9491  25.5349700
AUT_76    2.000  -2.7850080  7.0378630              25.7365   1.6797000
AUT_81    1.000  -3.4403770  6.4757080              23.2928   1.4688700

I then use these variables to 

imbalances.selections.def = subset(imbalances.all, select=c(5:8,10:12), cu_gdp < 0)
clusters.defs = Mclust(imbalances.selections.def, G=1:10)


I use MclustDR to reduce the dimensions to plot the results, which works beautifully and produces a nice contour plot.

dr.defs = MclustDR(clusters.defs)
plot(dr.defs, what="contour”)

But the plot is not particularly informative unless I know which observation is which.

How can I label the points displayed in the plot to identify the observations? I can probably extract this from the dr.defs object whose str() is below, but I don’t know how to do that, or somehow from the original data frame row names. Help would be greatly appreciated. I know this is trivial in a regular plot(x,y) situation.

str(dr.defs)

List of 22
 $ call         : language MclustDR(object = clusters.defs)
 $ type         : chr "Mclust"
 $ x            : num [1:49, 1:7] 2 3.5 4 4 2 1 1 2 2 2 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:49] "AUS_76" "AUS_81" "AUS_91" "AUS_01" ...
  .. ..$ : chr [1:7] "RRcoarse" "govtDeficit" "res_gdp" "GrossFixedCapForm_UN" ...
 $ Sigma        : num [1:7, 1:7] 0.875 0.116 -0.781 -0.525 2.339 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:7] "RRcoarse" "govtDeficit" "res_gdp" "GrossFixedCapForm_UN" …
etc etc etc

Many thanks in advance,

Mark S. Manger 
Assistant Professor

Munk School of Global Affairs and Department of Political Science

University of Toronto
Observatory Site | 315 Bloor Street West | Room 212
Toronto, ON   M5S 0A7

mark.manger at utoronto.ca




More information about the R-help mailing list