Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ $$\hat{\vY} = H\vY$$
:::

:::{#thm-resid-unbiased}
#### Mean and variance of residuals

For an ordinary least squares linear model
with fitted values $\hat y_i = \dprodf{\vx_i}{\vb}$
(and fitted-value vector $\hat{\vY}$),
Expand Down
1 change: 1 addition & 0 deletions _subfiles/intro-MLEs/_sec-loglik.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ It is typically easier to work with the log of the likelihood function:
---

:::{#thm-mle-use-log}
#### Maximize the log-likelihood instead of the likelihood

The likelihood and log-likelihood have the same maximizer:

Expand Down
1 change: 1 addition & 0 deletions _subfiles/intro-MLEs/_sec_likelihood.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ $$\Lik_i(\theta) = \P(X_i=x_i)$$
---

:::{#thm-ds-lik-obs-lik}
#### Dataset likelihood as a product of observation likelihoods

For $\iid$ data $\vx \eqdef \x1n$,
the likelihood of the dataset is equal to the product of the observation-specific likelihood factors:
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/intro-to-survival-analysis/_sec-cuhaz.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Since $\haz(t) = \deriv{t}\cb{-\log{\surv(t)}}$ (see @thm-h-logS), we also have:

:::{#cor-surv-int-haz}
#### Survival function from the cumulative hazard

$$\surv(t) = \exp{-\int_{u=0}^t \haz(u)du}$${#eq-surv-int-haz}
:::

Expand Down
2 changes: 2 additions & 0 deletions _subfiles/intro-to-survival-analysis/_sec-exp-dist.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ $$
---

:::{#thm-mle-exp}
#### MLE of the exponential rate parameter

Let $T=\sum t_i$ and $U=\sum u_j$. Then:

$$
Expand Down
1 change: 1 addition & 0 deletions _subfiles/intro-to-survival-analysis/_sec-inv-survf.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ qexp(p = 0.5, rate = 2)
{{< slidebreak >}}

:::{#thm-inv-surv-is-quantile}
#### Inverse survival function is the quantile function

The inverse survival function equals the $(1-p)$th
[population quantile](probability.qmd#def-quantile-function)
Expand Down
3 changes: 3 additions & 0 deletions _subfiles/intro-to-survival-analysis/_sec-survf.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $$\surv(t) \eqdef \Pr(T > t)$$
---

:::{#thm-survival-expressions-1}
#### Equivalent expressions for the survival function

$$
\begin{aligned}
Expand Down Expand Up @@ -109,6 +110,7 @@ ggplot() +
---

:::{#thm-surv-fn-as-mean-status}
#### Survival function as expected survival status

If $A_t$ represents survival status at time $t$, with $A_t = 1$ denoting alive at time $t$ and $A_t = 0$ denoting deceased at time $t$, then:

Expand All @@ -119,6 +121,7 @@ $$\surv(t) = \P(A_t=1) = \E{A_t}$$
---

:::{#thm-surv-and-mean}
#### Mean as the integral of the survival function

If $T$ is a nonnegative random variable, then:

Expand Down
4 changes: 4 additions & 0 deletions _subfiles/logistic-regression/_sec-d_odds-d_logodds.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
:::{#lem-deriv-invodds}
#### Derivative of odds w.r.t. log-odds

$$\derivf{\odds}{\logodds} = \odds$$

:::
Expand Down Expand Up @@ -26,6 +28,8 @@ $$

:::{#thm-d_odds-d_logodds}

#### Derivative of odds in terms of probability

$$\derivf{\omega}{\eta} = \frac{\pi}{1-\pi}$${#eq-d_omega-d_eta}

:::
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/logistic-regression/_sec_OR-ratio-ratio.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ so odds ratios are ratios of ratios:
:::

:::{#thm-or-ratio-ratio}
#### Odds ratio as a ratio of ratios

$$
\ba
\ratio(\odds_1, \odds_2)
Expand Down
4 changes: 4 additions & 0 deletions _subfiles/logistic-regression/_sec_OR_logistic.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ $$

:::{#thm-logistic-OR}

#### Odds ratio from difference in covariate patterns

The odds ratio comparing covariate patterns $\vx$ and $\vxs$ is:

{{< include _subfiles/logistic-regression/_eq_OR_delta.qmd >}}
Expand All @@ -211,6 +213,8 @@ By @sol-simplify-logistic-OR.

:::{#cor-log-or}

#### Log odds ratio equals the difference in log-odds

$$\logf {\ror(\vx,\vxs)} = \difflogodds$$

:::
4 changes: 4 additions & 0 deletions _subfiles/logistic-regression/_sec_d-pi_d-eta.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:::{#thm-d_prob-d_logodds}

#### Derivative of probability w.r.t. log-odds

$$\derivf{\prob}{\logodds} = \pi (1-\pi)$$
:::

Expand Down Expand Up @@ -39,6 +41,8 @@ $$

:::{#cor-d_pi-d_eta-var}

#### Derivative of probability w.r.t. linear predictor as a variance

If $\pi = \Pr(Y=1| \vX=\vx)$, then:

$$\derivf{\pi}{\eta} = \Varf{Y|X=x}$$
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/logistic-regression/_sec_derive_logistic_loglik.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ $$

:::{#lem-logistic-loglik-component}

#### Per-observation log-likelihood component

$$\ell_i(\pi_i) = y_i \eta_i - \logf{1+\odds_i}$$

:::
3 changes: 3 additions & 0 deletions _subfiles/logistic-regression/_sec_expit.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

:::{#thm-prob-from-logodds}

#### Probability as a function of log-odds

::: notes
If $\prob$ is the probability of an event $A$,
$\odds$ is the corresponding odds of $A$,
Expand Down Expand Up @@ -61,6 +63,7 @@ Details left to the reader.
---

:::{#thm-expit-prob-logodds}
#### Probability via the expit function
If $\prob$ is the probability of an event $A$,
$\odds$ is the corresponding odds of $A$,
and $\logodds$ is the corresponding log-odds of $A$,
Expand Down
7 changes: 7 additions & 0 deletions _subfiles/logistic-regression/_sec_invodds.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ $$

:::{#thm-odds-to-prob}

#### Probability as a function of odds

If $\pi$ is the probability of an event
and $\omega$ is the corresponding odds of that event,
then:
Expand Down Expand Up @@ -86,6 +88,8 @@ can be called the **inverse-odds function**.

:::{#cor-invodds-pi}

#### Probability via the inverse-odds function

$$\prob = \invoddsf{\odds}$$
:::

Expand All @@ -100,6 +104,8 @@ By @def-inv-odds and @thm-odds-to-prob.

:::{#cor-invodds-odds-inv}

#### Inverse-odds function inverts the odds function

$$\invoddsf{\odds} = \oddsinvf{\odds}$$

:::
Expand Down Expand Up @@ -252,6 +258,7 @@ $$
---

:::{#cor-inverse-odds-nonevent}
#### One plus odds in terms of non-event probability
$$1+\odds = \frac{1}{1-\prob}$$
:::

Expand Down
9 changes: 9 additions & 0 deletions _subfiles/logistic-regression/_sec_logistic_score_fn.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ As usual, by independence, we have:

:::{#lem-score-logistic}

#### Score function decomposes over observations

$$
\ba
\brown{\vec{\llik'}(\vb)}
Expand All @@ -22,6 +24,8 @@ we can apply the [vector chain rule](math-prereqs.qmd#thm-chain-vec):

:::{#lem-logistic-score-comp}

#### Chain rule applied to the score component

$$
\ba
\magenta{\vec{\llik_i'}(\vb)}
Expand All @@ -38,6 +42,8 @@ $$

:::{#lem-d_logodds-d_vb}

#### Derivative of log-odds with respect to coefficients

By [the derivative of a linear combination](math-prereqs.qmd#thm-deriv-lincom):

$$
Expand Down Expand Up @@ -90,6 +96,7 @@ $$


:::{#thm-logistic-score-comp}
#### Score component for one observation
$$\magenta{\llik_i'(\vb)} = \magenta{\vx_i \err_i}$${#eq-score-comp}
:::

Expand All @@ -106,6 +113,8 @@ we have:

:::{#thm-logistic-score-fn}

#### Logistic-model score function

$$
\ba
\brown{\vec{\llik'}(\vb)} &= \sumin \magenta{\llik_i'(\vb)}\\
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/logistic-regression/_sec_logistic_slope_mean.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

:::{#lem-d_logodds-d_x}

#### Derivative of log-odds w.r.t. predictor

By [the derivative of a linear combination](math-prereqs.qmd#thm-deriv-lincom):

$$
Expand Down
3 changes: 3 additions & 0 deletions _subfiles/logistic-regression/_sec_logit.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ $$\logodds \eqdef \logf{\omega}$${#eq-def-logodds}

:::{#thm-logodds-pi}

#### Log-odds as a function of probability

If $\prob$ is the probability of an event $A$,
$\odds$ is the corresponding odds of $A$,
and $\eta$ is the corresponding log-odds of $A$,
Expand Down Expand Up @@ -81,6 +83,7 @@ Apply @def-logit-fn and then @def-odds (details left to the reader).
---

:::{#cor-logodds-logit}
#### Log-odds via the logit function
If $\prob$ is the probability of an event $A$
and $\logodds$ is the corresponding log-odds of $A$,
then:
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/logistic-regression/_sec_odds_fn.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $$
---

:::{#thm-prob-to-odds}
#### Odds as a function of probability
If $\prob$ is the probability of an event $A$
and $\odds$ is the corresponding odds of $A$,
then:
Expand Down Expand Up @@ -64,6 +65,7 @@ which is easier to remember and manipulate:
:::

:::{#cor-oddsf-to-odds}
#### Odds via the odds function
If $\prob$ is the probability of an outcome $A$
and $\odds$ is the corresponding odds of $A$,
then:
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/logistic-regression/_sec_odds_of_rare_events.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ $$

:::{#thm-odds-minus-probs}

#### Difference between odds and probability

Let $\odds = \frac{\pi}{1-\pi}$. Then:

$$\odds - \pi = \frac{\pi^2}{1-\pi}$$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ What is logistic regression?
:::{#sol-def-logistic-regression}

:::{#def-logistic-regression}
#### Logistic regression model

**Logistic regression** is a framework for modeling [binary](data.qmd#def-binary) outcomes, conditional on one or more *predictors* (a.k.a. *covariates*).
:::

Expand Down
3 changes: 3 additions & 0 deletions _subfiles/logistic-regression/_thm-d_odds_d_beta.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:::{#thm-d_odds_d_beta}
#### Gradient of odds w.r.t. coefficients

::: notes
To derive $\derivf{\odds}{\vb}$,
Expand All @@ -19,6 +20,8 @@ $$

:::{#cor-d_odds_d_beta}

#### Gradient of odds w.r.t. coefficients in terms of probability

$$
\ba
\derivf{\odds}{\vb}
Expand Down
4 changes: 3 additions & 1 deletion _subfiles/logistic-regression/_thm-d_pi_d_beta.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

:::{#thm-d_pi_d_beta}

Using
#### Gradient of fitted probability w.r.t. coefficients

Using
@lem-d_logodds-d_vb and
@thm-d_prob-d_logodds:

Expand Down
1 change: 1 addition & 0 deletions _subfiles/logistic-regression/_thm_odds-from-logodds.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:::{#lem-odds-from-logodds}
#### Odds from log-odds

::: notes
If $\odds$ is the odds of an event $A$
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/logistic-regression/_thms-deriv-odds.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $$

:::{#cor-deriv-odds}

#### Derivative of odds function in terms of odds

$$\derivf{\odds}{\prob} = \sqf{1+\odds}$$

:::
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/misc/_cor-deriv-expit.qmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:::{#cor-deriv-expit}
#### Derivative of expit

$$\dexpitf{\logodds} = (\expitf{\logodds}) (1 - \expitf{\logodds})$$
:::
2 changes: 2 additions & 0 deletions _subfiles/misc/_cor-deriv-invodds.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

:::{#cor-deriv-invodds}

#### Derivative of inverse-odds function

$$\doddsinvf{\odds} = \sqf{1 - \invoddsf{\odds}}$$
:::
2 changes: 2 additions & 0 deletions _subfiles/misc/_cor_prob-nonevent.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:::{#cor-inverse-odds-nonevent2}

#### Probability of a non-event from the odds

If $\prob$ is the probability of event $A$
and $\odds$ is the corresponding odds of event $A$,
then the probability that $A$ does not occur is:
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/misc/_lem-one-minus-expit.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
:::{#lem-one-minus-expit}
#### One minus expit

$$1-\expitf{\logodds} = \inv{1+\exp{\logodds}}$$
:::

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:::{#cor-hazard-ratio-vs-baseline}

#### Hazard factor from difference of log-hazard from baseline

$$\hazfactor(t|\vx)= \expf{\diffloghaz(t|\vx)}$$

:::
Expand Down
2 changes: 2 additions & 0 deletions _subfiles/proportional-hazards-models/_def-ph-model.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Equivalently:

:::{#lem-ph-lincomp}

#### Log-hazard as baseline plus a linear combination

In a proportional hazards model (that is, if @eq-ph-diffloghaz holds):

$$
Expand Down
Loading
Loading