Skip to contents

The rdasim2 function generates simulated data for Ridge Redundancy Analysis (RDA) with adjustable signal-to-noise ratio and covariance structure for X. The data matrix Y is created by a low-rank model, where the rank is set by the product of two matrices A and C corresponding to the number of latent variables (k). The function allows control over the signal-to-noise ratio (s2n) and off-diagonal elements of the covariance matrix for X (xofd). It returns a list containing the matrices X, Y, the regression coefficient matrix B (obtained as the product of A and C), and the error matrix E.

Usage

rdasim2(n, p, q, k, s2n = 5, xofd = 0)

Arguments

n

The number of samples.

p

The number of variables of X.

q

The number of variables of Y.

k

The number of latent variables.

s2n

The numeric parameter of signal to noise ratio, default value is 5.

xofd

The numeric parameter of the off-diagnal elements of covariance matrix of X, default is 0.

Value

A list containing matrices X, Y, B, E.

Examples

# Example usage of rdasim2
set.seed(10)
sim_data2 <- rdasim2(n = 10, p = 5, q = 3, k = 2)
str(sim_data2)
#> List of 4
#>  $ X: num [1:10, 1:5] 1.087 -0.763 -0.829 0.834 -0.968 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : NULL
#>   .. ..$ : NULL
#>  $ Y: num [1:10, 1:3] -0.6956 0.7462 1.4538 0.4088 -0.0279 ...
#>  $ B: num [1:5, 1:3] -0.0402 0.3284 -0.6099 -0.6098 -0.2473 ...
#>  $ E: num [1:10, 1:3] 0.27 -0.176 0.206 -0.457 0.14 ...