Skip to content

Simulating a Weibull regression model

2 messages · duo wan, Mark Clements

#
HI All,I am trying to simulate a AFT Weibull model in R using a log-linear mod
log(Y)=?0+?1X1+?2X2+cW


Where W is a extreme value distribution. My R code is below. I can not understand why the intercept estimate is 2.94, not lose to 1?? Thanks,?
Vincent

install.packages("extRemes")
library(extRemes)

n<-500000    
x1<-rnorm(n,0,1)    
x2<-rnorm(n,0,1)    
error<-revd(n, loc = 0, scale = 1)    
b0<- 1    
b1<-0.5    
b2<--1.2    
c<-1    
time<-exp(b0+b1*x1+b2*x2+c*error)    
status<-rep(1,n)    
survreg(Surv(time, status==1) ~ x1+x2,dist="exponential")

####output 

Coefficients:    
(Intercept)          x1          x2 

  2.9390956   0.4931199  -1.2061369 

Scale fixed at 1 
#####
#
If you use

time<-exp(b0+b1*x1+b2*x2-c*error) # or
time<-rexp(n, rate=1/exp(b0+b1*x1+b2*x2)) # or
time<-rweibull(n, shape=c, scale=exp(b0+b1*x1+b2*x2))

then you could model using

survreg(Surv(time, status==1) ~ x1+x2,dist="exponential") # or
survreg(Surv(time, status==1) ~ x1+x2,dist="weibull")

-- Mark