Shelby Leonard
2016-Mar-26 01:32 UTC
[R] Coxph model treating all the values of 1 variable as separate variables PLEASE HELP!!
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2016-03-25 at 9.26.30 PM.png Type: image/png Size: 499434 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160326/53424269/attachment-0002.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2016-03-25 at 9.32.04 PM.png Type: image/png Size: 207019 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160326/53424269/attachment-0003.png>
Marc Schwartz
2016-Mar-26 11:39 UTC
[R] Coxph model treating all the values of 1 variable as separate variables PLEASE HELP!!
> 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