Problem 1: Overfitting

Use the extended dataset on Body Weight of animals and fit all the variables and the factor breed. Compare the result with a regression that uses only Breast Circumference or with the linear model that only uses the factor Breed. The data set is available from: https://charlotte-ngs.github.io/asmss2022/data/asm_bw_flem.csv

Your Solution

  • Read the data

  • Fit the full model

  • Fit the model with only Breast Circumference

  • Fit the model with only Breed

Problem 2: Plotting

The first step before doing any analysis should always be to plot the data which helps to visualise the internal structure of a dataset. A very instructive plot is the so-called pairs-plot. This plot can be done using the function pairs(). The task of this problem is to create a pairs-plot for the extended dataset on Body Weight of animals. The input to the function pairs() must be all numeric. This means that the column containing the Breed in our dataset must be converted to a datatype called factor. This can be done using the function as.factor().

Results of linear models can also be plotted. In such plots, we are mainly interested in the behavior of the residuals. Hence, fit a linear regression model between Body Weight and Breast Circumference and plot the resulting linear model object.

Your Solution

  • Read the dataset

  • Convert the breed column to a factor

  • Create a pairs-plot

  • Fit the linear regression model

  • Plot the result


Latest Changes: 2022-03-21 05:27:31 (pvr)

LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayA0CmF1dGhvcjogUGV0ZXIgdm9uIFJvaHIKZGF0ZTogMjAyMi0wMy0xNgpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgoKYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldChlY2hvID0gVFJVRSkKYGBgCgpgYGB7ciwgZWNobz1GQUxTRX0Kc19leDA0cDAxX2RhdGFfcGF0aCA8LSAiaHR0cHM6Ly9jaGFybG90dGUtbmdzLmdpdGh1Yi5pby9hc21zczIwMjIvZGF0YS9hc21fYndfZmxlbS5jc3YiCmBgYAoKCiMjIFByb2JsZW0gMTogT3ZlcmZpdHRpbmcKVXNlIHRoZSBleHRlbmRlZCBkYXRhc2V0IG9uIGBCb2R5IFdlaWdodGAgb2YgYW5pbWFscyBhbmQgZml0IGFsbCB0aGUgdmFya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