alphaR: Generate random R matrices with a known coefficient alpha

View source: R/alphaR.R

alphaRR Documentation

Generate random R matrices with a known coefficient alpha

Description

alphaR can generate a list of fungible correlation matrices with a user-defined (standardized) coefficient \alpha.

Usage

alphaR(alpha, k, Nmats, SEED)

Arguments

alpha

(numeric) A desired coefficient \alpha within the range \alpha \in (-\infty, 1].

k

(integer). The order of each R (correlation) matrix.

Nmats

(integer) The number of fungible R matrices with a known \alpha. Default (Nmats = 5).

SEED

(numeric) The initial seed for the random number generator. If SEED is not supplied then the program will generate (and return) a randomly generated seed.

Value

  • alpha The desired (standardized) coefficient \alpha.

  • R The initial correlation matrix with a desired coefficient \alpha.

  • Rlist A list with Nmats fungible correlation matrices with a desired coefficient \alpha.

  • SEED The initial value for the random number generator.

Author(s)

Niels G. Waller

References

Waller, N. & Revelle, W. (2023). What are the mathematical bounds for coefficient \alpha? Psychological Methods. doi.org/10.1037/met0000583

Examples


## Function to compute standardized alpha
Alphaz <- function(Rxx){
  k <- ncol(Rxx)
  k/(k-1) * (1 - (k/sum(Rxx)) ) 
}# END Alphaz

## Example 1
## Generate 25 6 x 6 R matrices with a standardized alpha of .85
alpha =  .85   
k = 6
Nmats =  25 
SEED = 1

out = alphaR(alpha, k , Nmats, SEED)
Alphaz(out$Rlist[[1]])

## Example 2
## Generate 25 6 x 6 R matrices with a standardized alpha of -5
alpha =  -5   
k = 6
Nmats =  25 
SEED = 1

out = alphaR(alpha, k , Nmats, SEED) 
Alphaz(out$Rlist[[5]])


fungible documentation built on May 29, 2024, 8:28 a.m.