Rplus: Generate a random R matrix with all rij > 0

View source: R/Rplus.R

RplusR Documentation

Generate a random R matrix with all rij > 0

Description

Rplus(Seed, NVar = NULL, rdist = NULL, param1 = NULL, param2 = NULL, s = NULL)

Usage

Rplus(Seed, NVar = NULL, rdist = NULL, param1 = NULL, param2 = NULL, s = NULL)

Arguments

Seed

(scalar) A seed for the random number generator. If Seed = NULL then the program will generate a random seed.

NVar

(integer) The order of the generated correlation (R) matrix.

rdist

(character) A one or two letter character string that determines the distribution for the elements of the Cholesky factor of the randomly generated covariance matrix. Possible values include

  • B Beta(param1, param2)

  • X Chisq(param1

  • E Exponential(param1)

  • F F(param1, param2)

  • G Gamma(param1, param2)

  • IB Inverse Beta(param1, param2)

  • IX Inverse Chisq(param1)

  • LN Log Normal(param1, param2)

  • U Uniform(param1, param2)

  • W Weibull(param1, param2)

param1

(scalar). The first parameter of rdist.

param2

(scalar). The second parameter of rdist

s

(scalar). An optional scalar s \in [0,1] that scales the generated correlations by a factor of s. Default (s = NULL). If s is supplied then no correlations in R will be larger than s.

Value

  • R The generated R matrix.

  • NVar The order of R.

  • rdist The user-supplied character strong for rdist,

  • param1 The first parameter of rdist.

  • param2 The possible second parameter of rdist.

  • s The user-supplied scaling factor.

  • Seed the starting value for the random number generator.

Author(s)

Niels G. Waller

Examples

 # --- Example 1: Generate two random R with positive rij ----
 R = Rplus(Seed = 123,  
           NVar = 6,  
           rdist =  "F",  
           param1 = 2.5,  
           param2 = 25,
           s = .8)$R

 R |> round(2)

R = Rplus(Seed = 456,  
          NVar = 6,  
          rdist =  "F",  
          param1 = 2.5,  
          param2 = 25,
          s = .8)$R
       
 R |> round(2)   


fungible documentation built on April 7, 2026, 9:06 a.m.