You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -373,9 +373,9 @@ which produces an object `learnt10` (just a string, in this case) which can be u
373
373
374
374
## Examples of analysis
375
375
376
-
### Estimating the relative frequencies of the three species
376
+
### Estimating the relative frequencies of the three penguin species
377
377
378
-
Consider our first research question **Q1**: what's the overall statistical occurrence of the three species in the whole population? The relative frequencies of the three species in the whole population are unknown to us, so we cannot give a simple answer such as "Adélie: 0.10, Chinstrap: 0.34, Gentoo: 0.56".
378
+
Consider our first research question **Q1**: "what's the overall statistical occurrence of the three species in the whole population?" The relative frequencies of the three species in the whole population are unknown to us, so we cannot give a simple answer such as "Adélie: 0.10, Chinstrap: 0.34, Gentoo: 0.56".
379
379
380
380
Bayesian nonparametrics and ***inferno*** give a first answer to this question in the form of:
381
381
@@ -413,7 +413,10 @@ The answer to our question is now contained in the `Fspecies10` object (we chose
413
413
plot(Fspecies10)
414
414
```
415
415
416
-
<imgsrc="figure/vis10-1.png"width="100%" />
416
+
<divclass="figure">
417
+
<imgsrc="figure/vis10-1.png"alt="**Estimates and uncertainty of relative frequencies of the three penguin species**"width="100%" />
418
+
<pclass="caption">**Estimates and uncertainty of relative frequencies of the three penguin species**</p>
419
+
</div>
417
420
418
421
The x-axis of this plot shows the three possible values of the `species` variate. The y-axis reports fractions which may be read as *frequencies* or *probabilities*.
419
422
@@ -424,135 +427,95 @@ The three estimated frequencies are Adélie: 0.32, Chinstrap: 0.31, Gentoo: 0
424
427
425
428
```r
426
429
Fspecies10$values
427
-
## X
428
-
## Y [,1]
429
-
## [1,] 0.315265
430
-
## [2,] 0.310161
431
-
## [3,] 0.374574
430
+
## X
431
+
## Y [,1]
432
+
## Adelie 0.315265
433
+
## Chinstrap 0.310161
434
+
## Gentoo 0.374574
432
435
```
433
436
434
-
What about the uncertainty of these estimates? In Bayesian theory, a compact way of expressing the uncertainty in a quantity is by means of a **credibility interval** with a given probability. For instance, if we say that a particular quantity has a 80%-credibility interval equal to $(0.41, 0.69)$, what we mean is that there's an 80% probability that the true value of that quantity is between $0.41$ and $0.69$ -- pretty straightforward! (*Please be careful not to confuse the Bayesian credibility interval with a "confidence interval"*: the latter has a much more involved and less straightforward meaning.)
437
+
What about the uncertainty of these estimates?
435
438
436
-
The `Pr()` function by default calculates two credibility intervals for each frequency estimate: a 50% one, and an 89% one. In our present inference, the 50%-credibility intervals are shown in the plot above as the darker grey band, and the 89%-credibility interval as the lighter grey band. Note that this interval contains the 50% one.
439
+
### Uncertainty of the estimates: credibility intervals and probabilities
437
440
438
-
For instance, the plot indicates that there's a 50% probability that the relative frequency of all Adélie penguins is roughly between 0.25 and 0.4; and an 89% probability that their relative frequency is roughly between 0.3 and 0.45.
441
+
In Bayesian theory, a compact way of expressing the uncertainty in a quantity is by means of a **credibility interval** with a given probability. For instance, if we say that a particular quantity has a 80%-credibility interval equal to $(0.41, 0.69)$, what we mean is that there's an 80% probability that the true value of that quantity is between $0.41$ and $0.69$ -- pretty straightforward! (*Please be careful not to confuse the Bayesian credibility interval with a "confidence interval"*: the latter has a much more involved and less straightforward meaning.)
439
442
440
-
For the Gentoo species, there's a 50% probability that its relative frequency is roughly between 0.3 and 0.45; and an 89% probability that their relative frequency is roughly between 0.2 and 0.6.
443
+
The `Pr()` function by default calculates two credibility intervals for each frequency estimate: a 50% one, and an 89% one. In our present inference, the 50%-credibility intervals are shown in the plot above as the darker grey band, and the 89%-credibility intervals as the lighter grey band. Note that these intervals contain the 50% ones.
441
444
442
-
The credibility intervals can be read from the `quantiles` element of the `Fspecies10` object:
445
+
For instance, the plot indicates that there's a 50% probability that the relative frequency of all `Adelie` penguins is roughly between 0.25 and 0.4; and an 89% probability that their relative frequency is roughly between 0.3 and 0.45.
443
446
447
+
For the `Gentoo` species, there's a 50% probability that its relative frequency is roughly between 0.3 and 0.45; and an 89% probability that their relative frequency is roughly between 0.2 and 0.6.
444
448
445
-
```r
446
-
Fspecies10$quantiles
447
-
## , , = 5.5%
448
-
##
449
-
## X
450
-
## Y [,1]
451
-
## [1,] 0.134878
452
-
## [2,] 0.132087
453
-
## [3,] 0.180867
454
-
##
455
-
## , , = 25%
456
-
##
457
-
## X
458
-
## Y [,1]
459
-
## [1,] 0.227634
460
-
## [2,] 0.219339
461
-
## [3,] 0.284369
462
-
##
463
-
## , , = 75%
464
-
##
465
-
## X
466
-
## Y [,1]
467
-
## [1,] 0.395804
468
-
## [2,] 0.391340
469
-
## [3,] 0.457973
470
-
##
471
-
## , , = 94.5%
472
-
##
473
-
## X
474
-
## Y [,1]
475
-
## [1,] 0.525858
476
-
## [2,] 0.521080
477
-
## [3,] 0.587441
478
-
```
449
+
We can Actually do more: we can plot the probabilities of all possible frequencies. To understand this idea, let's ask: what is the relative frequency of Adélie penguins in the whole population? Possible values could be anything between 0 and 1. But some of these values may be more probable than others. If we look at our 10 samples, we see that 3 out of 10 are `Adelie`. So a relative frequency around 0.3 is a little more probable, although there's still a lot of uncertainty because this is just a small sample.
479
450
480
-
As the name tells, this element actually report the *quantiles* of the probability. For example, look at the `= 25%` output: among other things it says `Adelie 0.227634`. This means that there's a 25% probability that the frequency of Adélie penguins is below $0.227634$, and thus a 75% probability that it's above $0.227634$.
451
+
The `Pr()` function has actually calculated, in an approximate way, the probabilities for all possible frequencies of each species. We can plot the probabilities of the frequencies of the `Adelie` species as follows:
<imgsrc="figure/hist10adelie-1.png"alt="**Probability distribution for the frequency of Adelie penguins**"width="100%" />
463
+
<pclass="caption">**Probability distribution for the frequency of Adelie penguins**</p>
464
+
</div>
490
465
491
-
by giving the probabilities of all possible relative-frequency distributions.
466
+
With the `subset()` function we first extract from the `Fspecies10` object only the information pertaining to the `Adelie` species, saving it into the `onlyAdelie` object. Then the `hist()` function plots the probability distribution for all the frequency values. We see that frequencies between 0.2 and 0.4 have highest probability. But the probability distribution is quite wide; even a frequency of 0.6 has some probability. The vertical line indicates the mean of this probability distribution, which we take as our frequency estimate.
492
467
468
+
The width of this probability distribution reflects our large uncertainty, which in turn comes from the fact that we have only seen a small sample of penguins. We shall see that this uncertainty decreases and we gather more samples.
493
469
470
+
\
471
+
The credibility intervals are calculated from the probability distribution above. They can be quickly obtained from the `quantiles` element of the `Fspecies10` object. For instance, we can read the 89%-credibility intervals as follows:
<imgsrc="figure/freqs10-1.png"alt="plot of chunk freqs10"width="100%" />
513
-
<pclass="caption">plot of chunk freqs10</p>
514
-
</div>
483
+
<!-- As the name tells, this element actually report the *quantiles* of the probability. For example, look at the `= 25%` output: among other things it says `Adelie 0.227634`. This means that there's a 25% probability that the frequency of Adélie penguins is below $0.227634$, and thus a 75% probability that it's above $0.227634$.
484
+
-->
515
485
516
-
```r
486
+
### A preliminary report
517
487
518
-
hist(prQ1, xlim= c(0, 1))
519
-
```
488
+
We can now give a preliminary answer to our question **Q1**, "what's the overall statistical occurrence of the three species in the whole population?".
520
489
521
-
<divclass="figure">
522
-
<imgsrc="figure/freqs10-2.png"alt="plot of chunk freqs10"width="100%" />
523
-
<pclass="caption">plot of chunk freqs10</p>
524
-
</div>
490
+
A summary answer could be as follows:
525
491
492
+
> From a sample of 10 penguins, the inference about the relative frequencies of the three species in the full population is as follows:
493
+
>
494
+
> Adélie
495
+
> : rel. frequency between 0.143 and 0.53, with 89% probability
496
+
>
497
+
> Chinstrap
498
+
> : rel. frequency between 0.13 and 0.52, with 89% probability
499
+
>
500
+
> Gentoo
501
+
> : rel. frequency between 0.18 and 0.59, with 89% probability
502
+
503
+
But we can also give a fuller answer by displaying the probability distributions for all three frequencies:
<imgsrc="figure/freqsall-1.png"alt="plot of chunk freqsall"width="100%" />
544
-
<pclass="caption">plot of chunk freqsall</p>
512
+
<imgsrc="figure/hist10-1.png"alt="**Probability distribution for the rel. requencies of the three species**"width="100%" />
513
+
<pclass="caption">**Probability distribution for the rel. requencies of the three species**</p>
545
514
</div>
546
515
547
-
```r
516
+
It's important to keep in mind that the three frequencies must add up to 1, so if our future estimates of some of them increase, then the estimate of some others must decrease.
548
517
549
-
hist(prQ1, xlim= c(0, 1))
550
-
```
551
518
552
-
<divclass="figure">
553
-
<imgsrc="figure/freqsall-2.png"alt="plot of chunk freqsall"width="100%" />
0 commit comments