artifNA: Introduce MCAR Missing Values in a matrix

Description Usage Arguments Value Examples

Description

This function artificially introduces missing values in a data matrix under missing completely at random (MCAR) mechanism.

Usage

1
artifNA(x, miss.prop = 0.1)

Arguments

x

a matrix, in which missing values are to be created.

miss.prop

proportion of missing values

Value

a matrix with missing values

Examples

1
2
3
4
 set.seed(3)
 x = matrix(rnorm(100),10,10)
 ## create 10% missing values in x
 artifNA(x, 0.10)

Example output

             [,1]       [,2]        [,3]        [,4]       [,5]       [,6]
 [1,] -0.96193342 -0.7447816 -0.57848372  0.90062473  0.7865069  0.7268389
 [2,] -0.29252572 -1.1312186 -0.94230073  0.85177045 -0.3104631 -0.8094409
 [3,]          NA -0.7163585 -0.20372818  0.72771517  1.6988848  0.2670851
 [4,] -1.15213189  0.2526524 -1.66647484          NA -0.7945937 -1.7372637
 [5,]  0.19578283  0.1520457 -0.48445511 -0.35212962  0.3484377 -1.4114251
 [6,]  0.03012394 -0.3076564 -0.74107266  0.70551551 -2.2654011 -0.4535512
 [7,]  0.08541773 -0.9530173  1.16061578          NA -0.1622053 -1.0354913
 [8,]  1.11661021 -0.6482428  1.01206712  0.03825201         NA  1.3621429
 [9,] -1.21885742  1.2243136 -0.07207847 -0.97928377 -0.4555460  0.9174567
[10,]  1.26736872  0.1998116 -1.13678230  0.79376123 -0.8991663 -0.7851422
            [,7]       [,8]       [,9]       [,10]
 [1,]  0.5735182 -0.0313255  1.7355352 -0.85381845
 [2,]  0.9181962  0.4670973         NA -0.98999433
 [3,]  0.2562873  1.0241977  0.6886400 -0.65087774
 [4,]         NA         NA  1.2244061  1.05394666
 [5,]  1.1743374  0.2318261  0.7942963 -0.39087803
 [6,] -0.4808464  0.7475925         NA -0.07058639
 [7,] -0.4188297  1.2170685  0.2191506 -0.46205081
 [8,]  0.9551128         NA -0.8864638  0.54090827
 [9,]         NA -0.9880528  0.4397603  0.93163497
[10,]  0.1861974 -0.1568529 -0.8863898 -0.20927435

wNNSel documentation built on May 2, 2019, 2:49 p.m.