2

I'm trying to replicate some survival analysis using the Weibull distribution that I have previously produced in SAS - I'm now working from an unlicensed machine so am using R (both from Windows). My (right censored) input data looks like:

> head(mydata)
  ID         Key  Time  Score    Event    Censor
1 1231231    ZXC   28   182.34   0      1
2 4564564    ASD   28   320.04   0      1
3 7897897    QWE   28   306.32   0      1
4 9879879    QWE   28   211.92   0      1
5 6546546    ASD   28   276.14   0      1
6 3213213    ZXC   28   331.50   0      1

with Event and Censor being binaries, Score varying between about 150 and 450 and Time between 1 and 28. There are some 30,000 rows in the input dataset.

When I try:

mydatasr <- survreg(Surv(Time, Censor) ~ Score, dist = "w")

I get a warning message:

In survreg.fit(X, Y, weights, offset, init = init, controlvals = control, : Ran out of iterations and did not converge,

And no output.

I've searched for this msg online (and through this site) but have not managed to find anything that indicates what the problem might be. I had no convergence issues putting the same data through (proc logistic and) lifereg in SAS.

Zephyr
  • 138
  • 2
  • 13
  • You would not expect any output unless you then typed the name of that object to invoke the `print.survreg` function. Assignment does not necessarily cause `print`-methods to execute. – IRTFM Aug 25 '15 at 19:01
  • Very late to this, but encountering the same issue led me here .. I am wondering if it has to do with resources (ie RAM)? Am currently troubleshooting so will report back – daRknight May 07 '19 at 21:34

2 Answers2

3

It's difficult to know in the absence of data. You can double (or as illustrated below, triple) the number of iterations which defaults to 30:

(mydatasr <- survreg(Surv(Time, Censor) ~ Score , dist = "w", control = list(maxiter=90) )

See ?survreg.control for further options. I also am guessing you may have missed that a Surv-object has a closing parenthesis before the formula-~

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Oops - I think the closing bracket got lost while I was disguising my data! I _did_ try increasing the number of iterations, but still didn't get any meaningful results, even when I truncated the length of my input data to ~ 70 rows. I think I will just have to go back to SAS. – Zephyr Aug 26 '15 at 07:39
  • It's fairly common on the Rhelp Mailing List that when SAS produces a result and R does not, and the data are also provided for analysis, that SAS can be shown to be delivering the wrong answer. You should be checking the result by plotting the non-parametric hazards to see if a Weibull model actually makes sense. – IRTFM Aug 26 '15 at 16:03
  • Thanks for the heads-up! Unfortunately, the tool of choice at my company is SAS - I'm just waiting for a licence. However, we do cross-validate our results :) – Zephyr Aug 27 '15 at 09:11
0

Try this:

   survreg(Surv(Time, Censor) ~ Score, data=mydata, dist = "w", scale=1)
Yong
  • 1,107
  • 1
  • 12
  • 21
  • Thank you, but does that not just approximate the Weibull distribution to an exponential one? – Zephyr Aug 25 '15 at 11:43