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:
\mu=\frac{\Sigma_{i=1}^{k}\bar{x}_{i}n_{i}}{\Sigma_{i=1}^{k}n_{i}}
where \mu
is the grand mean, \bar{x}_{i}
represents the sample means, and n_{i}
represents the sample sizes.
Maximum-likelihood mixture variances are computed as:
var_{pooled_{ML}}=MSW_{ML}=\frac{\Sigma_{i=1}^{k}\left(\bar{x}_{i}-\mu\right)n_{i}}{\Sigma_{i=1}^{k}n_{i}}
var_{means_{ML}}=MSB_{ML}=\frac{\Sigma_{i=1}^{k}\left(\bar{x}_{i}-\mu\right)n_{i}}{k}
var_{BG_{ML}}=\frac{\Sigma_{i=1}^{k}\left(\bar{x}_{i}-\mu\right)n_{i}}{\Sigma_{i=1}^{k}n_{i}}
var_{WG_{ML}}=\frac{\Sigma_{i=1}^{k}v_{i}n_{i}}{\Sigma_{i=1}^{k}n_{i}}
var_{mix_{ML}}=var_{BG_{ML}}+var_{WG_{ML}}
where v_{i}
represents the sample variances.
Unbiased mixture variances are computed as:
var_{pooled_{Unbiased}}=MSW_{Unbiased}=\frac{\Sigma_{i=1}^{k}v_{i}\left(n_{i}-1\right)}{\left(\Sigma_{i=1}^{k}n_{i}\right)-k}
var_{means_{Unbiased}}=MSB_{Unbiased}=\frac{\Sigma_{i=1}^{k}\left(\bar{x}_{i}-\mu\right)n_{i}}{k-1}
var_{BG_{Unbiased}}=\frac{\Sigma_{i=1}^{k}\left(\bar{x}_{i}-\mu\right)n_{i}}{\left(\Sigma_{i=1}^{k}n_{i}\right)-1}
var_{WG_{Unbiased}}=\frac{\Sigma_{i=1}^{k}v_{i}\left(n_{i}-1\right)}{\left(\Sigma_{i=1}^{k}n_{i}\right)-1}
var_{mix_{Unbiased}}=var_{BG_{Unbiased}}+var_{WG_{Unbiased}}
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))