1

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}
LaTeXFan
  • 1,136
  • 4
  • 14
  • 36

1 Answers1

4

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)
jeremycg
  • 24,657
  • 5
  • 63
  • 74
  • 1
    Maybe there is also an error in the LaTeX code because your solution does not work for me. Could you please be more precise? – SabDeM Aug 06 '15 at 13:14
  • the error still exists. as I said it is not a R problem but a LaTeX one. I'll try to investigate the log file. – SabDeM Aug 06 '15 at 13:24
  • it works fine for me - pasting above into RStudio as a .rnw and hitting compile .pdf. R version 3.2.1, knitr_1.10.5, RStudio Version 0.99.441 – jeremycg Aug 06 '15 at 13:27