Show R code
coef(cvfit, s = "lambda.1se")
#> 4 x 1 sparse Matrix of class "dgCMatrix"
-#> s1
-#> (Intercept) 34.30916
-#> age .
-#> weight -0.08001
-#> protein 0.76405
diff --git a/.nojekyll b/.nojekyll index d4bc224..f98f34e 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -48479f2e \ No newline at end of file +59a3177a \ No newline at end of file diff --git a/Linear-models-overview.html b/Linear-models-overview.html index fab2a31..5f43330 100644 --- a/Linear-models-overview.html +++ b/Linear-models-overview.html @@ -3925,7 +3925,7 @@
coef(cvfit, s = "lambda.1se")
#> 4 x 1 sparse Matrix of class "dgCMatrix"
-#> s1
-#> (Intercept) 34.30916
-#> age .
-#> weight -0.08001
-#> protein 0.76405
ggplotly(HL_plot)
wcgs_response_resid_plot |> ggplotly()
We can see a slight fan-shape here: observations on the right have larger variance (as expected since \(var(\bar y) = \pi(1-\pi)/n\) is maximized when \(\pi = 0.5\)).
@@ -4007,8 +4007,8 @@|> ggplotly() wcgs_resid_plot1
Definition C.23 (Conditionally independent and identically distributed) A set of random variables \(Y_1, \ldots, Y_n\) are conditionally independent and identically distributed (shorthand: “\(Y_i | X_i\ \text{ciid}\)” or just “\(Y_i |X_i\ \text{iid}\)”) given a set of covariates \(X_1, \ldots, X_n\) if \(Y_1, \ldots, Y_n\) are conditionally independent given \(X_1, \ldots, X_n\) and \(Y_1, \ldots, Y_n\) are identically distributed given \(X_1, \ldots, X_n\).
The sum of many independent or nearly-independent random variables with small variances (relative to the number of RVs being summed) produces bell-shaped distributions.
+For example, consider the sum of five dice (Figure C.4).
+library(dplyr)
+dist =
+ expand.grid(1:6, 1:6, 1:6, 1:6, 1:6) |>
+ rowwise() |>
+ mutate(total = sum(c_across(everything()))) |>
+ ungroup() |>
+ count(total) |>
+ mutate(`p(X=x)` = n/sum(n))
+
+library(ggplot2)
+
+dist |>
+ ggplot() +
+ aes(x = total, y = `p(X=x)`) +
+ geom_col() +
+ xlab("sum of dice (x)") +
+ ylab("Probability of outcome, Pr(X=x)") +
+ expand_limits(y = 0)
+
+
+
In comparison, the outcome of just one die is not bell-shaped (?fig-clt-2d6).
+library(dplyr)
+dist =
+ expand.grid(1:6) |>
+ rowwise() |>
+ mutate(total = sum(c_across(everything()))) |>
+ ungroup() |>
+ count(total) |>
+ mutate(`p(X=x)` = n/sum(n))
+
+library(ggplot2)
+
+dist |>
+ ggplot() +
+ aes(x = total, y = `p(X=x)`) +
+ geom_col() +
+ xlab("sum of dice (x)") +
+ ylab("Probability of outcome, Pr(X=x)") +
+ expand_limits(y = 0)
+
+
+
What distribution does a single die have?
+Answer: discrete uniform on 1:6.
-