createMCAR: Missing Completely at Random

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function adds (or modifies) a "MISSING" flag to a dataset to simulate a missing completely at random behaviour.

Usage

1
2
3
4
5
createMCAR(data, 
  prop = 0, 
  rule, 
  seed = .deriveFromMasterSeed(), 
  flagName = getEctdColName("Missing"))

Arguments

data

(Required) Data frame to which to add missingness

prop

(Optional) proportion of missingness between 0 and 1. The default is "0" (so no missingness is generated)

rule

(Optional) Only observations matching the rule can be flagged as missing. Be default, all observations are available to be missing

seed

(Optional) Random seed to use. Based on the current random seed by default

flagName

(Optional) name of the missing flag ("MISSING" by default)

Details

The missing data is either added to the dataset or modified if it already exist. In the latter case, the function only overwrites data that is not already missing.

Value

the data argument to which a MISSING flag is added or modified.

Author(s)

Mike K Smith mstoolkit@googlemail.com

See Also

createDropout for drop out missingness.

parseRangeCode to handle the rule argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  
myData <- data.frame( 
  SUBJ   = rep(1:3, each = 3), 
  TIME = rep(0:2, 3)  ) 
createMCAR( myData, prop = 0.1, rule = "TIME > 0")  

## Not run: 
 ## more examples in the unit tests
 file.show( system.file( "Runit", "runit.data.missing.R" , package = "MSToolkit") ) 

## End(Not run)

MSToolkit documentation built on May 2, 2019, 6:30 p.m.