[R] Simulation from a model fitted by survreg.

2004-07-28 Thread Sixten Borg
Dear list,

I would like to simulate individual survival times from a model that has been fitted 
using the survreg procedure (library survival). Output shown below.

My plan is to extract the shape and scale arguments for use with rweibull() since my 
error terms are assumed to be Weibull, but it does not make any sense. The mean 
survival time is easy to predict, but I would like to simulate individual survival 
times.

I am probably missing something completely obvious. Any hints or advice are 
appreciated.

Thanks
Sixten

 summary(mod1)

Call:
survreg(formula = Surv(tid, study$first.event.death) ~ regim + 
age + stadium2, data = study, dist = weibull)
  Value Std. Error  zp
(Intercept) 11.6005 0.7539 15.387 2.01e-53
regimposto  -0.1350 0.1558 -0.867 3.86e-01
age -0.0362 0.0102 -3.533 4.11e-04
stadium2ii  -0.0526 0.2794 -0.188 8.51e-01
Log(scale)  -0.5148 0.1116 -4.615 3.93e-06

Scale= 0.598 

Weibull distribution
Loglik(model)= -680.7   Loglik(intercept only)= -689.2
Chisq= 16.87 on 3 degrees of freedom, p= 0.00075 
Number of Newton-Raphson Iterations: 8 
n=1183 (4 observations deleted due to missing)

 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor8.1
year 2003   
month11 
day  21 
language R  


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Simulation from a model fitted by survreg.

2004-07-28 Thread Spencer Graves
 Please check the documentation, e.g., Venables and Ripley (2002) 
Modern Applied Statistics with S, p. 360.  The Weibull shape parameter 
is the reciprocal of the scale parameter 0.598 in your printout, so 
shape = 1/0.598 = 1.672;  see also Meeker  Escobar (1998) Statistical 
Methods for Reliability Data (Wiley). 

 Does this answer the question?  You can get coefficients with 
coef(mod1).  Also, have you looked at attributes(summary(mod1))?  If 
mod1 follows the old S3 standard, attributes may give you a list of 
names you can access via summary(mod1)$whateverthenameis (or via 
summary(mod1)[[whateverthenameis]]).  If mod1 follows the new S4 
standard, then getSlots(mod1) and getSlots(summary(mod1)) will give you 
the names of the slots and their classes, which can then be accessed via 
[EMAIL PROTECTED]  Sorry, I don't have time to construct an 
example myself, but I've done this kind of thing many times. 

 hope this helps. 
 spencer graves

Sixten Borg wrote:
Dear list,
I would like to simulate individual survival times from a model that has been fitted 
using the survreg procedure (library survival). Output shown below.
My plan is to extract the shape and scale arguments for use with rweibull() since my 
error terms are assumed to be Weibull, but it does not make any sense. The mean 
survival time is easy to predict, but I would like to simulate individual survival 
times.
I am probably missing something completely obvious. Any hints or advice are 
appreciated.
Thanks
Sixten
 

summary(mod1)
   

Call:
survreg(formula = Surv(tid, study$first.event.death) ~ regim + 
   age + stadium2, data = study, dist = weibull)
 Value Std. Error  zp
(Intercept) 11.6005 0.7539 15.387 2.01e-53
regimposto  -0.1350 0.1558 -0.867 3.86e-01
age -0.0362 0.0102 -3.533 4.11e-04
stadium2ii  -0.0526 0.2794 -0.188 8.51e-01
Log(scale)  -0.5148 0.1116 -4.615 3.93e-06

Scale= 0.598 

Weibull distribution
Loglik(model)= -680.7   Loglik(intercept only)= -689.2
   Chisq= 16.87 on 3 degrees of freedom, p= 0.00075 
Number of Newton-Raphson Iterations: 8 
n=1183 (4 observations deleted due to missing)

 

version
   

_  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor8.1
year 2003   
month11 
day  21 
language R  
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Simulation from a model fitted by survreg.

2004-07-28 Thread Thomas Lumley
On Wed, 28 Jul 2004, Sixten Borg wrote:

 Dear list,

 I would like to simulate individual survival times from a model that has
 been fitted using the survreg procedure (library survival). Output shown
 below.

 My plan is to extract the shape and scale arguments for use with
 rweibull() since my error terms are assumed to be Weibull, but it does
 not make any sense. The mean survival time is easy to predict, but I
 would like to simulate individual survival times.


It's parametrized differently from rweibull. The linear predictor for the
model is the logarithm of the scale, and the scale parameter from the
model is the reciprocal of the shape.

As with the gamma family you always need to check the parametrisation for
weibull distributions.

-thomas



 I am probably missing something completely obvious. Any hints or advice
 are appreciated.

 Thanks
 Sixten

  summary(mod1)

 Call:
 survreg(formula = Surv(tid, study$first.event.death) ~ regim +
 age + stadium2, data = study, dist = weibull)
   Value Std. Error  zp
 (Intercept) 11.6005 0.7539 15.387 2.01e-53
 regimposto  -0.1350 0.1558 -0.867 3.86e-01
 age -0.0362 0.0102 -3.533 4.11e-04
 stadium2ii  -0.0526 0.2794 -0.188 8.51e-01
 Log(scale)  -0.5148 0.1116 -4.615 3.93e-06

 Scale= 0.598

 Weibull distribution
 Loglik(model)= -680.7   Loglik(intercept only)= -689.2
 Chisq= 16.87 on 3 degrees of freedom, p= 0.00075
 Number of Newton-Raphson Iterations: 8
 n=1183 (4 observations deleted due to missing)

  version
  _
 platform i386-pc-mingw32
 arch i386
 os   mingw32
 system   i386, mingw32
 status
 major1
 minor8.1
 year 2003
 month11
 day  21
 language R
 

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html