Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed May 24, 2024
1 parent ec683fd commit aabb649
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 51 deletions.
43 changes: 17 additions & 26 deletions R/estimate_grouplevel.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,30 @@
#' indices (such as SE and CI), as these are not computable.
#' @param ... Other arguments passed to or from other methods.
#'
#' @examples
#' @examplesIf require("lme4") && require("see")
#' # lme4 model
#' if (require("lme4") && require("see")) {
#' model <- lmer(mpg ~ hp + (1 | carb), data = mtcars)
#' random <- estimate_grouplevel(model)
#' random
#' data(mtcars)
#' model <- lme4::lmer(mpg ~ hp + (1 | carb), data = mtcars)
#' random <- estimate_grouplevel(model)
#' random
#'
#' # Visualize random effects
#' plot(random)
#' # Visualize random effects
#' plot(random)
#'
#' # Show group-specific effects
#' estimate_grouplevel(model, deviation = FALSE)
#' # Show group-specific effects
#' estimate_grouplevel(model, deviation = FALSE)
#'
#' # Reshape to wide data so that it matches the original dataframe...
#' reshaped <- reshape_grouplevel(random, indices = c("Coefficient", "SE"))
#' # Reshape to wide data so that it matches the original dataframe...
#' reshaped <- reshape_grouplevel(random, indices = c("Coefficient", "SE"))
#'
#' # ... and can be easily combined
#' alldata <- cbind(mtcars, reshaped)
#' # ... and can be easily combined
#' alldata <- cbind(mtcars, reshaped)
#'
#' # Use summary() to remove duplicated rows
#' summary(reshaped)
#' # Use summary() to remove duplicated rows
#' summary(reshaped)
#'
#' # Compute BLUPs
#' estimate_grouplevel(model, type = "total")
#' }
#'
#' # Bayesian models
#' \donttest{
#' if (require("rstanarm")) {
#' model <- rstanarm::stan_lmer(mpg ~ hp + (1 | carb) + (1 | gear), data = mtcars, refresh = 0)
#' # Broken estimate_grouplevel(model)
#' }
#' }
#' # Compute BLUPs
#' estimate_grouplevel(model, type = "total")
#' @export
estimate_grouplevel <- function(model, type = "random", ...) {
# Extract params
Expand Down
43 changes: 18 additions & 25 deletions man/estimate_grouplevel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aabb649

Please sign in to comment.