Further elaboration of exxercises.
This commit is contained in:
@@ -65,7 +65,6 @@ Note: There is a closed-form expression for
|
|||||||
$(\hat \beta_0, \hat \beta_1)$. We will not make use of it here, but
|
$(\hat \beta_0, \hat \beta_1)$. We will not make use of it here, but
|
||||||
rather use Julia to solve the problem.
|
rather use Julia to solve the problem.
|
||||||
|
|
||||||
|
|
||||||
``` julia
|
``` julia
|
||||||
lm(@formula(Volume ~ Girth), trees)
|
lm(@formula(Volume ~ Girth), trees)
|
||||||
```
|
```
|
||||||
@@ -88,8 +87,11 @@ lm(@formula(Volume ~ Girth), trees)
|
|||||||
- column `Pr(>|t|)`: $p$-values for the hypotheses $\beta_i=0$ for
|
- column `Pr(>|t|)`: $p$-values for the hypotheses $\beta_i=0$ for
|
||||||
$i=0,1$
|
$i=0,1$
|
||||||
|
|
||||||
:::callout.tip
|
::: callout-tip
|
||||||
The command `rand(n)` generates a sample of `n` "random" (i.e., uniformly distributed) random numbers.
|
The command `rand(n)` generates a sample of `n` "random" (i.e.,
|
||||||
|
uniformly distributed) random numbers. If you want to sample from another distribution, use the `Distributions` package, define an object being the distribution of interest, e.g. `d = Normal(0.0, 2.0)` for a normal distribution
|
||||||
|
with mean 0.0 and standard deviation 2.0, and sample `n` times from this
|
||||||
|
distribution by `rand(d, n)`.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**Task 1**: Generate a random set of covariates $\mathbf{x}$. Given
|
**Task 1**: Generate a random set of covariates $\mathbf{x}$. Given
|
||||||
@@ -234,35 +236,38 @@ $$
|
|||||||
|
|
||||||
For the models above, these are:
|
For the models above, these are:
|
||||||
|
|
||||||
+----------------+------------------+-----------------+
|
+----------------+-----------------+----------------+
|
||||||
| Type of Data | Distribution | Link Function |
|
| Type of Data | Distribution | Link Function |
|
||||||
| | Family | |
|
| | Family | |
|
||||||
+================+==================+=================+
|
+================+=================+================+
|
||||||
| continuous | Normal | identity: |
|
| continuous | Normal | identity: |
|
||||||
| | | |
|
| | | |
|
||||||
| | | $$ |
|
| | | $$ |
|
||||||
| | | g(x)=x |
|
| | | g(x)=x |
|
||||||
| | | $$ |
|
| | | $$ |
|
||||||
+----------------+------------------+-----------------+
|
+----------------+-----------------+----------------+
|
||||||
| count | Poisson | log: |
|
| count | Poisson | log: |
|
||||||
| | | |
|
| | | |
|
||||||
| | | $$ |
|
| | | $$ |
|
||||||
|
| | | |
|
||||||
| | | g(x) = \log(x) |
|
| | | g(x) = \log(x) |
|
||||||
| | | $$ |
|
| | | $$ |
|
||||||
+----------------+------------------+-----------------+
|
+----------------+-----------------+----------------+
|
||||||
| binary | Bernoulli | logit: |
|
| binary | Bernoulli | logit: |
|
||||||
| | | |
|
| | | |
|
||||||
| | | $$ |
|
| | | $$ |
|
||||||
| | | g |
|
| | | g |
|
||||||
| | | (x) = \log\left |
|
| | | ( |
|
||||||
|
| | | x) = \log\left |
|
||||||
| | | ( |
|
| | | ( |
|
||||||
| | | \ |
|
| | | \ |
|
||||||
| | | f |
|
| | | f |
|
||||||
| | | ra |
|
| | | ra |
|
||||||
| | | c |
|
| | | c |
|
||||||
| | | {x}{1-x}\right) |
|
| | | { |
|
||||||
|
| | | x}{1-x}\right) |
|
||||||
| | | $$ |
|
| | | $$ |
|
||||||
+----------------+------------------+-----------------+
|
+----------------+-----------------+----------------+
|
||||||
|
|
||||||
In general, the parameter vector $\beta$ is estimated via maximizing the
|
In general, the parameter vector $\beta$ is estimated via maximizing the
|
||||||
likelihood, i.e.,
|
likelihood, i.e.,
|
||||||
@@ -296,7 +301,7 @@ model = glm(@formula(participation ~ age^2),
|
|||||||
::: callout-task
|
::: callout-task
|
||||||
**Task 3**:
|
**Task 3**:
|
||||||
|
|
||||||
1. Reproduce the results of our data analysis of the `tree` data set using
|
1. Reproduce the results of our data analysis of the `tree` data set
|
||||||
a generalized linear model with normal distribution family.
|
using a generalized linear model with normal distribution family.
|
||||||
2. Generate
|
2. Generate
|
||||||
:::
|
:::
|
||||||
|
|||||||
Reference in New Issue
Block a user