mark.fisher123 <marko.fisher2008 <at> gmail.com> writes:

[snip]
> library(survival) 
> survdata<-read.csv("data.csv") 
> 
> ##Fit Weibull model to data 
> 
> WeiModel<-survreg(Surv(survdata$Time,survdata$Status)~survdata$gender) 
> summary(WeiModel) 
> 
> P<-pweibull(n, scale=exp(WeiModel$coef[1]), shape=1/WeiModel$scale) 
> 
> ##Return mean 
> 
> scale<-exp(WeiModel$coef[1]) 
> shape<-1/WeiModel$scale 
> 
> mean <- scale*gamma(1+1/shape) 
> The problem is that the mean is based on the baseline coefficient which
> assumes the population is male (= 0). I want an adjusted mean which isnt
> assuming the whole population is male, or female - so the baseline
> coefficient is completely adjusted for gender. 

  Well, you will get different answers depending on the sex ratio of
the population.  If you want to predict based on the existing population,
then just go ahead and fit the model without including gender as
a covariate (~1 rather than ~gender).  The other possibility would
be to use coef(WeiModel)[1]+coef(WeiModel)[2]/2 as the (log-scale)
scale parameter, but I'm not sure that would be correct.

______________________________________________
R-help@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.

Reply via email to