knitr::opts_chunk$set(echo = FALSE) # rmdhelp::show_knit_hook_call() knitr::knit_hooks$set(hook_convert_odg = rmdhelp::hook_convert_odg)
Assessment of relationship between
tbl_reg <- tibble::tibble(Animal = c(1:10), `Breast Circumference` = c(176, 177, 178, 179, 179, 180, 181, 182,183, 184), `Body Weight` = c(471, 463, 481, 470, 496, 491, 518, 511, 510, 541)) n_nr_obs <- nrow(tbl_reg) knitr::kable(tbl_reg, booktabs = TRUE, longtable = TRUE, escape = FALSE)
library(ggplot2) ggplot(tbl_reg, aes(x = `Breast Circumference`, y = `Body Weight`)) + geom_point(color = "blue")
#rmdhelp::use_odg_graphic(ps_path = "odg/measure-band.odg") knitr::include_graphics(path = "odg/measure-band.png")
\begin{equation} E(y) = b_0 + b_1 * x \notag \end{equation}
#rmdhelp::use_odg_graphic(ps_path = "odg/lsq-plot.odg") knitr::include_graphics(path = "odg/lsq-plot.png")
Find values $\hat{b}_0$ and $\hat{b}_1$ such that
\begin{equation} \mathbf{e}^T\mathbf{e} = \sum_{i=1}^N e_i^2 = \sum_{i=1}^N \left[ y_i - E(e_i) \right]^2 = \sum_{i=1}^N \left[ y_i - b_0 - b_1*x_i \right]^2 \notag \end{equation}
is minimal
\begin{align} \frac{\partial\mathbf{e}^T\mathbf{e}}{\partial b_0} &= -2 \sum_{i=1}^N \left[y_i - b_0 - b_1x_i\right] \notag \ &= -2\left[\sum_{i=1}^N y_i - Nb_0 - b_1\sum_{i=1}^N x_i\right] \notag \end{align}
\begin{align} \frac{\partial\mathbf{e}^T\mathbf{e}}{\partial b_1} &= -2 \sum_{i=1}^N x_i\left[y_i - b_0 - b_1x_i\right] \notag \ &= -2 \left[\sum_{i=1}^N x_iy_i - b_0 \sum_{i=1}^N x_i - b_1 \sum_{i=1}^N x_i^2 \right]\notag \end{align}
$$x. = \sum_{i=1}^N x_i$$ $$y. = \sum_{i=1}^N y_i$$ $$(x^2). = \sum_{i=1}^N x_i^2 $$ $$(xy). = \sum_{i=1}^N x_iy_i$$ $$\bar{x}. = {x. \over N}$$ $$\bar{y}. = {y. \over N}$$
\begin{equation} \hat{b}_0 = \bar{y}. - \hat{b}_1\bar{x}. \notag \end{equation}
and
\begin{equation} \hat{b}_1 = \frac{(xy). - N\bar{x}.\bar{y}.}{(x^2). - N\bar{x}.^2} \notag \end{equation}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.