# How to create a Cox proportional-hazards model with count data and proportions?

Suppose I have data with the following format:

Date_DMY    age_bracket   Num_Infected  Total_Infected  Total_Prop_Infected
1/1/2000    30-39         1             1               0.0524
2/1/2000    30-39         2             3               0.1149
3/1/2000    20-29         3             6               0.1657
3/1/2000    30-39         2             9               0.2299
.
.
.
5/12/2000   20-29         1             228             0.7243
6/12/2000   40-49         1             229             0.7755
6/12/2000   20-29         1             230             0.7786
7/12/2000   20-29         1             231             0.7900


There are packages in R which utilize binary variables to perform cox regressions (such as the survival and survminer package), however I only have counts, a cumulative total and a cumulative proportions.

How can I create a Cox proportional hazards model with this data using age_bracket as a covariate? My aim is to evaluate a hazard ratio for the age brackets.

• I am not sure why you want to reinvent the wheel , estimating cox proportional hazard based on partial likelihood is a complex process. Even if you succeed you cannot be sure because how you handle ties further complicates this process. I would recommend you go through the concepts in book 1) Survival Analysis by Kleinbaum & Klien or 2) Survival Analysis by Terry M Therneau , both are excellent guide. Jan 1 at 4:02

The Total_Infected and Total_Prop_Infected seem to represent the entire population rather than a breakdown by age_bracket, so they won't be directly useful for a Cox model.

If there is at most one infection per individual, the simplest way to proceed is to make a separate row for each individual. For example, for this data row:

Date_DMY    age_bracket   Num_Infected  Total_Infected  Total_Prop_Infected
.
.
3/1/2000    20-29         3             6               0.1657
.
.


you make 3 copies with the same Date_DMY, age_bracket, an indicator that there was an event on that date, and any other covariate values of interest.

For a proper survival model, however, you also have to keep track of those who were at risk and didn't have an event. They would be represented by the correct number of extra rows with age_bracket, Date_DMY of the last follow-up date, an indicator that there was NO event on that date, and any other covariate values of interest.