This function extracts the clustering assignments and the latent variables from the fit. This function must receive in input exactly the same data used for the fit.
Clusters(x, data)
x | An object of class |
---|---|
data | The data used to compute the fit |
The input data
transformed into a tibble, augmented with a column for the cluster labels and the latent variables.
# The same dataset used in the package vignette data = data.frame(successes = c(rbinom(30, 100, .4), rbinom(70, 100, .7)), trials = 100) # BMix fit with default parameters x = bmixfit(data)#>#>#>#> ℹ Binomials k_B = 1 and 2, Beta-Binomials k_BB = 0; 4 fits to run.#>#> ℹ Bmix best fit completed in 0 mins#>#> [ BMix ] My BMix model n = 100 with k = 2 component(s) (2 + 0) ──────────────#> Bin 2] and 30% [Bin 1], with π > 0.#> Bin 1 with mean = 0.398001536600375.#> Bin 2 with mean = 0.705854422544301.#> ℹ Score (model selection): ICL = 730.76.Clusters(x, data)#> # A tibble: 100 x 5 #> successes trials cluster `Bin 1` `Bin 2` #> <int> <dbl> <chr> <dbl> <dbl> #> 1 35 100 Bin 1 1.00 5.74e-12 #> 2 37 100 Bin 1 1.00 7.34e-11 #> 3 36 100 Bin 1 1.00 2.05e-11 #> 4 38 100 Bin 1 1.00 2.62e-10 #> 5 46 100 Bin 1 1.00 7.03e- 6 #> 6 47 100 Bin 1 1.00 2.51e- 5 #> 7 40 100 Bin 1 1.00 3.36e- 9 #> 8 40 100 Bin 1 1.00 3.36e- 9 #> 9 44 100 Bin 1 1.00 5.49e- 7 #> 10 37 100 Bin 1 1.00 7.34e-11 #> # … with 90 more rows