Problem 1: Experiment Evaluation
In the paper by [@Manzocchi2020] 4 different feeding treatments for dairy cows were compared. The different feeding treatments consisted of
1 |
hay |
2 |
grass-silage |
3 |
maize silage |
4 |
shredlage |
From the results section of the paper, the values for energy corrected milk (ECM in kg/day) and coagulation time (CGT in min) of the milk are shown in the table below.
1 |
24.3 |
11.0 |
2 |
23.6 |
10.6 |
3 |
25.0 |
10.5 |
4 |
23.8 |
10.3 |
The standard errors of the means (SEM) for the above reported target variables were
The real experiment is designed according to an incomplete latin square where in two runs groups of six cows were assigned to each of the four treatments. For the purpose of this exercise, we simplify the experimental design and assume that groups of 6 cows were assigned to the treatments all at the same time. The paper mentions that besides of the treatment numerous fixed effects (experimental run and interactions between treatments and experimental runs) and covariates (lactation stage) were considered. But unfortunately, no estimates for the different effects were given. Hence we are assuming that the treatment is the major effect on our responses.
Your Tasks
- Simulate a dataset with 6 cows per treatment and assign to each of the cows a value for the two responses ECM and CGT with mean values shown in the table above and with standard deviation equal to the SEM values.
- Analyse the dataset with a fixed linear effect model
- Verify whether you can reproduce the results of the paper
- Think about what type of contrasts are ideal for this type of dataset.
Your Solution
Simulate dataset similar to the one in the paper for ECM and CGT for the four treatments
Analyse the dataset with lm()
Compare your results with the results from the paper
What are the best contrast for our analysis
Problem 2: Significance and Size of Dataset
For some of the LM-analyses done in Problem 1, the results might not be significant. The same was also true in the paper. Their reported results were also declared to be non-significant. This might have two reasons.
- Either the generated dataset is just a “bad” example due to the unfortunate random numbers that were drawn or
- The size of the dataset is too small.
Check both reasons by implementing the following tasks
Your Tasks
- Repeat the simulation 30 times and check how many times a significant effect of one of the treatments can be reported.
- Increase the size of the dataset until one of the treatment effect is significant.
Your Solution
Create a loop that runs over all repetitions and does the analysis as shown in the solution of Problem 1
Inside of the loop store the results of lm()
in a new dataframe
Investigate the result dataframe and check how many times a significant result was obtained.
Double the number of observations until significant results can be found
References
Latest Changes: 2022-04-03 12:29:41 (pvr)
LS0tCnRpdGxlOiBBcHBsaWVkIFN0YX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RzIGZvciBkYWlyeSBjb3dzIHdlcmUgY29tcGFyZWQuIFRoZSBkaWZmZXJlbnQgZmVlZGluZyB0cmVhdG1lbnRzIGNvbnNpc3RlZCBvZiAKCmBgYHtyLCBlY2hvPUZBTFNFfQp0YmxfZmVlZCA8LSB0aWJibGU6OnRpYmJsZShUcmVhdG1lbnQgPSBjKDE6bl9ucl9mZWVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgRmVlZCA9IGMoImhheSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJncmFzcy1zaWxhZ2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibWFpemUgc2lsYWdlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInNocmVkbGFnZSIpKQprbml0cjo6a2FibGUodGJsX2ZlZWQsCiAgICAgICAgICAgICBib29rdGFicyA9IFRSVUUsCiAgICAgICAgICAgICBsb25ndGFibGUgPSBUUlVFKQpgYGAKCkZyb20gdGhlIHJlc3VsdHMgc2VjdGlvbiBvZiB0aGUgcGFwZXIsIHRoZSB2YWx1ZXMgZm9yIGVuZXJneSBjb3JyZWN0ZWQgbWlsayAoRUNNIGluIGtnL2RheSkgIGFuZCBjb2FndWxhdGlvbiB0aW1lIChDR1QgaW4gbWluKSBvZiB0aGUgbWlsayBhcmUgc2hvd24gaW4gdGhlIHRhYmxlIGJlbG93LiAKCmBgYHtyLCBlY2hvPUZBTFNFfQp0YmxfZWNtIDwtIHRpYmJsZTo6dGliYmxlKFRyZWF0bWVudCA9IGMoMTpuX25yX2ZlZWQpLAogICAgICAgICAgICAgICAgICAgICAgICAgIEVDTSA9IGMoMjQuMywgMjMuNiwgMjUuMCwgMjMuOCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgQ0dUID0gYygxMS4wLCAxMC42LCAxMC41LCAxMC4zKSkKa25pdHI6OmthYmxlKHRibF9lY20sCiAgICAgICAgICAgICBib29rdGFicyA9IFRSVUUsCiA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