Learn R Programming

psychmeta (version 2.6.4)

simulate_alpha: Generate a vector of simulated sample alpha coefficients

Description

This function generates inter-item covariance matrices from a population matrix and computes a coefficient alpha reliability estimate for each matrix.

Usage

simulate_alpha(
  item_mat = NULL,
  alpha = NULL,
  k_items = NULL,
  n_cases,
  k_samples,
  standarized = FALSE
)

Value

A vector of simulated sample alpha coefficients

Arguments

item_mat

Item correlation/covariance matrix. If item_mat is not supplied, the user must supply both alpha and k_items. If item_mat is NULL, the program will assume that all item intercorrelations are equal.

alpha

Population alpha value. Must be supplied if item_mat is NULL.

k_items

Number of items on the test to be simulated. Must be supplied if item_mat is NULL.

n_cases

Number of cases to simulate in sampling distribution of alpha.

k_samples

Number of samples to simulate.

standarized

Should alpha be computed from correlation matrices (TRUE) or unstandardized covariance matrices (FALSE)?

Examples

Run this code
## Define a hypothetical matrix:
item_mat <- reshape_vec2mat(cov = .3, order = 12)

## Simulations of unstandardized alphas
set.seed(100)
simulate_alpha(item_mat = item_mat, n_cases = 50, k_samples = 10, standarized = FALSE)
set.seed(100)
simulate_alpha(alpha = mean(item_mat[lower.tri(item_mat)]) / mean(item_mat),
k_items = ncol(item_mat), n_cases = 50, k_samples = 10, standarized = FALSE)

## Simulations of standardized alphas
set.seed(100)
simulate_alpha(item_mat = item_mat, n_cases = 50, k_samples = 10, standarized = TRUE)
set.seed(100)
simulate_alpha(alpha = mean(item_mat[lower.tri(item_mat)]) / mean(item_mat),
k_items = ncol(item_mat), n_cases = 50, k_samples = 10, standarized = TRUE)

Run the code above in your browser using DataLab