Quantcast

AFT model time-dependent with weibull distribution

classic Classic list List threaded Threaded
14 messages Options
JPF
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

AFT model time-dependent with weibull distribution

JPF
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

Göran Broström
On Fri, Aug 19, 2011 at 2:55 PM, javier palacios <[hidden email]> wrote:

> Dear R-community,
>
> I have tried to estimate an accelerated failure time(AFT) and proportional
> hazard (PH) parametric survival model with time-independent  and
> time-dependent covariates. For that purpose, I have used the eha package.
>
>
> Please, consider this example:
>
> weibullph <- phreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist="weibull",
> data.frame=Data)
>
> weibullaft<-aftreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist="weibull",
> data.frame=Data)
>
> ## aftreg gives error when I add ID argument...
>
> Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,  :
>  Overlapping intervals for id  2

Does not happen to me.

>
> >From help(aftreg): id If there are more than one spell per individual, it is
> essential to keep spells together by the id argument. This allows for
> time-varying covariates.
>
>
> data table:
>
> Data
>   S sta time  TDC1 total_time TIC1          ID
> A 1   0   1  48.50       1              1           1
> B 0   0   1  65.96       2               1           2
> B 1   1   2  65.08       2              1            2
> C 0   0   1  0.00        2               4           3
> C 1   1   2  0.00        2               4           3
> D 0   0   1 72.74        2               5           4
> D 1   1   2 72.52        2               5           4
> E 0   0   1 61.84         2              3            5
> E 0   1   2 60.56        2               3            5
> F 0   0   1 35.04        4               2            6
> F 0   1   2 36.97        4               2            6
> F 0   2   3 37.92        4               2            6
> F 1   3   4 39.01        4               2            6

Duplicated rownames are no allowed.

>
> time - time to event
> sta - starting time
> TDC - time dependent covariates
> TIC - time independent covariate
> total_time - total time at risk
> ID - ID
>
> 1- What happens if the ID is not included?
Read the documentation
> 2- How can I solve this error?
Read the documentation
> 3- Why the phreg function does not need an ID?
Read the documentation (and a good text book on survival analysis)

And please read the posting guide; the elementary information is missing.

>
> Thanks,
>
> Javier
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p3755079.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>



--
Göran Broström

______________________________________________
[hidden email] 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.
JPF
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

JPF
Dear Prof. Broström,

 I have searched in the reference manual inside the package eha, updated recently. I did not find any description on how to enter id in the aftreg function except the description of the argument. Can you refer to a specific part of the manual?  Do you mean another documentation?


I had also visited the posting guide before ( I included an example and all the details I could.). What else can I add?

And have also read a a book intruducing survival analysis in R, but the doubt that I have is very specific to R computation.


I reask the questions:

I have a doubt on how to perform a weibull parametric survival anayisis using time-dependent covariates in R using both accelerated failure time(AFT) and proportional hazard (PH).

I would highly appreciate a reply to my questions.

I provide an example similar to data i use. (Here there are only two covariates one dependent and another independent)

Data
   S sta time  TDC1 total_time TIC1          ID
A 1   0   1  48.50       1              1           1
B 0   0   1  65.96       2               1           2
B 1   1   2  65.08       2              1            2
C 0   0   1  0.00        2               4           3
C 1   1   2  0.00        2               4           3
D 0   0   1 72.74        2               5           4
D 1   1   2 72.52        2               5           4
E 0   0   1 61.84         2              3            5
E 0   1   2 60.56        2               3            5
F 0   0   1 35.04        4               2            6
F 0   1   2 36.97        4               2            6
F 0   2   3 37.92        4               2            6
F 1   3   4 39.01        4               2            6

time - time to event
sta - starting time
TDC - time dependent covariates
TIC - time independent covariate
total_time - total time at risk
ID - ID

Doubts:  

-AFT and PH time-dependent Weibull distribution

I have tried to estimate an accelerated failure time(AFT) and proportional hazard (PH) parametric survival model with time-independent  and time-dependent covariates with a weibull distribution. For that purpose, I have used the eha  package. To my knowledge, the survival package does not provide a solution for estimating models with time-dependent models.

