Update Exercise 1 (Multiple Regression).
This commit is contained in:
parent
19d4618a53
commit
b265c7afe0
@ -89,17 +89,24 @@ lm(@formula(Volume ~ Girth), trees)
|
|||||||
|
|
||||||
::: callout-tip
|
::: callout-tip
|
||||||
The command `rand(n)` generates a sample of `n` "random" (i.e.,
|
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
|
uniformly distributed) random numbers. If you want to sample from
|
||||||
with mean 0.0 and standard deviation 2.0, and sample `n` times from this
|
another distribution, use the `Distributions` package, define an object
|
||||||
distribution by `rand(d, n)`.
|
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
|
::: {.callout-caution collapse="false"}
|
||||||
these covariates and true parameters $\beta_0$, $\beta_1$ and $\sigma^2$
|
## Task 1
|
||||||
(you can choose them)), simulate responses from a linear model and
|
|
||||||
estimate the coefficients $\beta_0$ and $\beta_1$. Play with different
|
1. Generate $n=20$ covariates $\mathbf{x}$ randomly.
|
||||||
choices of the parameters to see the effects on the parameter estimates
|
2. Given these covariates and true parameters $\beta_0=-3$, $\beta_1=2$
|
||||||
and the $p$-values.
|
and $\sigma=0.5$, simulate responses from a linear model and
|
||||||
|
estimate the coefficients $\beta_0$ and $\beta_1$.
|
||||||
|
3. Play with different choices of the parameters above (including the
|
||||||
|
sample size $n$) to see the effects on the parameter estimates and
|
||||||
|
the $p$-values.
|
||||||
|
:::
|
||||||
|
|
||||||
## Multiple Regression Model
|
## Multiple Regression Model
|
||||||
|
|
||||||
@ -236,38 +243,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.,
|
||||||
|
Loading…
Reference in New Issue
Block a user