[R] Coxph model treating all the values of 1 variable as separate variables PLEASE HELP!!
Marc Schwartz
marc_schwartz at me.com
Sat Mar 26 12:39:38 CET 2016
> On Mar 25, 2016, at 8:32 PM, Shelby Leonard <shelby_leonard26 at yahoo.com> wrote:
>
>
> I have been working for 12 hours now on trying to fix my cox model. I have a large data set (n>300) and In my model I have time in months, status (1=dead), and change represents my variable. I am trying to determine if the variable change is predicitive of survival. I have used this exact code before but for some reason now it is not working I get the following error message
> Warning message:
> In fitter(X, Y, strats, offset, init, control, weights = weights, : Ran out of iterations and did not converge
> And the output is taking all of the individual values of change as separate variables when I instead want them to be taken together as the same variable
>
> This is my code:model.1<-coxph(Surv(time, status)~change)
>
> I also have tried adding in a 2nd time and using all the variations of the same formula I could find. In addition to the warning message this is what my output looks like
> instead of
> I have no idea why this is happening!!
> Thanks
>
The output that you attached, which you could have copied and pasted into the e-mail as monospaced text, rather than attaching as a screen capture, suggests that your 'change' variable has been coerced to a factor (categorical variable) rather than being treated as continuous.
Thus, you need to figure out where in your code, before you create the model, this is happening.
Trace through your code, step by step if need be, keeping track of how the 'change' variable is being created or manipulated. Use:
str(change)
to see what data type and/or class the 'change' variable is at each step. See ?str. Somewhere along the way, it becomes a factor instead of numeric.
If you imported it via something like read.table() from an external data file, check to see what the result of that operation is, as non-numeric values in that column can result in the entire column being coerced to a factor.
Regards,
Marc Schwartz
More information about the R-help
mailing list