weibullph <- phreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist="weibull", data.frame=Data)  
weibullaft<-aftreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist="weibull", data.frame=Data)

## aftreg gives an error when I add an ID argument... That should be used for controlling for time-varying variables.

Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,  :
  Overlapping intervals for id  2
 
From help(aftreg): id If there are more than one spell per individual, it is essential to keep spells together by the id argument. This allows for time-varying covariates.

Here are the questions I have:
 
1- How can I solve this error?
2- Does the phreg function need an ID?  Can I use it to estimate  a model with time-dependent covariates?
3- How can time-dependent covariates be estimated with phreg or aftreg, or other function in R?


Thank you very much,

J
JPF
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

JPF
JPF wrote

weibullaft<-aftreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist="weibull", data.frame=Data)

## aftreg gives an error when I add an ID argument... That should be used for controlling for time-varying variables.

Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,  :
  Overlapping intervals for id  2
 
From help(aftreg): id If there are more than one spell per individual, it is essential to keep spells together by the id argument. This allows for time-varying covariates.
This is solved. It gave the overlapping intervals error, but now it is solved: id=ID, just as before.  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

Göran Broström
On Sat, Aug 20, 2011 at 4:19 AM, JPF <[hidden email]> wrote:

>
> JPF wrote:
>>
>>
>>
>> weibullaft<-aftreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist="weibull",
>> data.frame=Data)
>>
>> ## aftreg gives an error when I add an ID argument... That should be used
>> for controlling for time-varying variables.
>>
>> Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,
>> :
>>   *Overlapping intervals for id  2 *
>>
>> From help(aftreg): id If there are more than one spell per individual, it
>> is essential to keep spells together by the id argument. This allows for
>> time-varying covariates.
>>
>>
>
> This is solved. It gave the overlapping intervals error, but now it is
> solved: /id=ID/, just as before.
>
Good. Do you still need answers to your other questions?

G.

> --
> View this message in context: http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p3756502.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>



--
Göran Broström

______________________________________________
[hidden email] 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.
JPF
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

JPF
Göran Broström wrote
Good. Do you still need answers to your other questions?
Yes. Could answer the following two questions:

1- Can I use phreg function to estimate  a model with time-dependent covariates? In case of a positive answer, how?
 
2- I could not find any example that clearly explains how to interpret aftreg output. Specially, refering to the diference between survreg and aftreg output (intercept and sign of the estimates).

I include below an example of output of a regression with coxph, survreg, phreg and aftreg and a time-independent variable. I would appreciate if you could explain it or provide an external example that explains how it works.

n=26
events=25
time at risk=45

a/

coxph(Surv(time,s) ~ Z1,  data=data.frame(data))

     coef     exp(coef)  se(coef)    z     p
Z1 0.0249      1.03      0.00907 2.75 0.006


b/

phreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist="weibull")

Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
Z1                      43.689     0.033     1.033     0.009     0.000

log(scale)                          0.641     1.899     0.065     0.000
log(shape)                         1.172     3.230     0.158     0.000

Max. log. likelihood      -22.135
LR test statistic         13.1
Degrees of freedom        1
Overall p-value           0.000302689


c/

aftreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist="weibull")

Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
mas                  43.689       0.010    1.010     0.002     0.000

log(scale)                          1.147     3.149     0.141     0.000
log(shape)                         1.172     3.230     0.158     0.000

Max. log. likelihood      -22.135
LR test statistic         13.1
Degrees of freedom        1
Overall p-value         0.000302692


d/

survreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist="weibull")

                      Value     Std. Error     z        p
(Intercept)      1.1476    0.13498     8.50  1.87e-17
mas               -0.0101   0.00232    -4.34  1.45e-05
Log(scale)      -1.1724    0.15787    -7.43 1.11e-13

Scale= 0.310

Weibull distribution
Loglik(model)= -22.1   Loglik(intercept only)= -28.7
        Chisq= 13.05 on 1 degrees of freedom, p= 3e-04
Number of Newton-Raphson Iterations: 5


Thank you very much,

J





JPF
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

JPF

question 2

aftreg vs. survreg

for aftreg = S0 *{t/exp(b-BXi)]^a}   a= shape and b= log(scale)

