diff --git a/R/ch2.html b/R/ch2.html index 169bd3b..9acd4e7 100644 --- a/R/ch2.html +++ b/R/ch2.html @@ -241,12 +241,12 @@ Probability and Likelihood gt::cols_width(everything() ~ px(100))
-
+
@@ -851,12 +851,12 @@ Baye’s Rule gt::cols_width(everything() ~ px(100))
-
+
@@ -1272,11 +1272,11 @@ Baye’s Rule fake -3967 -0.3967 +4011 +0.4011 real -6033 -0.6033 +5989 +0.5989 @@ -1313,8 +1313,8 @@ Baye’s Rule # Groups: usage [2] usage fake real <chr> <int> <int> -1 no 2891 5910 -2 yes 1076 123 +1 no 2942 5856 +2 yes 1069 133
@@ -1341,8 +1341,8 @@ Baye’s Rule
# A tibble: 2 × 3
   type  total  prop
   <chr> <int> <dbl>
-1 fake   1076 0.897
-2 real    123 0.103
+1 fake 1069 0.889 +2 real 133 0.111
@@ -1586,6 +1586,81 @@ Important

this has been mentioned before but its an important message to drive home. Note that the reason why thes values sum to a value greater than 1 is that they are not probabilities, they are likelihoods. We are determining how likely each value of \(\pi\) is given that we have observed \(Y = 1\).

+

We can formalize the likelihood function \(L\) in our example as follows:

+

\[L(\pi|y=1) = f(y=1|\pi) = {6 \choose 1}\pi^1(1-\pi)^{6-1}\] \[ = 6\pi(1 - \pi)^5\]

+

We can test this out

+
+
6 * .2 * (.8 ^ 5)
+
+
[1] 0.393216
+
+
+

which is the value we get as .2 in the bar plot above.

+

the likelihood values for \(Y = 1\) are here:

+
+
d |>
+    filter(ys == 1)|>
+    select(-display_pi) |>
+    knitr::kable()
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
piesysfys
0.110.354294
0.210.393216
0.310.302526
0.410.186624
0.510.093750
0.610.036864
0.710.010206
0.810.001536
0.910.000054
+
+
diff --git a/R/ch2.qmd b/R/ch2.qmd index 4701623..975e471 100644 --- a/R/ch2.qmd +++ b/R/ch2.qmd @@ -543,4 +543,27 @@ are likelihoods. We are determining how likely each value of $\pi$ is given that we have observed $Y = 1$. ::: +We can formalize the likelihood function $L$ in our example +as follows: + +$$L(\pi|y=1) = f(y=1|\pi) = {6 \choose 1}\pi^1(1-\pi)^{6-1}$$ +$$ = 6\pi(1 - \pi)^5$$ + +We can test this out + +```{r} +6 * .2 * (.8 ^ 5) +``` +which is the value we get as .2 in the bar plot above. + +the likelihood values for $Y = 1$ are here: + +```{r} +d |> + filter(ys == 1)|> + select(-display_pi) |> + knitr::kable() +``` + + diff --git a/R/ch2_files/figure-html/unnamed-chunk-11-1.png b/R/ch2_files/figure-html/unnamed-chunk-11-1.png index 7057949..f58d865 100644 Binary files a/R/ch2_files/figure-html/unnamed-chunk-11-1.png and b/R/ch2_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/R/ch2_files/figure-html/unnamed-chunk-6-1.png b/R/ch2_files/figure-html/unnamed-chunk-6-1.png index d2ed0b1..cfb1e1e 100644 Binary files a/R/ch2_files/figure-html/unnamed-chunk-6-1.png and b/R/ch2_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/R/styles.css b/R/styles.css index b90550d..ea389ca 100644 --- a/R/styles.css +++ b/R/styles.css @@ -1,4 +1,5 @@ @import url('https://fonts.googleapis.com/css?family=Lora&display=swap'); +@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro&display=swap'); body { font-family: 'Lora';