0

I was look for some nice features to apply with posterior probabilities. I want to make a distribution for each component, but I don't know how. As a start, how do I make a vector for each of the components in a list?

Below some information how the probabilities looks like:

>dput(head(out.3.1$posterior))
>structure(c(0.0563823895419722, 0.0257300157960745, 0.0000000000000000180397428035783, 
0.0253978781532002, 0.000000000000000007586528108014, 0.0000000000000000064152619636675, 
0.609445398048216, 0.417193791818801, 0.0731264720737992, 0.411808417688033, 
0.314143467477256, 0.405535515667362, 0.334172212409812, 0.557076192385124, 
0.926873527926201, 0.562793704158767, 0.685856532522744, 0.594464484332638
), .Dim = c(6L, 3L), .Dimnames = list(NULL, c("comp.1", "comp.2", 
"comp.3")))

Hope you can help me out!

  • 1
    Your question isn't clear. Are you asking how to extract the columns of a matrix as vectors? `out.3.1$posterior[,1]` (or `out.3.1$posterior[, "comp.1")]` ) would be the first column. If that is what you are asking, I recommend spending some time on a tutorial about how subscripting works in R. – John Coleman Dec 09 '19 at 16:25
  • Alternatively, if you are asking how to take that matrix of probabilities and turn it into a simple vector it would be `as.vector(out.3.1$posterior)` – John Coleman Dec 09 '19 at 16:33
  • If you already have a posterior, it means you have already 'made' the distribution (the parameters probably being the three components). If by making a distribution, you mean a function to which you pass arbitrary input and it returns a probability, it would need to take into account firstly your prior and secondly the parameters which result from the optimization of the likelihood (e.g. the coefficients for comp.1/2/3. P.S. A posterior probability function needs to sum to 1 and the missing part is usually a data-independent prior to normalize it. – koohyar Dec 09 '19 at 16:57
  • Then I already have the distribution. i'm now looking more for a way how to plot each of the components' distribution nicely. For now I only have an ugly plot full with scatters. @koohyar – daantheboss Dec 09 '19 at 17:25

0 Answers0