建立橢圓
橢圓所包圍的區域代表叢集觀測值的 95%,因此這條曲線有助於視覺化叢集的位置。由於我們已經擷取了平均數(mean_comp_number)與共變異數矩陣(covariance_comp_number),就能輕鬆為這兩個叢集建立橢圓。
不過要注意,這些橢圓不會考慮各叢集的比例,只會顯示叢集位在哪裡,而不代表其重要性。
本練習屬於課程
R 中的混合模型
練習說明
- 使用
ellipse()函式來建立這些曲線。此函式以共變異數矩陣作為x參數,並以平均數作為centre參數。 - 使用
gender資料集的列數作為npoints。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create ellipse curve 1
ellipse_comp_1 <- ___(x = ___,
centre = ___,
npoints = nrow(___))
head(ellipse_comp_1)
# Create ellipse curve 2
ellipse_comp_2 <- ___(x = ___,
centre = ___,
npoints = ___(gender))
head(ellipse_comp_2)