---
title: "Event Prediction after Enrollment Completion"
author: "Kaifeng Lu"
date: "2025-02-27"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Event Prediction after Enrollment Completion}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(eventPred)
```

We analyzed interim event data from the interimData2 dataset within the eventPred package. As of the cutoff date of October 1, 2020, all 300 patients had been enrolled, and 183 patients had experienced the event of interest (with a target of 200 events).

A Weibull distribution was employed to model the time to event. An exponential distribution was used to model the time to dropout.


```{r}
set.seed(2000)

pred <- getPrediction(
  df = interimData2,
  to_predict = "event only",
  target_d = 200,
  event_model = "weibull",
  dropout_model = "exponential",
  pilevel = 0.90, 
  nyears = 1,
  nreps = 500)
```

The median predicted date to reach 200 events is March 8, 2021. The 90% prediction interval for event completion is much narrower, ranging from January 12, 2021 to May 20, 2021, indicating reduced uncertainty in the prediction attributed to the greatly increased number of events.

Based on the finalData dataset within the eventPred package, the actual date to reach the 200 events was February 14, 2021. The increased number of events greatly improved the prediction accuracy and precision.

