Problem 1: Regression Analysis
The following dataset on body weight and on futher observations on a
number of animals is given.
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/asmss2023/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: 2023-02-27 09:09:37 (pvr)
LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayAxCmF1dGhvcjogUGV0ZXIgdm9uIFJvaHIKZGF0ZTogJzIwMjMtMDItMjcnCm91dHB1dDogaHRtbF9ub3RlYm9vawpwYXJhbXM6CiAgZG9jdHlwZToKICAgIGxhYmVsOiBEb2N1bWVudCBUeXBlCiAgICB2YWx1ZTogc29sdXRpb24KICAgIGNob2ljZXM6CiAgICAtIGV4ZXJjaXNlCiAgICAtIHNvbHV0aW9uCiAgICAtIG5vdGVib29rCiAgaXNvbmx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