ComeçarComece de graça

Get the components

The fitted model from last exercise is in the object fit_with_covariance. The aim here is to extract the means and the covariance matrices for both clusters.

Este exercício faz parte do curso

Mixture Models in R

Ver curso

Instruções do exercício

  • Use the function parameters() with the corresponding component number to extract the means and the covariance matrices for each cluster. Save the results into the objects comp_number.
  • The first two values of comp_number correspond to the mean. Save them into the objects mean_comp_number.
  • The last four values of comp_number correspond to the covariance matrix. Save these values into a 2x2 matrices.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Get the parameters
comp_1 <- ___(___, component = 1)
comp_2 <- parameters(fit_with_covariance, component = ___)

# The means
mean_comp_1 <- ___[1:2]
mean_comp_1
mean_comp_2 <- comp_2[___]
mean_comp_2

# The covariance matrices
covariance_comp_1 <- matrix(comp_1[___], nrow = 2)
covariance_comp_1
covariance_comp_2 <- matrix(comp_2[___], nrow = ___)
covariance_comp_2
Editar e executar o código