knitr::opts_chunk$set(echo = TRUE)
# define data directory depending on online status if (params$isonline){ s_data_dir <- "https://charlotte-ngs.github.io/asmss2022/data" } else { s_data_dir <- file.path(here::here(), "docs", "data") } s_data_path <- file.path(s_data_dir, "asm_bw_mult_reg.csv") s_data_bw_bc_path <- file.path(s_data_dir, "asm_bw_bc_reg.csv") # write the default one variable regression, if we are not online if (!params$isonline){ tbl_mult <- readr::read_csv(file = s_data_path) tbl_bw_bc <- dplyr::select(tbl_mult, Animal, `Breast Circumference`, `Body Weight`) if (!fs::file_exists(path = s_data_bw_bc_path)) readr::write_csv(tbl_bw_bc, file = s_data_bw_bc_path) } tbl_bw_bc <- readr::read_csv(file = s_data_bw_bc_path) n_nr_obs <- nrow(tbl_bw_bc)
The measurement unit has an influence on the results of a regression model. This is demonstrated by changing the unit for Breast Circumference
(BC) from centimeters to meters.
r n_nr_obs
animals. The dataset is availble as csv-file under: r s_data_bw_bc_path
lm()
readr::read_csv()
to read the datas_data_bw_bc_url <- "https://charlotte-ngs.github.io/asmss2022/data/asm_bw_bc_reg.csv" tbl_bw_bc <- readr::read_csv(file = s_data_bw_bc_path)
Breast Circumference
by 100tbl_bw_bc$`Breast Circumference` <- tbl_bw_bc$`Breast Circumference` / 100
lm()
lm_bw_bc_m <- lm(formula = `Body Weight` ~ `Breast Circumference`, data = tbl_bw_bc) summary(lm_bw_bc_m)
Comparison of results: intercept is the same, because it has the same unit as the response variable Body Weight
. The regression slope is multiplied by 100 compared to the result of the original dataset where Breast Circumference
is in cm.
Although according to the International System of Units (https://en.wikipedia.org/wiki/International_System_of_Units) meter is the official unit for length, it does not make sense to use meter as unit for breast circumference. This is because the range of measurement for breast circumference is very narrow when the values are expressed in meters. Furthermore the increment of $1$ meter is very unrealistic, compared to the range of available measurement value for breast circumference.
Do the same type of comparison of regression modelling results when changing the measurement unit for the variable HEI in the complete dataset given in
https://charlotte-ngs.github.io/asmss2022/data/asm_bw_mult_reg.csv
.
s_sol02_p02_path <- "https://charlotte-ngs.github.io/asmss2022/data/asm_bw_mult_reg.csv" tbl_sol02_p02 <- readr::read_csv(file = s_sol02_p02_path)
lm_sol02_p02 <- lm(formula = `Body Weight` ~ `Breast Circumference` + BCS + HEI, data = tbl_sol02_p02) summary(lm_sol02_p02)
tbl_sol02_p02_HEI_in_m <- tbl_sol02_p02 tbl_sol02_p02_HEI_in_m$HEI <- tbl_sol02_p02_HEI_in_m$HEI / 100
lm_sol02_p02_HEI_in_m <- lm(formula = `Body Weight` ~ `Breast Circumference` + BCS + HEI, data = tbl_sol02_p02_HEI_in_m) summary(lm_sol02_p02_HEI_in_m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.