Skip to content

Commit

Permalink
initialize parameters_groupspecific #484 #482
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed May 9, 2021
1 parent 453efeb commit 62f44f3
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ export(p_value_robust)
export(p_value_satterthwaite)
export(p_value_wald)
export(parameters)
export(parameters_groupspecific)
export(parameters_type)
export(pool_parameters)
export(principal_components)
Expand Down
40 changes: 40 additions & 0 deletions R/parameters_grouplevel.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#' Extract group-specific parameters of mixed models
#'
#' Extract parameters of each individual group in the context of mixed models.
#'
#' @inheritParams model_parameters.merMod
#'
#' @examples
#' library(parameters)
#' if (require("lme4")) {
#' data <- lme4::sleepstudy
#'
#' # Random intercept
#' model <- lmer(Reaction ~ Days + (1 | Subject), data = data)
#' parameters_groupspecific(model)
#'
#' # Random slope and intercept
#' model <- lmer(Reaction ~ Days + (1 + Days | Subject), data = data)
#' parameters_groupspecific(model)
#'
#' # Nested random factors
#' set.seed(12345)
#' data$grp <- sample(1:5, size = 180, replace = TRUE)
#' data$subgrp <- NA
#' for (i in 1:5) {
#' filter_group <- data$grp == i
#' data$subgrp[filter_group] <- sample(1:30, size = sum(filter_group), replace = TRUE)
#' }
#' model <- lmer(Reaction ~ Days + (1 | grp / subgrp) + (1 | Subject), data = data)
#' parameters_groupspecific(model)
#'
#' }
#' @export
parameters_groupspecific <- function(model, ...) {
# Extract params
out <- model_parameters(model, effects = "random", group_level = TRUE)

# Assign new class
class(out) <- c("parmaeters_groupspecific", class(out))
out
}
42 changes: 42 additions & 0 deletions man/parameters_groupspecific.Rd

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

0 comments on commit 62f44f3

Please sign in to comment.