for survreg and stata S0 *{t*exp(intercept+BXi)]^1/p} p=shape

intercept, log(scale) and estimates are equivalent with reversed sign. 

PH and AFT 

phreg.Bhat= aftreg.Bhat * shape    





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

Göran Broström
In reply to this post by JPF
On Sat, Aug 20, 2011 at 7:33 PM, JPF <[hidden email]> wrote:

>
> Göran Broström wrote:
>>
>>
>> Good. Do you still need answers to your other questions?
>>
>>
>
> Yes. Could answer the following two questions:
>
> 1- Can I use phreg function to estimate  a model with time-dependent
> covariates? In case of a positive answer, how?

Yes. You do it in the way you did it with your first example. No 'id'
argument is needed (or allowed) in the call to phreg. The reason is
that in PH regression, the hazard function at any time depends only on
the covariate value at that time point. In the AFT model, on the other
hand, the hazard function at time  t  depends on all covariate values
in the interval (0, t). Therefore aftreg needs the 'id' argument, but
phreg does not.

>
> 2- I could not find any example that clearly explains how to interpret
> aftreg output. Specially, refering to the diference between survreg and
> aftreg output (intercept and sign of the estimates).

I think you already answered that question. You can read more about it
in the vignette about parametric models in eha.

G.

>
> I include below an example of output of a regression with coxph, survreg,
> phreg and aftreg and a time-independent variable. I would appreciate if you
> could explain it or provide an external example that explains how it works.
>
> n=26
> events=25
> time at risk=45
>
> a/
>
> coxph(Surv(time,s) ~ Z1,  data=data.frame(data))
>
>     coef     exp(coef)  se(coef)    z     p
> Z1 0.0249      1.03      0.00907 2.75 0.006
>
>
> b/
>
> phreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist="weibull")
>
> Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
> Z1                      43.689     0.033     1.033     0.009     0.000
>
> log(scale)                          0.641     1.899     0.065     0.000
> log(shape)                         1.172     3.230     0.158     0.000
>
> Max. log. likelihood      -22.135
> LR test statistic         13.1
> Degrees of freedom        1
> Overall p-value           0.000302689
>
>
> c/
>
> aftreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist="weibull")
>
> Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
> mas                  43.689       0.010    1.010     0.002     0.000
>
> log(scale)                          1.147     3.149     0.141     0.000
> log(shape)                         1.172     3.230     0.158     0.000
>
> Max. log. likelihood      -22.135
> LR test statistic         13.1
> Degrees of freedom        1
> Overall p-value         0.000302692
>
>
> d/
>
> survreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist="weibull")
>
>                      Value     Std. Error     z        p
> (Intercept)      1.1476    0.13498     8.50  1.87e-17
> mas               -0.0101   0.00232    -4.34  1.45e-05
> Log(scale)      -1.1724    0.15787    -7.43 1.11e-13
>
> Scale= 0.310
>
> Weibull distribution
> Loglik(model)= -22.1   Loglik(intercept only)= -28.7
>        Chisq= 13.05 on 1 degrees of freedom, p= 3e-04
> Number of Newton-Raphson Iterations: 5
>
>
> Thank you very much,
>
> J
>
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p3757387.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>



--
Göran Broström

______________________________________________
[hidden email] 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.
JPF
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

JPF
thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

hafida
In reply to this post by Göran Broström
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

David Winsemius

On Aug 4, 2012, at 10:45 AM, hafida wrote:

> 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
snipped
> 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

Your variables being given to the `Surv` function do not match those  
in you data object.

>
>> 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
>
snipped

> 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

You are spelling 'exponential' incorrectly (in English anyway.)

Bon chance;
David.
>
>> 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
>
>
--

David Winsemius, MD
Alameda, CA, USA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

Rui Barradas
In reply to this post by hafida
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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

hafida
thanks a lot
sorry for the mistake that i do in exponential, i am "francophone"

and for the programme if we want to apply the "power rule " condition we use  log(vi).
it works  thank youuuu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: AFT model time-dependent with weibull distribution

hafida
This post has NOT been accepted by the mailing list yet.
HI again

>I want to ask you about the defference between the exponential power rul model and the exponential log-linear model
>
> thank you
Hafiida
Loading...