Problem 1: Random Cows
a) We model sires as a random effect because these parenting bulls serve as factors that were randomly chosen from a greater population of bulls, where if we were to repeat the experiment we would randomly select different bulls from the greater population of bulls. As randomly chosen sires, we are interested in how much of the variability in the outcome is attributable to the randomness with in the sire factor.
b) The factor effects model for this experiment would read as:
y_ij = our prediction for the Average Daily Weight Gain for a Calv j by a specified Bull i.
mu = the overall mean of average daily weight gain for calves
alpha_i = the random effect attributed to the specificed Bull i
Epsilon_ij = the random error associated with predicting calv j with specified Bull i.
c)
install.packages("lme4", repos = "https://cran.r-project.org/web/packages/lme4/lme4.pdf")
## Warning: unable to access index for repository https://cran.r-project.org/web/packages/lme4/lme4.pdf/src/contrib:
## cannot open URL 'https://cran.r-project.org/web/packages/lme4/lme4.pdf/src/contrib/PACKAGES'
## Warning: package 'lme4' is not available (for R version 3.6.1)
## Warning: unable to access index for repository https://cran.r-project.org/web/packages/lme4/lme4.pdf/bin/macosx/el-capitan/contrib/3.6:
## cannot open URL 'https://cran.r-project.org/web/packages/lme4/lme4.pdf/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
library(lme4)
## Loading required package: Matrix
library(readxl)
calves <- read_excel("calves.xlsx")
modC<-lmer(weight~1+(1|sired), data=calves)
d)
modD<-lm(weight~1, data=calves)
e)
anova(modC, modD)
## refitting model(s) with ML (instead of REML)
## Data: calves
## Models:
## modD: weight ~ 1
## modC: weight ~ 1 + (1 | sired)
## Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
## modD 2 -22.898 -20.542 13.449 -26.898
## modC 3 -22.095 -18.561 14.047 -28.095 1.1962 1 0.2741
The output claims that Model C was refitted with ML instead of REML, so I am not sure of how that affects the output. It provides no Chisq of P value for Model D, so because I can only see that Model C does not have a significant P value for Chisq (it is greater than 0.05), then I would say it is not worth including a random effect for sire.
f) The variance component estimate for Model C is Chisq = 1.1962
g)
confint(modC)
## Computing profile confidence intervals ...
## 2.5 % 97.5 %
## .sig01 0.00000000 0.1795777
## .sigma 0.09534633 0.1783855
## (Intercept) 0.97994356 1.1733897