Learn R Programming

psychmeta (version 2.3.4)

simulate_matrix: Generate a list of simulated sample matrices sampled from the Wishart distribution

Description

This function generates simulated sample matrices based on a population matrix and a sample size. It uses the Wishart distribution (i.e., the multivariate \(\chi^2\) distribution) to obtain data, rescales the data into the input metric, and can be standardized into a correlation matrix by setting as_cor to TRUE. The function can produce a list of matrices for any number of samples.

Usage

simulate_matrix(sigma, n, k = 1, as_cor = FALSE)

Arguments

sigma

Population covariance matrix. May be standardized or unstandardized.

n

Sample size for simulated sample matrices.

k

Number of sample matrices to generate.

as_cor

Should the simulated matrices be standardized (TRUE) or unstandardized (FALSE)?

Value

A list of simulated sample matrices.

Examples

Run this code
# NOT RUN {
## Define a hypothetical matrix:
sigma <- reshape_vec2mat(cov = .4, order = 5)

## Simualte a list of unstandardized covariance matrices:
simulate_matrix(sigma = sigma, n = 50, k = 10, as_cor = FALSE)

## Simualte a list of correlation matrices:
simulate_matrix(sigma = sigma, n = 50, k = 10, as_cor = TRUE)
# }

Run the code above in your browser using DataLab