|
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
|
|
Hi J,
You have not provided nearly enough information for us to evaluate whether the results should be similar. You are talking about two completely different packages, with no information on your data, only a small amount of information about your model ("the same analysis") but clearly the analysis is *not* the same or you would get the same results, so really you have "I think I am running the same analysis but either the underlying code/model, the data, or my syntax is actually running a different model and what I really want is someone to help me synchronize the results from R and Stata so I feel more confident, but please do this without data, code, or output". Please do not take this the wrong way, I am not trying to be harsh, just point out the difficulty of the question you have asked us. I primarily use R, but I work at a consulting center and have access to Stata and some interest in survival models, so if you sent us your data (or found/created some example data that replicated the discrepancy you note), I would try to check out both your R and Stata code, but I can only do this with some help from you. Otherwise, I have to find my own data, examine the functions in R and Stata to compare what they are doing, and try many tests on my own to hopefully try to replicate what you might be seeing and then see if I can actually get the same output. Perhaps a more saintly version of myself would do that, but unlike my officemate, there is no special place waiting for me in heaven, or perhaps I have yet to find my wings. More detailed help provided when you provide a reproducible example as the posting guide requests. Cheers, Josh On Fri, Jul 6, 2012 at 2:12 PM, JPF <[hidden email]> wrote: > Dear Community, > > I have been using two types of survival programs to analyse a data set. > > The first one is an R function called aftreg. The second one an STATA > function called streg. > > Both of them include the same analyisis with a weibull distribution. Yet, > results are very different. > > Shouldn't the results be the same? > > Kind regards, > J > > -- > View this message in context: http://r.789695.n4.nabble.com/differences-between-survival-models-between-STATA-and-R-tp4635670.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 it's this bit right here I am referring to: > and provide commented, minimal, self-contained, reproducible code. --------------------------> ^^^^^^^^^^^^^ -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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. |
|
In reply to this post by JPF
Without more information, we can only guess what you did, or what you
are seeing on the page that is "different". I'll make a random guess though. There are about 5 ways to paramaterize the Weibull distribution. The standard packages that I know, however, tend to use the one found in the Kalbfleisch and Prentice book The Statistical Analysis of Failure time Data. This includes the survreg funciton in R and lifereg in SAS, and likely stata tthought I don't know that package. The aftreg function in the eha package uses something different. About 1/2 the weibull questions I see are due to a change in parameters. Terry T. ---- begin included message ----- Dear Community, I have been using two types of survival programs to analyse a data set. The first one is an R function called aftreg. The second one an STATA function called streg. Both of them include the same analyisis with a weibull distribution. Yet, results are very different. Shouldn't the results be the same? Kind regards, J ______________________________________________ [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. |
|
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
|
|
On 7/9/2012 9:17 AM, Javier Palacios Fenech wrote:
> Please. After, Terry's response I guess I was expecting to hear how your comparison between R and STATA went when you used the R function, survreg() for your analysis. We still don't know what your data look like. The posting guide asks for a "reproducible example". This typically means including at least a "toy dataset" if not the actual data you are using. To learn more: library(survival) ?survreg > > find an example here. With exactly the same data set, I run two hazard > models following the instructions for each function. > > aftreg(formula = Surv(sta, sto, S) ~ a + b + c + d + e + f + g > , factor(F), data = data.frame(SURV), > dist = "weibull", id = ID) > > streg f1 f2 f3 f4 f5 a b c d g f g, dist(weibull) time nolog (note: > F= f1, f2,f3,f4,f5) > > Results are different. Really different. With aftreg some estimates are > significant, and with STATA they are not. Many estimates do not even have > the same sign, therefore predicting contrary effects. Which model should I > trust? > > Best, > > J > > > > > > On Mon, Jul 9, 2012 at 9:59 AM, Terry Therneau <[hidden email]> wrote: > >> Without more information, we can only guess what you did, or what you are >> seeing on the page that is "different". >> >> I'll make a random guess though. There are about 5 ways to paramaterize >> the Weibull distribution. The standard packages that I know, however, tend >> to use the one found in the Kalbfleisch and Prentice book The Statistical >> Analysis of Failure time Data. This includes the survreg funciton in R and >> lifereg in SAS, and likely stata tthought I don't know that package. The >> aftreg function in the eha package uses something different. >> >> About 1/2 the weibull questions I see are due to a change in parameters. >> >> Terry T. >> >> ---- begin included message ----- >> >> >> >> >> Dear Community, >> >> I have been using two types of survival programs to analyse a data set. >> >> The first one is an R function called aftreg. The second one an STATA >> function called streg. >> >> Both of them include the same analyisis with a weibull distribution. Yet, >> results are very different. >> >> Shouldn't the results be the same? >> >> Kind regards, >> J >> >> > ______________________________________________ [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. |
|
This post was updated on .
In reply to this post by JPF
CONTENTS DELETED
The author has deleted this message.
|
|
In reply to this post by JPF
UCLA's Advanced Technical Services' Statistical Computing website often has very good resources for comparing analyses between R, Stata, and SAS ( http://www.ats.ucla.edu/stat ). For accelerated failure time models, I believe that it has some examples for Stata ( http://www.ats.ucla.edu/stat/stata/examples/asa/asastata8.htm ), but not for R. However, the Stata examples, to the best of my knowledge, use Hosmer and Lemeshow's HMO HIV data from their 1998 Applied Survival Analysis text, which happens to be available at http://www.ats.ucla.edu/stat/R/examples/asa/hmohiv.csv . Thus, you can try reproducing UCLA's Stata AFT examples in R, and post the results here as a reproducible example to illustrate what is confusing you.
For example:
## Require eha package for aftreg function
require("eha")
## Hosmer and Lemeshow's HMO HIV data
hmohiv <- read.csv("http://www.ats.ucla.edu/stat/R/examples/asa/hmohiv.csv")
## Example model
aft1 <- aftreg(Surv(time, censor) ~ drug, data = hmohiv, dist = "weibull", shape = 1)
summary(aft1)
Yields:
> summary(aft1)
Call:
aftreg(formula = Surv(time, censor) ~ drug, data = hmohiv, dist = "weibull",
shape = 1)
Covariate W.mean Coef Exp(Coef) se(Coef) Wald p
drug 0.239 1.056 2.874 0.224 0.000
log(scale) 3.024 20.571 0.112 0.000
Which you can compare to the following from the UCLA website:
streg drug, dist(exp) time
Exponential regression -- accelerated failure-time form
No. of subjects = 100 Number of obs = 100
No. of failures = 80
Time at risk = 1136
LR chi2(1) = 20.93
Log likelihood = -146.79209 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
drug | -1.055687 .2238868 -4.72 0.000 -1.494497 -.6168771
_cons | 3.023903 .1543033 19.60 0.000 2.721474 3.326332
------------------------------------------------------------------------------
And then describe to r-help which discrepancies between the R and Stata output are confusing you. Regards, Jeremy
Jeremy T. Hetzel
Boston University |
|
In reply to this post by JPF
Be sure you reply or forward your message to me to the r-help listhost. I might not have time to review it tonight, while others might.
Jeremy
On Mon, Jul 9, 2012 at 2:38 PM, JPF [via R] <[hidden email]> wrote: Please, find an example with a data set here.
Jeremy T. Hetzel
Boston University |
|
In reply to this post by Terry Therneau-2
On Mon, Jul 9, 2012 at 3:59 PM, Terry Therneau <[hidden email]> wrote:
> Without more information, we can only guess what you did, or what you are > seeing on the page that is "different". > > I'll make a random guess though. There are about 5 ways to paramaterize > the Weibull distribution. The standard packages that I know, however, tend > to use the one found in the Kalbfleisch and Prentice book The Statistical > Analysis of Failure time Data. This includes the survreg funciton in R and > lifereg in SAS, and likely stata tthought I don't know that package. The > aftreg function in the eha package uses something different. > (exponential) score of an individual accelerates time with that factor. In survreg, expected life is multiplied by the corresponding factor (the inverse of the previous). > > About 1/2 the weibull questions I see are due to a change in parameters. > > For this reason I have introduced an additional parameter to aftreg, 'param', in the latest version of eha. The default value is 'default' (everything is as before) and an alternative is 'survreg' (everything is as in survreg). Göran > Terry T. > > ---- begin included message ----- > > > > > Dear Community, > > I have been using two types of survival programs to analyse a data set. > > The first one is an R function called aftreg. The second one an STATA > function called streg. > > Both of them include the same analyisis with a weibull distribution. Yet, > results are very different. > > Shouldn't the results be the same? > > Kind regards, > J > > ______________________________**________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Göran Broström [[alternative HTML version deleted]] ______________________________________________ [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. |
| Powered by Nabble | Edit this page |
