sim_lod()
simulates putting the columns of a given matrix D
under a limit
of detection (LOD) by calculating the given quantile q
of each column and
corrupting all values < the quantile to NA
, returning the newly corrupted
matrix, the binary corruption mask, and a vector of column LODs.
Arguments
- D
The input data matrix.
- q
A double in the range
[0, 1]
specifying the quantile to use in creating the column-wise LODs. Passed as theprobs
argument to thequantile()
function.
Value
A list containing:
D_tilde
: The original matrixD
corrupted with < LODNA
values.tilde_mask
: A binary matrix ofdim(D)
specifying the locations of corrupted entries (1
) and uncorrupted entries (0
).lod
: A vector withlength(lod) == ncol(D)
providing the simulated LOD values corresponding to each column in theD_tilde
.
Examples
D <- sim_data(5, 5, sigma = 0.8)$D
D
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 2.9302635 0.8938987 0.7291769 0.8853122 0.06966197
#> [2,] 1.4584989 1.0828959 1.3333332 1.3004826 1.15159124
#> [3,] -1.6146424 0.9188127 0.6471552 1.2856310 0.42002327
#> [4,] -0.4990438 1.9652499 1.3747700 1.0188214 -0.67200285
#> [5,] 2.4033674 2.6339801 0.7118914 0.9998089 2.31177279
sim_lod(D, q = 0.2)
#> $D_tilde
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 2.9302635 NA 0.7291769 NA 0.06966197
#> [2,] 1.4584989 1.0828959 1.3333332 1.3004826 1.15159124
#> [3,] NA 0.9188127 NA 1.2856310 0.42002327
#> [4,] -0.4990438 1.9652499 1.3747700 1.0188214 NA
#> [5,] 2.4033674 2.6339801 0.7118914 0.9998089 2.31177279
#>
#> $tilde_mask
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0 1 0 1 0
#> [2,] 0 0 0 0 0
#> [3,] 1 0 1 0 0
#> [4,] 0 0 0 0 1
#> [5,] 0 0 0 0 0
#>
#> $lod
#> [1] -0.72216355 0.91382991 0.69894415 0.97690956 -0.07867099
#>