simPreg simulates pregnancy data in a time-to-event
framework with a time-varying exposure. The package allows users to
specify gestational hazard rates and hazard ratios for pregnancy
outcomes and exposure.
The development version of simPreg can be installed from
GitHub:
# install.packages("remotes")
remotes::install_github("YOUR-USERNAME/simPreg")library(simPreg)
# Simulate pregnancy outcome proportions using the default hazard vectors
data.prop <- simPregProp()
# Sample 1000 pregnancies from the simulated proportions
data.samp <- simPregSamp(data.prop, 1000)
# Specify a hazard ratio of 2 for spontaneous and non-spontaneous
# live birth through gestational day 258
hr <- rep(1, 301)
hr[1:258] <- 2
data.prop <- simPregProp(
hr.spont.livebirth = hr,
hr.nonspont.livebirth = hr
)