Learn R Programming

psychmeta (version 2.6.4)

mix_dist: 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)

Value

The mean, pooled sample (within-sample) variance, variance of sample means (between-groups), and mixture (total sample) variance of the mixture sample data.

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=1^kx_in_i_i=1^kn_imu = sum(mean_vec * n_vec) / sum(n_vec)

where mu is the grand mean, x_imean_vec represents the sample means, and n_in_vec represents the sample sizes.

Maximum-likelihood mixture variances are computed as: var_pooled_ML=MSW_ML=_i=1^k(x_i-)n_i_i=1^kn_ivar_pooled_ml = MSW_ml = sum(var_vec * n_vec) / sum(n_vec) var_means_ML=MSB_ML=_i=1^k(x_i-)n_ikvar_means_ml = MSB_ml = sum(var_vec * n_vec) / sum(n_vec) var_BG_ML=_i=1^k(x_i-)n_i_i=1^kn_ivar_bg_ml = sum((mean_vec - mean_mixture)^2 * n_vec) / sum(n_vec) var_WG_ML=_i=1^kv_in_i_i=1^kn_ivar_wg_ml = sum(var_vec * n_vec) / sum(n_vec) var_mix_ML=var_BG_ML+var_WG_MLvar_mix_ml = var_bg_ml + var_wg_ml

where v_ivar_vec represents the sample variances.

Unbiased mixture variances are computed as: var_pooled_Unbiased=MSW_Unbiased=_i=1^kv_i(n_i-1)(_i=1^kn_i)-kvar_pooled_unbiased = MSW_unbiased = sum(var_vec * (n_vec - 1)) / (sum(n_vec) - k) var_means_Unbiased=MSB_Unbiased=_i=1^k(x_i-)n_ik-1var_means_unbiased = MSB_unbiased = sum((mean_vec - mean_mixture)^2 * n_vec) / (k - 1) var_BG_Unbiased=_i=1^k(x_i-)n_i(_i=1^kn_i)-1var_bg_unbiased = sum((mean_vec - mean_mixture)^2 * n_vec) / (sum(n_vec) - 1) var_WG_Unbiased=_i=1^kv_i(n_i-1)(_i=1^kn_i)-1var_wg_unbiased = sum(var_vec * (n_vec - 1)) / (sum(n_vec) - 1) var_mix_Unbiased=var_BG_Unbiased+var_WG_Unbiasedvar_mix_unbiased = var_bg_unbiased + var_wg_unbiased

Examples

Run this code
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