grain-simulate.Rd
Simulate data from an independence network.
# S3 method for class 'grain'
simulate(object, nsim = 1, seed = NULL, ...)
A data frame
Søren Højsgaard (2012). Graphical Independence Networks with the gRain Package for R. Journal of Statistical Software, 46(10), 1-26. https://www.jstatsoft.org/v46/i10/.
tf <- system.file("huginex", "chest_clinic.net", package = "gRain")
chest <- loadHuginNet(tf, details=1)
simulate(chest,n=10)
#> Hasbronchitis Dyspnoea VisittoAsia Smoker Hastuberculosis Haslungcancer
#> 1 no no no no no no
#> 2 no no no yes no no
#> 3 no yes no no no no
#> 4 no no no no no no
#> 5 no no no yes no no
#> 6 no no no no no no
#> 7 yes yes no no no no
#> 8 yes yes no yes no no
#> 9 yes yes no yes no no
#> 10 yes yes no yes no no
#> Tuberculosisorcancer PositiveXray
#> 1 no no
#> 2 no no
#> 3 no no
#> 4 no no
#> 5 no no
#> 6 no no
#> 7 no no
#> 8 no yes
#> 9 no no
#> 10 no no
chest2 <- setFinding(chest, c("VisitToAsia", "Dyspnoea"),
c("yes", "yes"))
simulate(chest2, n=10)
#> Hasbronchitis Dyspnoea VisittoAsia Smoker Hastuberculosis Haslungcancer
#> 1 yes yes no yes no no
#> 2 yes yes no yes no no
#> 3 yes yes no yes no no
#> 4 yes yes no yes no no
#> 5 yes yes no yes no no
#> 6 yes yes no no no no
#> 7 yes yes no yes no no
#> 8 yes yes no yes no no
#> 9 yes yes no yes no no
#> 10 yes yes no yes no no
#> Tuberculosisorcancer PositiveXray
#> 1 no no
#> 2 no no
#> 3 no no
#> 4 no no
#> 5 no no
#> 6 no yes
#> 7 no no
#> 8 no no
#> 9 no no
#> 10 no no