I want to evaluate an exponential risk model with one predictor in R. For some reason, I get coefficients with opposite signs when I evaluate them with glm poisson with an offset of log t, and when I just use the survival stop function. I am sure that the explanation is quite obvious, but I cannot understand it.
Example
t <- c(89,74,23,74,53,3,177,44,28,43,25,24,31,111,57,20,19,137,45,48,9,17,4,59,7,26,180,56,36,51,6,71,23,6,13,28,16,180,16,25,6,25,4,5,32,94,106,1,69,63,31) d <- c(0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,0,1,0,1,1,1,0,1,0,1,1,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1) p <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1) df <- data.frame(d,t,p) # exponential hazards model using poisson with offest log(t) summary(glm(d ~ offset(log(t)) + p, data = df, family = "poisson"))
It produces:
Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -5.3868 0.7070 -7.619 2.56e-14 *** p 1.3932 0.7264 1.918 0.0551 .
Compared with
# exponential hazards model using survreg exponential require(survival) summary(survreg(Surv(t,d) ~ p, data = df, dist = "exponential"))
It produces:
Value Std. Error zp (Intercept) 5.39 0.707 7.62 2.58e-14 p -1.39 0.726 -1.92 5.51e-02
Why are the coefficients in opposite directions and how will I interpret the results as they stand? Thanks!