Dear all, Currently, I am doing a research project about serum sodium levels and falling. I am doing my analysis in R. I am performing the multiple imputation right now. I want to perform a survival analysis later, but therefore I need to specify the Nelson-Aalen estimator. My dataset is called DF1, the event indicator is Falls and the time variable is Time. The code that I use is as follows: NAE <- nelsonaalen(data = DF1, statusvar = Falls, timevar = Time) However, I get this error: Error in Surv(time, status) : Time variable is not numeric If I do the following: class(DF1$Time) [1] "numeric" It shows that my variable is numeric. Can you help me with how I can solve this issue? Thank you in advance. Lisa [[alternative HTML version deleted]]
Hard to tell from the info you are giving us. I assume this regards the "mice" package? One way to proceed is to set options(error=recover) which will dump you into the browser() environment when the error occurs and you can oka around and see what the value of variables was at the point of the error. This could give you a clue about what is going on. -pd> On 22 May 2018, at 15:29 , A.C. van der Burgh <a.c.vanderburgh at erasmusmc.nl> wrote: > > Dear all, > > Currently, I am doing a research project about serum sodium levels and falling. I am doing my analysis in R. I am performing the multiple imputation right now. I want to perform a survival analysis later, but therefore I need to specify the Nelson-Aalen estimator. My dataset is called DF1, the event indicator is Falls and the time variable is Time. The code that I use is as follows: > > NAE <- nelsonaalen(data = DF1, statusvar = Falls, timevar = Time) > > However, I get this error: Error in Surv(time, status) : Time variable is not numeric > > If I do the following: > > class(DF1$Time) [1] "numeric" > > It shows that my variable is numeric. Can you help me with how I can solve this issue? > > Thank you in advance. > > Lisa > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Thank you for your reply. It is about the MICE package indeed. I have tried your 'solution', but I do not see anything unusual going on. My variable Time is a numerical variable, ranging from 0 to 1200. My variable Falls is coded as zero one, where one is having the event. Maybe this information can help a little more to get an idea of the data. -----Original Message----- From: peter dalgaard [mailto:pdalgd at gmail.com] Sent: dinsdag 22 mei 2018 17:03 To: A.C. van der Burgh Cc: r-help at r-project.org Subject: Re: [R] Nelson-Aalen Estimator in R: Error Message Hard to tell from the info you are giving us. I assume this regards the "mice" package? One way to proceed is to set options(error=recover) which will dump you into the browser() environment when the error occurs and you can oka around and see what the value of variables was at the point of the error. This could give you a clue about what is going on. -pd> On 22 May 2018, at 15:29 , A.C. van der Burgh <a.c.vanderburgh at erasmusmc.nl> wrote: > > Dear all, > > Currently, I am doing a research project about serum sodium levels and falling. I am doing my analysis in R. I am performing the multiple imputation right now. I want to perform a survival analysis later, but therefore I need to specify the Nelson-Aalen estimator. My dataset is called DF1, the event indicator is Falls and the time variable is Time. The code that I use is as follows: > > NAE <- nelsonaalen(data = DF1, statusvar = Falls, timevar = Time) > > However, I get this error: Error in Surv(time, status) : Time variable is not numeric > > If I do the following: > > class(DF1$Time) [1] "numeric" > > It shows that my variable is numeric. Can you help me with how I can solve this issue? > > Thank you in advance. > > Lisa > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com