Skip to content

Commit

Permalink
Merge pull request #28 from carlbfrederick/master
Browse files Browse the repository at this point in the history
(lame) examples for all exported functions and package helpfile
  • Loading branch information
jknowles committed Aug 6, 2015
2 parents fb0e858 + 0a51d6f commit f54d1f2
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ importFrom(shiny,reactive)
importFrom(shiny,reactiveValues)
importFrom(shiny,renderPlot)
importFrom(shiny,renderPrint)
importFrom(shiny,runApp)
importFrom(shiny,shinyApp)
importFrom(shiny,sidebarLayout)
importFrom(shiny,sidebarPanel)
Expand Down
28 changes: 27 additions & 1 deletion R/merExtract.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@
#' @description Extracts random effect terms from an lme4 model
#' @param merMod a merMod object from the lme4 package
#' @importFrom plyr adply rbind.fill
#' @return a data frame with random effects from lme4 by group id
#' @return a data frame with the following columns
#' \describe{
#' \item{groupFctr}{The name of the grouping factor associated with the random effects}
#' \item{groupID}{The level of the grouping factor associated with the random effects}
#' \item{'term'}{One column per random effect, the name is derived from the merMod}
#' \item{'term'_se}{One column per random effect, the name is derived from the merMod}
#' }
#' @examples
#' require(lme4)
#' m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
#' rfx <- REextract(m2)
#' #Note the column names
#' head(rfx)
#' @export
REextract <- function(merMod){
stopifnot(class(merMod) == "lmerMod" | class(merMod) == "glmerMod")
Expand Down Expand Up @@ -53,6 +65,11 @@ REextract <- function(merMod){
#' }
#' @details Use the Gelman sim technique to build empirical Bayes estimates.
#' Uses the sim function in the arm package
#' @examples
#' require(lme4)
#' m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
#' re2 <- REsim(m2, 25)
#' head(re2)
#' @export
REsim <- function(merMod, n.sims = 200, oddsRatio = FALSE){
stopifnot(class(merMod) == "lmerMod" | class(merMod) == "glmerMod")
Expand Down Expand Up @@ -97,6 +114,11 @@ REsim <- function(merMod, n.sims = 200, oddsRatio = FALSE){
#' }
#' @details Use the Gelman sim technique to build fixed effect estimates and
#' confidence intervals. Uses the sim function in the arm package
#' @examples
#' require(lme4)
#' m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
#' fe2 <- FEsim(m2, 25)
#' head(fe2)
#' @export
FEsim <- function(merMod, n.sims = 200, oddsRatio=FALSE){
stopifnot(class(merMod) == "lmerMod" | class(merMod) == "glmerMod")
Expand Down Expand Up @@ -125,6 +147,10 @@ FEsim <- function(merMod, n.sims = 200, oddsRatio=FALSE){
#' response variable standard deviations?
#' @import lme4
#' @return a numeric which represents the RMSE
#' @examples
#' require(lme4)
#' m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
#' RMSE.merMod(m2)
#' @export
RMSE.merMod <- function(merMod, scale = FALSE){
stopifnot(class(merMod) == "lmerMod")
Expand Down
38 changes: 37 additions & 1 deletion R/merTools-package.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
#' merTools.
#' merTools: Provides methods for extracting and exploring results from merMod
#' objects in the lme4 package.
#'
#' The merTools package contains convenience tools for extracting useful
#' information from and exploring the implications of merMod objects created by
#' the lme4 package. These convenience functions are especially useful for
#' merMod objects that take a long time to estimate due to their complexity or
#' because they are estimated on very large samples.
#'
#' See the vignettes for usage examples
#'
#' @section merMod extraction/utility functions:
#'
#' \itemize{
#' \item \code{\link{fastdisp}}
#' \item \code{\link{superFactor}}
#' \item \code{\link{REextract}}
#' \item \code{\link{REsim}}
#' \item \code{\link{FEsim}}
#' \item \code{\link{RMSE.merMod}}
#' \item \code{\link{thetaExtract}}
#' \item \code{\link{REquantile}}
#' }
#'
#' @section merMod exploration functions:
#'
#' \itemize{
#' \item \code{\link{plotREsim}}
#' \item \code{\link{plotFEsim}}
#' \item \code{\link{draw}}
#' \item \code{\link{wiggle}}
#' \item \code{\link{subBoot}}
#' \item \code{\link{predictInterval}}
#' \item \code{\link{expectedRank}}
#' \item \code{\link{REimpact}}
#' \item \code{\link{shinyMer}}
#' }
#'
#' @name merTools
#' @docType package
Expand Down
6 changes: 6 additions & 0 deletions man/FEsim.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ Simulate fixed effects from merMod
Use the Gelman sim technique to build fixed effect estimates and
confidence intervals. Uses the sim function in the arm package
}
\examples{
require(lme4)
m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
fe2 <- FEsim(m2, 25)
head(fe2)
}

15 changes: 14 additions & 1 deletion man/REextract.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ REextract(merMod)
\item{merMod}{a merMod object from the lme4 package}
}
\value{
a data frame with random effects from lme4 by group id
a data frame with the following columns
\describe{
\item{groupFctr}{The name of the grouping factor associated with the random effects}
\item{groupID}{The level of the grouping factor associated with the random effects}
\item{'term'}{One column per random effect, the name is derived from the merMod}
\item{'term'_se}{One column per random effect, the name is derived from the merMod}
}
}
\description{
Extracts random effect terms from an lme4 model
}
\examples{
require(lme4)
m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
rfx <- REextract(m2)
#Note the column names
head(rfx)
}

6 changes: 6 additions & 0 deletions man/REsim.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ Simulate random effects from merMod
Use the Gelman sim technique to build empirical Bayes estimates.
Uses the sim function in the arm package
}
\examples{
require(lme4)
m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
re2 <- REsim(m2, 25)
head(re2)
}

5 changes: 5 additions & 0 deletions man/RMSE.merMod.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ a numeric which represents the RMSE
\description{
Extract the Root Mean Squared Error for a lmerMod object
}
\examples{
require(lme4)
m2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
RMSE.merMod(m2)
}

42 changes: 40 additions & 2 deletions man/merTools.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,46 @@
\name{merTools}
\alias{merTools}
\alias{merTools-package}
\title{merTools.}
\title{merTools: Provides methods for extracting and exploring results from merMod
objects in the lme4 package.}
\description{
merTools.
The merTools package contains convenience tools for extracting useful
information from and exploring the implications of merMod objects created by
the lme4 package. These convenience functions are especially useful for
merMod objects that take a long time to estimate due to their complexity or
because they are estimated on very large samples.
}
\details{
See the vignettes for usage examples
}
\section{merMod extraction/utility functions}{


\itemize{
\item \code{\link{fastdisp}}
\item \code{\link{superFactor}}
\item \code{\link{REextract}}
\item \code{\link{REsim}}
\item \code{\link{FEsim}}
\item \code{\link{RMSE.merMod}}
\item \code{\link{thetaExtract}}
\item \code{\link{REquantile}}
}
}

\section{merMod exploration functions}{


\itemize{
\item \code{\link{plotREsim}}
\item \code{\link{plotFEsim}}
\item \code{\link{draw}}
\item \code{\link{wiggle}}
\item \code{\link{subBoot}}
\item \code{\link{predictInterval}}
\item \code{\link{expectedRank}}
\item \code{\link{REimpact}}
\item \code{\link{shinyMer}}
}
}

0 comments on commit f54d1f2

Please sign in to comment.