Problem 1: Helmert Contrasts

Use the dataset of Body Weight and Breed to fit a linear model of Body Weight on Breed. The aim of this exercise is to use the Helmert-contrasts instead of the defautl Treatment contrasts. What are the estimable functions used in the Helmert-Contrasts and what are the effects that are reported for the different levels of the factor Breed? Verify your answer by comparing estimable functions of solutions of the least squares normal equations to the effects of lm().

The dataset is available under

https://charlotte-ngs.github.io/asmss2022/data/asm_bw_flem.csv 

Hint

  • Use options(contrasts = c("contr.helmert", "contr.helmert")) to change the default contrasts to the desired Helmert-Contrasts

Your Solution

  • Compute solutions to least squares normal equation

  • Change contrasts from default to Helmert

  • Find estimable functions associated to Helmert contrasts

  • Check back with effects of lm()

Problem 2: Simulation

Use the results of the regression of Body Weight on Breast Circumference and simulate three datasets with 10, 30 and 100 observations respectively. What is the number of observations required to obtain the same regression results from the simulated dataset that you used in the simulation?

The original dataset is available under:

https://charlotte-ngs.github.io/asmss2022/data/asm_bw_flem.csv 

Your Solution

  • Run the regression analysis of Body Weight on Breast Circumference

  • Create the three datasets

  • Analyse each of the datasets using lm()

  • Check the obtained results, whether they match the input from the simulation


Latest Changes: 2022-04-04 07:36:02 (pvr)

LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayA1CmF1dGhvcjogUGV0ZXIgdm9uIFJvaHIKZGF0ZTogJzIwMjItMDMtMjYnCm91dHB1dDogaHRtbF9ub3RlYm9vawpwYXJhbXM6CiAgZG9jdHlwZToKICAgIGxhYmVsOiBEb2N1bWVudCBUeXBlCiAgICB2YWx1ZTogc29sdXRpb24KICAgIGNob2ljZXM6CiAgICAtIGV4ZXJjaXNlCiAgICAtIHNvbHV0aW9uCiAgICAtIG5vdGVib29rCi0tLQoKCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0Ka25pdHI6Om9wdHNfY2h1bmskc2V0KGVjaG8gPSBUUlVFKQpgYGAKCgpgYGB7ciwgZWNobz1GQUxTRX0Kc19leDA1cDAxX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