describe_ml {quest} | R Documentation |
Multilevel Descriptive Statistics
Description
describe_ml
decomposes descriptive statistics from multilevel data
into within-group and between-group descriptives. The data is first separated
out into within-group components via centers_by
and between-group
components via aggs
. Then the psych
function
describe
is applied to both.
Usage
describe_ml(
data,
vrb.nm,
grp.nm,
na.rm = TRUE,
interp = FALSE,
skew = TRUE,
ranges = TRUE,
trim = 0.1,
type = 3,
quant = NULL,
IQR = FALSE
)
Arguments
data |
data.frame of data. |
vrb.nm |
character vector of colnames from |
grp.nm |
character vector of length 1 of a colname from |
na.rm |
logical vector of length 1 specifying whether missing values
should be removed before calculating the descriptive statistics. See
|
interp |
logical vector of length 1 specifying whether the median should be standard (FALSE) or interpolated (TRUE). |
skew |
logical vector of length 1 specifying whether skewness and kurtosis should be calculated (TRUE) or not (FALSE). |
ranges |
logical vector of length 1 specifying whether the minimum,
maximum, and range (i.e., maximum - minimum) should be calculated (TRUE) or
not (FALSE). Note, if |
trim |
numeric vector of length 1 specifying the top and bottom quantiles of data that are to be excluded when calculating the trimmed mean. For example, the default value of 0.1 means that only data within the 10th - 90th quantiles are used for calculating the trimmed mean. |
type |
numeric vector of length 1 specifying the type of skewness and
kurtosis coefficients to compute. See the details of
|
quant |
numeric vector specifying the quantiles to compute. Foe example,
the default value of c(0.25, 0.75) computes the 25th and 75th quantiles of
the group number of cases. If |
IQR |
logical vector of length 1 specifying whether to compute the Interquartile Range (TRUE) or not (FALSE), which is simply the 75th quantil - 25th quantile. |
Value
list of two elements each containing a data.frame of descriptive statistics, the first for the within-person components ("within") and the second for the between-person components ("between").
See Also
Examples
tmp_nm <- c("outcome","case","session","trt_time")
dat <- as.data.frame(lmeInfo::Bryant2016)[tmp_nm]
stats_by <- psych::statsBy(dat, group = "case") # requires you to include "case" column in dat
describe_ml(data = dat, vrb.nm = c("outcome","session","trt_time"), grp.nm = "case")