Plot time-to-event

plotTimeToEvent(cohortMethodData, population = NULL, outcomeId,
  firstExposureOnly = FALSE, restrictToCommonPeriod = FALSE,
  washoutPeriod = 0, removeDuplicateSubjects = FALSE,
  minDaysAtRisk = 1, riskWindowStart = 0,
  addExposureDaysToStart = NULL, startAnchor = "cohort start",
  riskWindowEnd = 0, addExposureDaysToEnd = NULL,
  endAnchor = "cohort end", censorAtNewRiskWindow = FALSE,
  periodLength = 7, numberOfPeriods = 52, showFittedLines = TRUE,
  targetLabel = "Target", comparatorLabel = "Comparator",
  title = NULL, fileName = NULL)

Arguments

cohortMethodData

An object of type cohortMethodData as generated using getDbCohortMethodData.

population

If specified, this population will be used as the starting point instead of the cohorts in the cohortMethodData object.

outcomeId

The ID of the outcome. If not specified, no outcome-specific transformations will be performed.

firstExposureOnly

Should only the first exposure per subject be included? Note that this is typically done in the createStudyPopulation function,

restrictToCommonPeriod

Restrict the analysis to the period when both exposures are observed?

washoutPeriod

The mininum required continuous observation time prior to index date for a person to be included in the cohort.

removeDuplicateSubjects

Remove subjects that are in both the target and comparator cohort? See details for allowed values.

minDaysAtRisk

The minimum required number of days at risk.

riskWindowStart

The start of the risk window (in days) relative to the startAnchor.

addExposureDaysToStart

DEPRECATED: Add the length of exposure the start of the risk window? Use startAnchor instead.

startAnchor

The anchor point for the start of the risk window. Can be "cohort start" or "cohort end".

riskWindowEnd

The end of the risk window (in days) relative to the endAnchor.

addExposureDaysToEnd

DEPRECATED: Add the length of exposure the risk window? Use endAnchor instead.

endAnchor

The anchor point for the end of the risk window. Can be "cohort start" or "cohort end".

censorAtNewRiskWindow

If a subject is in multiple cohorts, should time-at-risk be censored when the new time-at-risk starts to prevent overlap?

periodLength

The length in days of each period shown in the plot.

numberOfPeriods

Number of periods to show in the plot. The periods are equaly divided before and after the index date.

showFittedLines

Fit lines to the proportions and show them in the plot?

targetLabel

A label to us for the target cohort.

comparatorLabel

A label to us for the comparator cohort.

title

Optional: the main title for the plot.

fileName

Name of the file where the plot should be saved, for example 'plot.png'. See the function ggsave in the ggplot2 package for supported file formats.

Value

A ggplot object. Use the ggsave function to save to file in a different format.

Details

Creates a plot showing the number of events over time in the target and comparator cohorts, both before and after index date. The plot also distinguishes between events inside and outside the time-at-risk period. This requires the user to (re)specify the time-at-risk using the same arguments as the createStudyPopulation function. Note that it is not possible to specify that people with the outcome prior should be removed, since the plot will show these prior events.