1
votes

I had an odd question when compiling the following document. se.ranef(model) and se.fixef(model) worked fine in R. However, as the following picture shows, suddenly, they could not be found. What went wrong, please? Could anyone help me, please? Thank you!

enter image description here

\documentclass[english]{exam}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{bigints}
\usepackage[stable]{footmisc}
\usepackage{ulem}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{booktabs}
\usepackage{pdfpages}

\printanswers
\unframedsolutions

\begin{document}

\begin{questions}

\question 

\begin{solution}

<<>>=
library(lme4)
X <- 1:24
coag <- c(62, 60, 63, 59, 63, 67, 71, 64, 65, 66, 68, 66, 
          71, 67, 68, 68, 56, 62, 60, 61, 63, 64, 63, 59)
diet <- c("A", "A", "A",  "A",  "B",  "B",  "B",  "B",  "B",  "B", "C", 
          "C", "C", "C", "C", "C", "D", "D", "D", "D",  "D", "D", "D", "D")
#coag <- data.frame(cbind(X, coag, diet))
#coag <- read.table("coag.csv", sep=",", header=TRUE)
model <- lmer(coag~(1|diet))
@

<<>>=
se.ranef(model)
@

<<>>=
se.fixef(model)
@

\end{solution}

\end{questions}

\end{document}
1

1 Answers

4
votes

se.fixef and se.ranef are functions not from base, or nlme. knitr starts a new environment when you run it, so any other packages are not loaded.

Try loading the library you got them from first, add this to where you load nlme:

library(arm)