# Part 10 simulated survival dataset

This download accompanies Part 10, *Survival and Time-to-Event Analysis*, in the NajibMY Biostatistics Learning Hub.

## Important disclaimer

The dataset is entirely simulated for teaching. It contains no real patients, clinical records, or identifiable information. Its values must not be interpreted as evidence about an actual treatment, population, or healthcare service.

The deterministic simulation is designed to illustrate censoring, Kaplan–Meier estimation, log-rank testing, Cox regression, proportional-hazards assessment, and competing-risk analysis. It is not intended to reproduce all features of real clinical survival data.

## Files

- `part-10-simulated-survival-data.csv`: the simulated participant-level dataset.
- `generate-part-10-simulated-survival-data.R`: standalone base-R code that recreates the CSV.

## Coding definitions

- `group`: `0` = usual care; `1` = intervention.
- `stage3`: `0` = stage II; `1` = stage III.
- `overall_event`: `0` = right-censored; `1` = death observed.
- `competing_status`: `0` = right-censored; `1` = recurrence; `2` = death without recurrence.
- All time variables are measured in months from treatment allocation.
- Administrative follow-up ends at 36 months. Some participants are censored earlier by simulated dropout.

## Data dictionary

| Variable | Type | Description |
| --- | --- | --- |
| `id` | Integer | Simulated participant identifier, 1–240. |
| `group` | Integer | Randomised group code: 0 = usual care; 1 = intervention. |
| `group_label` | Text | Human-readable group label. |
| `age` | Integer | Simulated baseline age in years. |
| `stage3` | Integer | Baseline disease-stage indicator: 0 = stage II; 1 = stage III. |
| `overall_time` | Numeric | Observed time to death or right censoring, in months. |
| `overall_event` | Integer | Overall-survival endpoint indicator: 0 = censored; 1 = death. |
| `competing_time` | Numeric | Observed time to recurrence, death without recurrence, or censoring, in months. |
| `competing_status` | Integer | First-event code: 0 = censored; 1 = recurrence; 2 = death without recurrence. |
| `recurrence_time_latent` | Numeric | Simulated time at which recurrence would occur if not precluded by another event or censoring. |
| `nonrecurrence_death_time_latent` | Numeric | Simulated time at which death without prior recurrence would occur if not precluded by recurrence or censoring. |
| `censor_time` | Numeric | Simulated administrative or dropout censoring time, in months. |

## Latent-time variables

The two columns ending in `_latent` expose internal quantities used by the simulation. They are supplied so learners can understand and reproduce how the competing events were generated.

These latent times would not both be observable for a real participant. Once recurrence, death, or censoring occurs, later counterfactual event times are unknown. Do not include the latent-time columns as predictors or observed outcomes in the worked analyses. Use `overall_time` with `overall_event`, or `competing_time` with `competing_status`, as appropriate.

## Regenerating the dataset

The script uses base R and requires no additional packages. From a terminal in this directory, run:

```text
Rscript generate-part-10-simulated-survival-data.R
```

To choose another output location, supply it as the first argument:

```text
Rscript generate-part-10-simulated-survival-data.R path/to/output.csv
```

The generated values are deterministic: running the script again produces the same simulated data, subject only to harmless differences in printed numeric precision between R versions.
