Problem 1

a.)

The weight gain of the calves is related to the sire so the data for each column are correlated.

b.)

\(y_{i} = \mu + \alpha_i + \epsilon_i\)

c.)
weight <- c(1.46, 1.17, 0.98, 0.95,1.23, 1.08, 1.06, 1.10,1.12, 1.20, 1.15, 1.07,1.23, 1.08, 1.11, 1.11,1.02, 1.01, 0.83,0.89,1.15, 0.86, 0.86, 1.12)

sired <- c("A","B","C","D","A","B","C","D","A","B","C","D","A","B","C","D","A","B","C","D","A","B","C","D")

calves = data.frame(sired,weight)

#mat <- matrix(alldata,ncol=4,byrow=TRUE)
#calves <-as.data.frame(mat)

library(lme4)
## Loading required package: Matrix
modC<-lmer(weight~1+(1|sired), data=calves)
summary(modC)
## Linear mixed model fit by REML ['lmerMod']
## Formula: weight ~ 1 + (1 | sired)
##    Data: calves
## 
## REML criterion at convergence: -23.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6639 -0.5601  0.1081  0.5645  2.3859 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  sired    (Intercept) 0.005078 0.07126 
##  Residual             0.015945 0.12627 
## Number of obs: 24, groups:  sired, 4
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  1.07667    0.04397   24.48
d.)
modD<-lm(weight~1, data=calves)
summary(modD)
## 
## Call:
## lm(formula = weight ~ 1, data = calves)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.24667 -0.07417  0.01333  0.07333  0.38333 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.07667    0.02881   37.37   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1411 on 23 degrees of freedom
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

It’s not worth including because the chi-squared value is very low???

f.)

The variance estimate for sired is 0.005078. That’s super low, so there’s not that much difference between sires.

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