knitr::opts_chunk$set(echo = TRUE)
The same dataset is used as for the explanation of the Mixed Model Equation for the sire model. The data can be read from
s_data_url <- "https://charlotte-ngs.github.io/lbgfs2021/data/beef_data_bc.csv" tbl_beef_bc <- readr::read_csv(file = s_data_url) tbl_beef_bc$Herd <- as.factor(tbl_beef_bc$Herd) tbl_beef_bc$Sire <- as.factor(tbl_beef_bc$Sire) head(tbl_beef_bc)
library(lme4) fit_beef_bc_all <- lmer(formula = `Weaning Weight` ~ Herd + `Breast Circumference` + (1|Sire), data = tbl_beef_bc) isSingular(fit_beef_bc_all)
Reducing model complexity
fit_beef_sire_no_inter <- lmer(formula = `Weaning Weight` ~ 0 + (1|Sire), data = tbl_beef_bc) isSingular(fit_beef_sire_no_inter)
Model summary
summary(fit_beef_sire_no_inter)
The package functionality is tested with a dataset that is documented to be working.
library(lme4) str(sleepstudy)
Descriptive statistics reveals a linear dependence of Reaction
on Days
but each subject seams to have a different slope in the relationship. This is modelled with the following statement.
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) summary(fm1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.