Problem 2: Regression On Dummy Variables
Use the dataset with the breeds assigned to every animal and find out
the influence of the breed on the response variable
body weight
. The data is available from
[1] "https://charlotte-ngs.github.io/asmss2023/data/asm_bw_flem.csv"
https://charlotte-ngs.github.io/asmss2023/data/asm_bw_flem.csv
Start by fitting a linear model with Breed
as the only
factor in the model, hence ignore the independent variables such as
Breast Circumference
, BCS
and
HEI
.
Problem 3: Estimable Function
Use the matrix vector-notation to setup the model for a regression on
dummy variable with the data on breeds and body weight as used in
Problem 2. The aim of this problem is to find the estimable functions
used in the output of lm()
.
The model is given by
\[\mathbf{y} = \mathbf{Xb} +
\mathbf{e}\]
Setup the least squares normal equations. Find a solution for \(\mathbf{b}^0\) and construct the estimable
function that is used in the output lm()
.
Your Solution
Define elements of least squares normal equations
Find a solution for \(\mathbf{b}^0\)
Construct the estimable function. As a hint, assume the missing
factor level in the output of lm()
to be zero.
Latest Changes: 2023-03-12 15:28:42 (pvr)
LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayAzCmF1dGhvcjogUGV0ZXIgdm9uIFJvaHIKZGF0ZTogJzIwMjMtMDMtMTInCm91dHB1dDogaHRtbF9ub3RlYm9vawpwYXJhbXM6CiAgZG9jdHlwZToKICAgIGxhYmVsOiBEb2N1bWVudCBUeXBlCiAgICB2YWx1ZTogc29sdXRpb24KICAgIGNob2ljZXM6CiAgICAtIGV4ZXJjaXNlCiAgICAtIHNvbHV0aW9uCiAgICAtIG5vdGVib29rCiAgaXNvbmxpbmU6CiAgICBsYWJlbDogT25saW5lICh5L24pCiAgICB2YWx1ZTogdHJ1ZQogICAgY2hvaWNlczoKICAgIC0gdHJ1ZQogICAgLSBmYWxzZQotLS0KCgoKYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldChlY2hvID0gVFJVRSkKYGBgCgoKYGBge3IgZXgwM3AwMS1zZXR1cCwgZWNobz1GQU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