Dear Terry, Thanks a lot for your reply. The result of survreg reads like:
Call: survreg(formula = Surv(end, status) ~ fico_demean, data = raw, dist = "loglogistic", model = TRUE) Value Std. Error z p (Intercept) 2.98365 1.34e-03 2233.2 0.00e+00 fico_demean -0.00183 5.36e-05 -34.2 4.18e-256 Log(scale) -1.41070 2.65e-03 -532.9 0.00e+00 So given your transform the intercept term and log(scale) matches the a and b respectively - thanks a lot. The effect of fico_demean, however, still seems not close. I will try to find the K&P book. Yes, the function which(rnos <= bhaz * exp(dfico[i]*dficoeff))[1] is identical with min(which(rnos <= bhaz * exp(dfico[i]*dficoeff))), because the vector of subscription returned by 'which' is always ascending. bhaz is not a constant but a vector of baseline hazard rate, so 'which' will do a element by element comparison. If bhaz is a constant, then endtime[i] will follow a geometric distribution. I appreciate your help. Thanks a lot. Jiakai Chen Terry Therneau wrote: > > > The survreg function uses the location-scale parameterizations found in > Kalbfleisch and Prentice's book "The statistical analysis of failure time > data". > Looking at your code, you are using something different > > You K&P > 1/a lambda > b gamma > > And from K&P: lambda = exp(-alpha), gamma= 1/sigma, where > alpha = linear predictor from the fit > sigma = scale factor from the fit > I would suggest checking out a copy of the book to verify the above. > > Second, your method of constructing a random time from the distribution > is a > mystery to me. I believe your code is equivalent to > y <- min(which(runif(n) < constant)) > for any given y (with changing values of the constant). > This is a value from the geometic distribution. > > Terry Therneau > > ______________________________________________ > 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. > > -- View this message in context: http://www.nabble.com/Survreg-function-for-loglogistic-hazard-estimation-tp23907598p23927718.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.