library(lme4)
## Loading required package: Matrix
library(faraway)
## Warning: package 'faraway' was built under R version 4.0.3
library(nlme)
##
## Attaching package: 'nlme'
## The following object is masked from 'package:lme4':
##
## lmList
fatmodel <- lmer(Fat ~ 1 + (1|Lab/Technician/Sample),data = eggs)
summary(fatmodel)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Fat ~ 1 + (1 | Lab/Technician/Sample)
## Data: eggs
##
## REML criterion at convergence: -64.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.04098 -0.46576 0.00927 0.59713 1.54276
##
## Random effects:
## Groups Name Variance Std.Dev.
## Sample:(Technician:Lab) (Intercept) 0.003065 0.05536
## Technician:Lab (Intercept) 0.006980 0.08355
## Lab (Intercept) 0.005920 0.07694
## Residual 0.007196 0.08483
## Number of obs: 48, groups:
## Sample:(Technician:Lab), 24; Technician:Lab, 12; Lab, 6
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 0.38750 0.04296 9.019
refitmodel <- lmer(Fat ~ 1 + (1|Lab/Technician),data = eggs)
summary(refitmodel)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Fat ~ 1 + (1 | Lab/Technician)
## Data: eggs
##
## REML criterion at convergence: -62.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.17799 -0.42424 0.08043 0.67361 1.77544
##
## Random effects:
## Groups Name Variance Std.Dev.
## Technician:Lab (Intercept) 0.008002 0.08945
## Lab (Intercept) 0.005920 0.07694
## Residual 0.009239 0.09612
## Number of obs: 48, groups: Technician:Lab, 12; Lab, 6
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 0.38750 0.04296 9.019
a. Fat is the response variable here
b. Lab, Technician, and Sample are all random effects.
c. Due to the natural progression I believe these are nested random effects.
d. Lab one appears to have higher fat contents, other labs are pretty consistent
e. .3875
f. 0.006980
g. 0.005920
h. The variance goes up, fixed effects stay the same