generate.matrix {abess}R Documentation

Generate matrix composed of a sparse matrix and low-rank matrix

Description

Generate simulated matrix that is the superposition of a low-rank component and a sparse component.

Usage

generate.matrix(
  n,
  p,
  rank = NULL,
  support.size = NULL,
  beta = NULL,
  snr = Inf,
  sigma = NULL,
  seed = 1
)

Arguments

n

The number of observations.

p

The number of predictors of interest.

rank

The rank of low-rank matrix.

support.size

The number of nonzero coefficients in the underlying regression model. Can be omitted if beta is supplied.

beta

The coefficient values in the underlying regression model. If it is supplied, support.size would be omitted.

snr

A positive value controlling the signal-to-noise ratio (SNR). A larger SNR implies the identification of sparse matrix is much easier. Default snr = Inf enforces no noise exists.

sigma

A numerical value supplied the variance of the gaussian noise. Default sigma = NULL implies it is determined by snr.

seed

random seed. Default: seed = 1.

Details

The low rank matrix LL is generated by L=UVL = UV, where UU is an nn-by-rankrank matrix and VV is a rankrank-by-pp matrix. Each element in UU (or VV) are i.i.d. drawn from N(0,1/n)N(0, 1/n).

The sparse matrix SS is an nn-by-rankrank matrix. It is generated by choosing a support set of size support.size uniformly at random. The non-zero entries in SS are independent Bernoulli (-1, +1) entries.

The noise matrix NN is an nn-by-rankrank matrix, the elements in NN are i.i.d. gaussian random variable with standard deviation σ\sigma.

The SNR is defined as as the variance of vectorized matrix L+SL + S divided by σ2\sigma^2.

The matrix xx is the superposition of LL, SS, NN:

x=L+S+N.x = L + S + N.

Value

A list object comprising:

x

An nn-by-pp matrix.

L

The latent low rank matrix.

S

The latent sparse matrix.

Author(s)

Jin Zhu

Examples

# Generate simulated data
n <- 30
p <- 20
dataset <- generate.matrix(n, p)

stats::heatmap(as.matrix(dataset[["S"]]),
  Rowv = NA,
  Colv = NA,
  scale = "none",
  col = grDevices::cm.colors(256),
  frame.plot = TRUE,
  margins = c(2.4, 2.4)
)


[Package abess version 0.4.8 Index]