Skip to content
Prev 308479 / 398506 Next

Question about survdiff in for-loop.

On Fri, Oct 19, 2012 at 8:02 PM, Sando <chocosando at daum.net> wrote:
That's a problem with how formulas are parsed: you are effectively
telling survdiff() that you want names[i] as your predictor variable,
when actually you want it as the name of your predictor variable.

Using svsv[i] rather than names[i] should work.  Or you can insert the
value of names[i] into the formula with

 survdiff(eval(bquote(Surv(survival.m, survival) ~ .(names[i]))), data=svsv)

Even after you fix that, there's another problem, which is that your
code doesn't actually use the result from survdiff() in any way.

  -thomas