Skip to content

Instantly share code, notes, and snippets.

@derekmcloughlin
Last active February 21, 2024 15:44
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 19 You must be signed in to fork a gist
  • Save derekmcloughlin/896da22518ef2f3d81b0 to your computer and use it in GitHub Desktop.
Save derekmcloughlin/896da22518ef2f3d81b0 to your computer and use it in GitHub Desktop.
Useful Latex Equations used in R Markdown for Statistics
---
title: "Sample Equations used in Statistics"
output: html_document
---
### Summations
### Without Indices
$\sum x_{i}$
$\sum x_{i}^2$
$\sum x_{i}y_{i}$
#### With Indices - Inline Form
$\sum_{i=1}^n x_{i}$
$\sum_{i=1}^n x_{i}^2$
$\sum_{i=1}^n x_{i}y_{i}$
#### With Indices - Display Form
$$\sum_{i=1}^n x_{i}y_{i}$$
### Independent Samples
$$\mu_{\bar{x_{1}} - \bar{x_{2}}} = \mu_{1} - \mu_{2}$$
$$\sigma_{\bar{x_{1}} - \bar{x_{2}}}^2 = \frac {\sigma_{1}^2}{n_{1}} + \frac{\sigma_{2}^2}{n_{2}}$$
$$\mu_{\hat{p}_{1} - \hat{p}_{2}} = p_{1} - p_{2}$$
$$\sigma_{\hat{p}_{1} - \hat{p}_{2}}^2 = \frac {p_{1}(1 - p_{1})}{n_{1}} + \frac {p_{2}(1 - p_{2})}{n_{2}}$$
### Pooled Sample Variance
$$s_{p}^2 = \frac {(n_{1} - 1)s_{1}^2 + (n_{2} - 1)s_{2}^2}{n_{1} + n_{2} - 2}$$
### Pooled Sample Proportion
$$\hat{p} = \frac {n_{1}\hat{p}_1 + n_{2}\hat{p}_{2}}{n_{1} + n_{2}}$$
### Chi-Square Test
$$\chi^2 = \sum \frac {(O - E)^2}{E}$$
### Correlations
$${SS}_{xx} = \sum (x - \bar{x})^2 = \sum x^2 - \frac {(\sum x)^2}{n}$$
$${SS}_{xy} = \sum (x - \bar{x})(y - \bar{y}) = \sum xy - \frac {(\sum x)(\sum y)}{n}$$
$$r = \frac {{SS}_{xy}}{\sqrt {{SS}_{xx}{SS}_{yy}}}$$
### Regression
#### Population Regression Line
$$E(y) = \alpha + \beta{x}$$
$$var(y) = \sigma^2$$
#### Least Squares Line
$$\hat{y} = a + bx$$
where
$$b = \frac {{SS}_{xy}}{{SS}_{xx}}$$
and
$$\bar{y} = a + b\bar{x}$$
#### Residual Sum of Squares
$$SSResid = \sum (y - \hat{y})^2 = \sum y^2 - a\sum y - b \sum xy$$
#### Standard Errors
$$s_{e} = \sqrt \frac {SSResid}{n - 2}$$
$$s_{b} = \frac {s_{e}}{\sqrt {{SS}_{xx}}}$$
$$s_{a + bx} = s_{e} \sqrt {1 + \frac {1}{n} + \frac {(x - \bar{x})^2}{{SS}_{xx}}}$$
for prediction:
$$se(y - \hat{y}) = s_{e} \sqrt {1 + \frac {1}{n} + \frac {(x - \bar{x})^2}{{SS}_{xx}}}$$
### Variance
$$SSTr = \frac {T_{1}^2}{n_{1}} + \frac {T_{2}^2}{n_{2}} + ... + \frac {T_{k}^2}{n_{k}} - \frac {T^2}{n}$$
$$SSTo = x_{1}^2 + x_{2}^2 + ... + x_{k}^2 - \frac {T^2}{n}$$
$$SSE = SSTo - SSTr$$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment