Problem 1: Regression Analysis

The following dataset on body weight and on futher observations on a number of animals is given.

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 data can be read from https://charlotte-ngs.github.io/asmss2022/data/asm_bw_mult_reg.csv. The additional columns contain data on body condition score (BCS) and height (HEI).

Tasks

  • Build a regression model of body weight on the other observations using the dataset given above.
  • Set up the matrix \(\mathbf{X}\) and the vectors \(\mathbf{y}\), \(\mathbf{b}\) and \(\mathbf{e}\).
  • Compute estimate for the regression coefficients in the model defined above.

Your Solution

  • Start by building the model which includes the decision of what type of components go into the vector \(\mathbf{b}\). Then write down the model in matrix-vector notation.
  • Determine all the components of \(\mathbf{X}\), \(\mathbf{y}\), \(\mathbf{b}\) and \(\mathbf{e}\).
  • Compute the solution for $

Problem 2

Use the same dataset as in Problem 1 and verify your results using the function lm() in R.

Your Solution

  • Read the data into a dataframe
  • Use the lm() function which takes a formula to define the model and a dataframe
  • Use the function summary() on the result of lm() to show the results

Latest Changes: 2022-02-26 16:36:25 (pvr)

LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayAxCmF1dGhvcjogCmRhdGU6IDIwMjItMDItMjUKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpCmBgYAoKCiMjIFByb2JsZW0gMTogUmVncmVzc2lvbiBBbmFseXNpcwpUaGUgZm9sbG93aW5nIGRhdGFzZXQgb24gYm9keSB3ZWlnaHQgYW5kIG9uIGZ1dGhlciBvYnNlcnZhdGlvbnMgb24gYSBudW1iZXIgb2YgYW5pbWFscyBpcyBnaXZlbi4KCmBgYHtyIHR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