-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
453efeb
commit 62f44f3
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.