genMiss: Generate missing data

Description Usage Arguments Value See Also Examples

View source: R/genMiss.R

Description

Generate missing data

Usage

1
2
genMiss(dtName, missDefs, idvars, repeated = FALSE,
  periodvar = "period")

Arguments

dtName

Name of complete data set

missDefs

Definitions of missingness

idvars

Index variables

repeated

Indicator for longitudinal data

periodvar

Name of variable that contains period

Value

Missing data matrix indexed by idvars (and period if relevant)

See Also

defMiss, genObs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def1 <- defData(varname = "m", dist = "binary", formula = .5)
def1 <- defData(def1, "u", dist = "binary", formula = .5)
def1 <- defData(def1, "x1", dist="normal", formula = "20*m + 20*u", variance = 2)
def1 <- defData(def1, "x2", dist="normal", formula = "20*m + 20*u", variance = 2)
def1 <- defData(def1, "x3", dist="normal", formula = "20*m + 20*u", variance = 2)

dtAct <- genData(1000, def1)

defM <- defMiss(varname = "x1", formula = .15, logit.link = FALSE)
defM <- defMiss(defM, varname = "x2", formula = ".05 + m * 0.25", logit.link = FALSE)
defM <- defMiss(defM, varname = "x3", formula = ".05 + u * 0.25", logit.link = FALSE)
defM <- defMiss(defM, varname = "u", formula = 1, logit.link = FALSE) # not observed
defM

# Generate missing data matrix

missMat <- genMiss(dtAct, defM, idvars = "id")
missMat

# Generate observed data from actual data and missing data matrix

dtObs <- genObs(dtAct, missMat, idvars = "id")
dtObs

kgoldfeld/simstudy documentation built on Nov. 8, 2018, 7:41 p.m.