simPregProp: Simulate distributions of pregnancy outcomes and gestational...

View source: R/simPregProp.R

simPregPropR Documentation

Simulate distributions of pregnancy outcomes and gestational duration

Description

Calculates proportions of pregnancies experiencing spontaneous live birth, non-spontaneous live birth, or late miscarriage/stillbirth by gestational age and timing of exposure, given daily hazard rates and hazard ratios.

Usage

simPregProp(
  haz.spont.livebirth = haz.spont.livebirth.default,
  haz.nonspont.livebirth = haz.nonspont.livebirth.default,
  haz.late.miscarriage.stillbirth = haz.late.miscarriage.stillbirth.default,
  haz.exposure = haz.exposure.default,
  hr.spont.livebirth = NULL,
  hr.nonspont.livebirth = NULL,
  hr.late.miscarriage.stillbirth = NULL
)

Arguments

haz.spont.livebirth

Numeric vector of daily hazards of spontaneous live birth. Defaults to the package-provided haz.spont.livebirth.default vector of length 301.

haz.nonspont.livebirth

Numeric vector of daily hazards of non-spontaneous live birth. Defaults to the package-provided haz.nonspont.livebirth.default vector of length 301.

haz.late.miscarriage.stillbirth

Numeric vector of daily hazards of late miscarriage/stillbirth. Defaults to the package-provided haz.late.miscarriage.stillbirth.default vector of length 301.

haz.exposure

Numeric vector of daily hazards of exposure. Defaults to the package-provided haz.exposure.default vector of length 301.

hr.spont.livebirth

Numeric vector of hazard ratios for spontaneous live birth following exposure. Must have the same length as the hazard vectors. Defaults to NULL, corresponding to no effect of exposure on the hazard.

hr.nonspont.livebirth

Numeric vector of hazard ratios for non-spontaneous live birth following exposure. Must have the same length as the hazard vectors. Defaults to NULL, corresponding to no effect of exposure on the hazard.

hr.late.miscarriage.stillbirth

Numeric vector of hazard ratios for late miscarriage/stillbirth following exposure. Must have the same length as the hazard vectors. Defaults to NULL, corresponding to no effect of exposure on the hazard.

Value

A data frame with class preg.prop containing the following columns:

GA

Gestational age in days.

ExpGA

Gestational age at exposure. NA indicates no exposure.

Outcome

Pregnancy outcome: spontaneous_live_birth, nonspontaneous_live_birth, or late_miscarriage_stillbirth.

Prop

Proportion of pregnancies corresponding to the gestational age, exposure timing, and outcome combination.

Examples

# Use the package-provided default hazard vectors
data.prop <- simPregProp()
head(data.prop)

# Illustrate an exposure associated with increased risk of preterm live birth
hr <- rep(1, 301)
hr[1:258] <- 2
data.prop <- simPregProp(
  hr.spont.livebirth = hr,
  hr.nonspont.livebirth = hr
)


simPreg documentation built on Sept. 27, 2026, 5:06 p.m.