I am attempting to reproduce some survival analysis results published in a journal. The original results were produced in Stata. Here is the code:
* COUPS
gen c_coup=c
replace c_coup=0 if exit!="coup"
stset time, id(leadid) failure(c_coup)
* REVOLT ENTRY LEFT OUT BECAUSE IT IS A PERFECT PREDICTOR
streg legislature leg_growth_2 gdp_1k chgdpen_fearonlaitin Oil_fearonlaitin postcoldwarlag civiliandictatorshiplag militarydictatorshiplag communist lpopl1_fearonlaitin ethfrac_fearonlaitin relfrac_fearonlaitin age, distribution(weibull) time
outreg2 using survival, replace ctitle(coups, partial) tex nonotes bdec(3) e(all)
stcurve, hazard
I ran the code in Stata and the results are identical to those in the published manuscript. I am now trying to reproduce them in R, but I have had no luck. The results are off by quite a bit, suggesting that the differences are not due to using R as opposed to Stata. Here is the R code I wrote:
# load required libraries
library(survival)
library(haven)
# load data
leader_tvc_2 <- read_dta("leader_tvc_2.dta", encoding = "latin1")
# create survival object
surv_obj_coup <-
Surv(time = leader_tvc_2$time, event = leader_tvc_2$c_coup)
# fit a survival regression model in R
surv_model <- survreg(
surv_obj_coup ~ legislature + leg_growth_2 + gdp_1k + chgdpen_fearonlaitin + Oil_fearonlaitin + postcoldwarlag + civiliandictatorshiplag + militarydictatorshiplag + communist + lpopl1_fearonlaitin + ethfrac_fearonlaitin + relfrac_fearonlaitin + age,
data = leader_tvc_2,
dist = "weibull"
)
# summarize results
summary(surv_model)
Does anyone know why I am not getting roughly the same results? Am I not implementing the Stata code correctly in R? Any advice would be appreciated! Thanks.