Problem 1: Multiple Linear Regression Model

During the lecture the regression model was explained using the dataset on body weight and breast circumference. To improve the regression model for body weight, two additional conformation traits BCS and HEI are also considered. The new dataset is given in Table @ref(tab:dataregression).

Dataset for Multiple Linear Regression of Body Weight on Breast Circumference and two Conformation Traits for ten Animals
Animal Breast Circumference Body Weight BCS HEI
1 176 471 5.0 161
2 177 463 4.2 121
3 178 481 4.9 157
4 179 470 3.0 165
5 179 496 6.8 136
6 180 491 4.9 123
7 181 518 4.4 163
8 182 511 4.4 149
9 183 510 3.5 143
10 184 541 4.7 130

The same dataset is also available from the website at https://charlotte-ngs.github.io/gelasmss2021/data/asm_w03_ex02_bw_mult_reg.csv.

Your Task

  • Setup the linear regression model with an intercept for the data given in Table @ref(tab:dataregression)
  • Compute the solution for the unknown parameter \(b\)
  • Verify the result with the output from the function lm() in R

Your Solution

To setup the linear regression model, we have to determine two components, namely the matrix \(X\) and the vector \(y\)

# specify the matrix X

# specify the vector y

Problem 2: Prediction

Given the measurement of the trait Breast Circumference for two additional animals. The measurements are shown in the following table

Breast Circumference Measurements For Two Animals Used To Predict Body Weight
Animal Breast Circumference
Animal 11 181.2
Calf 12 99.5

We want to use the results of the simple linear regression of body weight (BW) on breast circumference (BC), as shown in Problem 2 of Exercise 1 to computed the predicted values for Body Weight for the two animals. The observed value for Breast Circumference of “Calf 12” is outside of the range of the values used in Problem 1. Predicting values of response variables based on predictors that are outside of the range of values used for the parameter estimation is called extrapolation. Based on the result of the predicted value of the trait Body Weight for “Calf 12” what can be said about the process of extrapolation?

Your Tasks

  • Compute the predicted value of Body Weight for “Animal 11”
  • Compute the predicted value of Body Weight for “Calf 12”
  • Make a statement about the validity of the extrapolated value of Body Weight for “Calf 12”
LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLS0gIE5vdGVib29rIDIKYXV0aG9yOiBQZXRlciB2b24gUm9ocgpkYXRlOiAyMDIxLTAzLTA4Cm91dHB1dDogaHRtbF9ub3Rl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