# How to generate 3D clusters that are really only 2D?

How to construct a data set in three dimensional space, containing five classes (small overlapping is allowed but not advisable) clusters such that only two dimensions possess significant discriminatory power?

• Questions solely about how software works are off-topic here, but you may have a real statistical question buried here. You may want to edit your question to clarify the underlying statistical issue. You may find that when you understand the statistical concepts involved, the software-specific elements are self-evident or at least easy to get from the documentation. – gung - Reinstate Monica Nov 28 '17 at 20:01

Does this count as a solution? I define the clusters by defining their centers in two dimensions and randomly make points around them. The third dimension consists of random numbers and therefore should not add anything to the cluster structure.

#centers of 5 clusters

center.x <- c(10, 20, 30, 40, 50)
center.y <- c(10, 20, 30, 40, 50)

x <- c(replicate(50, jitter(center.x[1])),
replicate(50, jitter(center.x[2])),
replicate(50, jitter(center.x[3])),
replicate(50, jitter(center.x[4])),
replicate(50, jitter(center.x[5])))

y <- c(replicate(50, jitter(center.y[1])),
replicate(50, jitter(center.y[2])),
replicate(50, jitter(center.y[3])),
replicate(50, jitter(center.y[4])),
replicate(50, jitter(center.y[5])))

z <- runif(5*50)

collected <- data.frame(x=x, y=y, z=z)

# 2D plot x and y
plot(x,y)

# cluster structure in all 3 dimensions
plot(hclust(dist(collected)))

# cluster structure in x and y dimension
plot(hclust(dist(collected[,c("x", "y")])))


You could make the 5 cluster structure even more pronounced by choosing centers that are not in a row but on a circle of the x-y-plane.

• Although implementation is often mixed w/ substantive content in questions, we are supposed to be a site for providing information about statistics, machine learning, etc, not code. It can be good to provide code as well, but please elaborate your substantive answer in text for people who don't read this language well enough to recognize & extract the answer from the code. – gung - Reinstate Monica Nov 28 '17 at 20:00
• I was just about to add some more text, when I saw your comment. Added a short explanation. – Bernhard Nov 28 '17 at 20:04
• @Bernhard Yes it did work out now I am trying to compute the Kmeans so that these cluster look even nicer. After that I want to compute Fisher Score Could you help me how I can compute the Fisher Score on clusters? – nishant Nov 29 '17 at 11:37