mix_dist {psychmeta} | R Documentation |
Descriptive statistics for a mixture distribution
Description
Compute descriptive statistics for a mixture distribution. This function returns the grand mean, the pooled sample variance (mean square within), variance of sample means (mean square between), portions of the total variance that are within and between groups, and mixture (total sample) variance of the mixture sample data.
Usage
mix_dist(mean_vec, var_vec, n_vec, unbiased = TRUE, na.rm = FALSE)
Arguments
mean_vec |
Vector of sample means.
|
var_vec |
Vector of sample variances.
|
n_vec |
Vector of sample sizes.
|
unbiased |
Logical scalar determining whether variance should be unbiased (TRUE; default) or maximum-likelihood (FALSE).
|
na.rm |
Logical scalar determining whether to remove missing values prior to computing output (TRUE) or not (FALSE; default)
|
Details
The grand mean of a mixture distribution is computed as:
μ=Σi=1kniΣi=1kxˉini
where μ
is the grand mean, xˉi
represents the sample means, and ni
represents the sample sizes.
Maximum-likelihood mixture variances are computed as:
varpooledML=MSWML=Σi=1kniΣi=1k(xˉi−μ)ni
varmeansML=MSBML=kΣi=1k(xˉi−μ)ni
varBGML=Σi=1kniΣi=1k(xˉi−μ)ni
varWGML=Σi=1kniΣi=1kvini
varmixML=varBGML+varWGML
where vi
represents the sample variances.
Unbiased mixture variances are computed as:
varpooledUnbiased=MSWUnbiased=(Σi=1kni)−kΣi=1kvi(ni−1)
varmeansUnbiased=MSBUnbiased=k−1Σi=1k(xˉi−μ)ni
varBGUnbiased=(Σi=1kni)−1Σi=1k(xˉi−μ)ni
varWGUnbiased=(Σi=1kni)−1Σi=1kvi(ni−1)
varmixUnbiased=varBGUnbiased+varWGUnbiased
Value
The mean, pooled sample (within-sample) variance, variance of sample means (between-groups), and mixture (total sample) variance of the mixture sample data.
Examples
mix_dist(mean_vec = c(-.5, 0, .5), var_vec = c(.9, 1, 1.1), n_vec = c(100, 100, 100))
[Package
psychmeta version 2.7.0
Index]