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)

Problem 1: Measurement Unit

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.

Tasks

Solution

s_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)
tbl_bw_bc$`Breast Circumference` <- tbl_bw_bc$`Breast Circumference` / 100
lm_bw_bc_m <- lm(formula = `Body Weight` ~ `Breast Circumference`, data = tbl_bw_bc)
summary(lm_bw_bc_m)

Problem 2: Significance Level

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.

Tasks

Solution

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)


charlotte-ngs/asmss2022 documentation built on June 7, 2022, 1:33 p.m.