Compute descriptive statistics for a mixture distribution. This function returns the grand mean, the pooled sample (within-sample) variance, variance of sample means (between-groups), and mixture (total sample) variance of the mixture sample data.
mix_dist(mean_vec, var_vec, n_vec, unbiased = TRUE, na.rm = FALSE)
Vector of sample means.
Vector of sample variances.
Vector of sample sizes.
Logical scalar determining whether variance should be unbiased (TRUE; default) or maximum-likelihood (FALSE).
Logical scalar determining whether to remove missing values prior to computing output (TRUE) or not (FALSE; default)
The mean, pooled sample (within-sample) variance, variance of sample means (between-groups), and mixture (total sample) variance of the mixture sample data.
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_{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_{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}}$$
# NOT RUN {
mix_dist(mean_vec = c(-.5, 0, .5), var_vec = c(.9, 1, 1.1), n_vec = c(100, 100, 100))
# }
Run the code above in your browser using DataLab