[R] AFT model time-dependent with weibull distribution

Rui Barradas ruipbarradas at sapo.pt
Sat Aug 4 21:20:06 CEST 2012


Hello,

Vous êtes française?
It shows, in english it would be 'exponential', with an 'a'.

Worked with me, after reading the manual.


dataexp <- read.table(text="
vi      Ti
1  26    5.79
2  26 1579.52
3  26 2323.70
4  28   68.85
[...]
73 38    0.39
74 38    1.13
75 38    0.09
76 38    2.38
", header=TRUE)

#  Better in a post to R-Help is the output of dput()
# It looks like the following line, without the assignment.
  dput(dataexp)
dataexp <-
structure(list(vi = c(26L, 26L, 26L, 28L, 28L, 28L, 28L, 28L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 32L, 32L,
32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 36L, 36L, 36L, 36L, 36L, 36L, 36L,
36L, 36L, 36L, 36L, 36L, 36L, 36L, 36L, 38L, 38L, 38L, 38L, 38L,
38L, 38L, 38L), Ti = c(5.79, 1579.52, 2323.7, 68.85, 426.07,
110.29, 108.29, 1067.6, 17.05, 22.66, 21.02, 175.88, 139.07,
144.12, 20.46, 43.4, 194.9, 47.3, 7.74, 0.4, 82.85, 9.88, 89.29,
215.1, 1.75, 0.79, 15.93, 3.91, 0.27, 0.69, 100.58, 27.8, 13.95,
53.24, 0.96, 4.15, 0.19, 0.78, 8.01, 31.75, 7.35, 6.5, 8.27,
33.91, 32.52, 3.16, 4.85, 2.78, 4.67, 1.31, 12.06, 36.71, 72.89,
1.97, 0.59, 2.58, 1.69, 2.71, 25.5, 0.35, 0.99, 3.99, 3.67, 2.07,
0.96, 5.35, 2.9, 13.77, 0.47, 0.73, 1.4, 0.74, 0.39, 1.13, 0.09,
2.38), status = 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, 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, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), .Names = c("vi",
"Ti", "status"), row.names = c("1", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17",
"18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28",
"29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50",
"51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61",
"62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72",
"73", "74", "75", "76"), class = "data.frame")

##Not run
#install.packages('eha')
library(eha)
library(survival)

dataexp$status <- rep(1, 76)

aftexp <- aftreg(Surv(Ti,status) ~ vi,  data=dataexp,
     dist="weibull", shape=1)

str(aftexp)
summary(aftexp)
coef(aftexp)

The exponential can be seen as a special case of the weibull 
distribution with shape = 1.
And the help page of aftreg() says precisely to use the weibull with 
shape = 1 if we want an exponential.


Em 04-08-2012 18:45, hafida escreveu:
> Dear R-community,
>> I have tried to estimate an EXPONENTIEL accelerated failure time(AFT)
>> power rule model  with time-independent . For that purpose, I have used
>> the eha package.
>> Please, consider this example:
>    vi      Ti
> 1  26    5.79
> 2  26 1579.52
> 3  26 2323.70
> 4  28   68.85
> 5  28  426.07
> 6  28  110.29
> 7  28  108.29
> 8  28 1067.60
> 9  30   17.05
> 10 30   22.66
> 11 30   21.02
> 12 30  175.88
> 13 30  139.07
> 14 30  144.12
> 15 30   20.46
> 16 30   43.40
> 17 30  194.90
> 18 30   47.30
> 19 30    7.74
> 20 32    0.40
> 21 32   82.85
> 22 32    9.88
> 23 32   89.29
> 24 32  215.10
> 25 32    1.75
> 26 32    0.79
> 27 32   15.93
> 28 32    3.91
> 29 32    0.27
> 30 32    0.69
> 31 32  100.58
> 32 32   27.80
> 33 32   13.95
> 34 32   53.24
> 35 34    0.96
> 36 34    4.15
> 37 34    0.19
> 38 34    0.78
> 39 34    8.01
> 40 34   31.75
> 41 34    7.35
> 42 34    6.50
> 43 34    8.27
> 44 34   33.91
> 45 34   32.52
> 46 34    3.16
> 47 34    4.85
> 48 34    2.78
> 49 34    4.67
> 50 34    1.31
> 51 34   12.06
> 52 34   36.71
> 53 34   72.89
> 54 36    1.97
> 55 36    0.59
> 56 36    2.58
> 57 36    1.69
> 58 36    2.71
> 59 36   25.50
> 60 36    0.35
> 61 36    0.99
> 62 36    3.99
> 63 36    3.67
> 64 36    2.07
> 65 36    0.96
> 66 36    5.35
> 67 36    2.90
> 68 36   13.77
> 69 38    0.47
> 70 38    0.73
> 71 38    1.40
> 72 38    0.74
> 73 38    0.39
> 74 38    1.13
> 75 38    0.09
> 76 38    2.38
>> aftexp<-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
>> dist="exponentiel")
> Error in Surv(time, status) : Time variable is not numeric
>
>> aftexp<-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
>> dist="exponentiel")
> Error in Surv(Ti, status) : object 'status' not found
>> status<- rep(1, 76)
>> status
>   [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 1 1 1 1 1 1 1 1 1 1 1
> 1 1
> [39] 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 1 1 1 1 1 1 1 1 1 1
> 1 1
>
>> cbind(dataexp, status)
>     vi      Ti status
> 1  26    5.79      1
> 2  26 1579.52      1
> 3  26 2323.70      1
> 4  28   68.85      1
> 5  28  426.07      1
> 6  28  110.29      1
> 7  28  108.29      1
> 8  28 1067.60      1
> 9  30   17.05      1
> 10 30   22.66      1
> 11 30   21.02      1
> 12 30  175.88      1
> 13 30  139.07      1
> 14 30  144.12      1
> 15 30   20.46      1
> 16 30   43.40      1
> 17 30  194.90      1
> 18 30   47.30      1
> 19 30    7.74      1
> 20 32    0.40      1
> 21 32   82.85      1
> 22 32    9.88      1
> 23 32   89.29      1
> 24 32  215.10      1
> 25 32    1.75      1
> 26 32    0.79      1
> 27 32   15.93      1
> 28 32    3.91      1
> 29 32    0.27      1
> 30 32    0.69      1
> 31 32  100.58      1
> 32 32   27.80      1
> 33 32   13.95      1
> 34 32   53.24      1
> 35 34    0.96      1
> 36 34    4.15      1
> 37 34    0.19      1
> 38 34    0.78      1
> 39 34    8.01      1
> 40 34   31.75      1
> 41 34    7.35      1
> 42 34    6.50      1
> 43 34    8.27      1
> 44 34   33.91      1
> 45 34   32.52      1
> 46 34    3.16      1
> 47 34    4.85      1
> 48 34    2.78      1
> 49 34    4.67      1
> 50 34    1.31      1
> 51 34   12.06      1
> 52 34   36.71      1
> 53 34   72.89      1
> 54 36    1.97      1
> 55 36    0.59      1
> 56 36    2.58      1
> 57 36    1.69      1
> 58 36    2.71      1
> 59 36   25.50      1
> 60 36    0.35      1
> 61 36    0.99      1
> 62 36    3.99      1
> 63 36    3.67      1
> 64 36    2.07      1
> 65 36    0.96      1
> 66 36    5.35      1
> 67 36    2.90      1
> 68 36   13.77      1
> 69 38    0.47      1
> 70 38    0.73      1
> 71 38    1.40      1
> 72 38    0.74      1
> 73 38    0.39      1
> 74 38    1.13      1
> 75 38    0.09      1
> 76 38    2.38      1
>
>> aftexp<-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
>> dist="exponentiel")
> Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,  :
>    exponentiel is not an implemented distribution
>
>> aftexp<-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
>> dist="exponentiel")
> Error in Surv(time, status) : Time variable is not numeric
>> pleas help me to find a solution to my problem
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p4639174.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list