### Create fake "real" data set - this is the source of the synthetic data
d <- defData(varname = "a", formula = 3, variance = 1, dist = "normal")
d <- defData(d, varname = "b", formula = 5, dist = "poisson")
d <- defData(d, varname = "c", formula = 0.3, dist = "binary")
d <- defData(d, varname = "d", formula = "a + b + 3*c", variance = 2, dist = "normal")
### Create synthetic data set from "observed" data set A (normally this
### would be an actual external data set):
A <- genData(1000, d)
### Generate new simstudy data set (using 'def')
def <- defData(varname = "x", formula = 0, variance = 5)
S <- genData(120, def)
### Create synthetic data from 'A' and add to simulated data in 'S'
S <- addSynthetic(dtOld = S, dtFrom = A, vars = c("b", "d"))
Run the code above in your browser using DataLab