I am curious on how to replicate the results of a Cox model estimated in Stata in R. I get completely different results, and I think I understand why (but I am unsure of how to fix it), but before I discuss that, I will present a glimpse of the data I am working with along with the simplified syntax to illustrate my problem.
"Failure" denotes an instance of a country experiencing conflict recurrence (this is just dummy data here so its not accurate) and "peace_sp_id" is a unique numeric ID value for a spell of peace. So now, I will run a model in both Stata and R (with the real data), provide the syntax and model outputs:
Stata:
stset year, id(peace_sp_id) failure(failure)
stcox GDP
R:
coxm1 <- coxph(Surv(year, failure) ~ GDP, data = chapter1data)
coxm1
A big difference that I notice is that I'm not sure how to recreate the id(peace_sp_id)
aspect in R. This is important since each row in this data set is not an independent observation from the other. Is there a way to re-create the "multiple-record ID variable" option in R that Stata provides?
cluster
function in the coxph formula. $\endgroup$