Suppose we have the following dataset that records individual survival times (dur) and a covariate z:
id| dur | z
-------------
1 | 1 | -1
2 | 2 | 1
3 | 3 | -1
4 | 4 | 1
I want to model the duration as a function of z. I may specify dur ~ weibull() and parameterize the scale as a function of z. This model can be fitted easily, e.g. with phreg or survreg in R.
If I am now interested to incorporate time-dependent covariates, I need to transform the dataset into something like this:
id | event | time | z | orig.row
_____________________________________
1 | 1 | 1 | -1 | 1
2 | 0 | 1 | 1 | 2
2.1| 1 | 2 | 1 | 2
3 | 0 | 1 |-1 | 3
3.1| 0 | 2 |-1 | 3
3.2| 1 | 3 |-1 | 3
4 | 0 | 1 | 1 | 4
4.1| 0 | 2 | 1 | 4
4.2| 0 | 3 | 1 | 4
4.3| 1 | 4 | 1 | 4
Apparently, a to say event ~ poisson() with a "poisson mean" $$\log(u_i) = \beta_0 + \alpha \log(t_i) + \beta_1 z_i$$ is equivalent to a the Weibull model above (Lindsey 1995). But when I run the analysis in R, I get two largely different values for the scale:
# Generate the data:
library(eha)
enter <- rep(0, 4)
exit <- 1:4
event <- rep(1, 4)
z <- rep(c(-1, 1), 2)
dat <- data.frame(enter, exit, event, z)
binDat <- toBinary(dat)
binDat <- binDat[order(rownames(binDat)),]
# Run the model:
summary(phreg(Surv(enter,exit, event) ~ z, data = dat, dist="weibull"))
summary(glm(event ~ z + log(risktime), data = binDat, family = poisson("log")))
The shape parmeter (glm: log(risktime)) is sort of similar as well as the beta for z. But the scale parameter is different (glm: Intercept). What am I doing wrong?
## Results
summary(phreg(Surv(enter,exit, event) ~ z, data = dat, dist="weibull"))
Call:
phreg(formula = Surv(enter, exit, event) ~ z, data = dat, dist = "weibull")
Covariate W.mean Coef Exp(Coef) se(Coef) Wald p
z 0.200 -0.432 0.649 0.519 0.406
log(scale) 1.020 2.774 0.197 0.000
log(shape) 0.985 2.677 0.421 0.019
Events 4
Total time at risk 10
Max. log. likelihood -5.6567
LR test statistic 0.68
Degrees of freedom 1
Overall p-value 0.410367
summary(glm(event ~ z + log(risktime), data = binDat, family = poisson("log")))
Call:
glm(formula = event ~ z + log(risktime), family = poisson("log"),
data = binDat)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.0696 -0.7695 -0.5391 0.3482 1.0671
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.6122 1.0019 -1.609 0.108
z -0.3166 0.5149 -0.615 0.539
log(risktime) 1.0634 1.0928 0.973 0.330
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 7.3303 on 9 degrees of freedom
Residual deviance: 6.1388 on 7 degrees of freedom
AIC: 20.139
Number of Fisher Scoring iterations: 5