Learn R Programming

eimpute (version 0.2.4)

incomplete.generator: Incomplete data generator

Description

Generate a matrix with missing values, where the indices of missing values are uniformly randomly distributed in the matrix.

Usage

incomplete.generator(m, n, r, snr = 3, prop = 0.5, seed = 1)

Value

A matrix with missing values.

Arguments

m

the rows of the matrix.

n

the columns of the matrix.

r

the rank of the matrix.

snr

the signal-to-noise ratio in generating the matrix. Default snr = 3.

prop

the proportion of missing observations. Default prop = 0.5.

seed

the random seed. Default seed = 1.

Details

We generate the matrix by \(UV + \epsilon\), where \(U\), \(V\) are \(m\) by \(r\), \(r\) by \(n\) matrix satisfy standard normal distribution. \(\epsilon\) has a normal distribution with mean 0 and variance \(\frac{r}{snr}\).

Examples

Run this code
m <- 100
n <- 100
r <- 10
x_na <- incomplete.generator(m, n, r)
head(x_na[, 1:6])

Run the code above in your browser using DataLab