I am trying to simulate a AFT Weibull model in R using a log-linear model
\begin{align} log(Y)=\beta_0 +\beta_1 X1+\beta_2 X2+c W \end{align} where $W ~$ a extreme value distribution. below is my simulation code:
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
#####
I can not understand why intercept is 2.94, not close to 1 ?
Thanks for the help from EDM. R Gumbel and extreme value functions are all for maximum extreme value distribution
\begin{align} f(x)=e^{(-x-e^{-x})} \end{align}
What we really need is a random variable from the minimum extreme value distribution with density function like this \begin{align} f(x)=e^{(x-e^{x})} \end{align}
Once I generate the error from a maximum extreme value distribution, I need to set it to -1*error.
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")
Coefficients:
(Intercept) x1 x2
1.000095 0.500679 -1.200210
Scale fixed at 1
time
? $\endgroup$revd()
, as that function doesn't seem to be in base R. There's both a maximum and a minimum extreme value distribution; make sure you're using the correct one. $\endgroup$