I want to select a Cox model using the forward procedure from a data.frame file without NA. Here are some sample data:
test <- data.frame( x_1 = runif(100,0,1), x_2 = runif(100,0,5), x_3 = runif(100,10,20), time = runif(100,50,200), event = c(rep(0,70),rep(1,30)) )
This table does not matter, but if we try to build a model anyway:
modeltest <- coxph(Surv(time, event) ~1, test) modeltest.forward <- step( modeltest, data = test, direction = "forward", scope = list(lower = ~ 1, upper = ~ x_1 + x_2 + x_3) )
The front end in the first step and says:
In is.na (suitable $ coefficients): is.na () is applied to a non (list or vector) of type 'NULL'
(three times)
I tried changing the upper model, I even tried upper = ~ 1 , but the warning remains. I do not understand: I do not have NS, and my vectors are all numerical (I checked). I searched if people had the same problem, but all I could find was problems due to the name or class of vectors.
What is wrong with my code?