I am having issues including "season" as a predictor variable in my survival analysis using cox proportional hazard models. I work with sage-grouse and have reason to believe their survival varies by season. I provided a sample data set below.
library(survival)
library(dplyr)
BirdID <- c(1,1,1,1,2,2,2,2,3,3,3)
Event <- c(0,0,0,0,0,0,0,1,0,0,1)
Start <- c(0,13,26,39,0,13,26,39,0,13,26)
Stop <- c(13,26,39,52,13,26,39,48,13,26,35)
Avg.Move <- c(2,5,6,9,15,9,16,25,1,3,18)
Season <- c("spring", "summer", "fall", "winter", "spring", "summer",
"fall", "winter", "spring", "summer", "fall")
C <- cbind(BirdID, Start, Stop, Event, Avg.Move, Season)
T <- as.data.frame(C)
T$Start <- as.numeric(as.character(T$Start))
T$Stop <- as.numeric(as.character(T$Stop))
T$Event <- as.numeric(as.character(T$Event))
T$Avg.Move <- as.numeric(as.character(T$Avg.Move))
I have formatted my data so that each row is a different season because I have time-dependent variables (e.g. Avg.Move = average distance moved per season). I'm guessing that this may be part of my problem. Anyway, when I try to run basic coxph models with different combinations of my predictors (Season and Avg.Move) I continually get errors.
L <- coxph(Surv(Start, Stop, Event) ~ Season, data=T)
## Error in fitter(X, Y, strats, offset, init, control, weights = weights, :
routine failed due to numeric overflow.This should never happen. Please
contact the author.
X <- coxph(Surv(Start, Stop, Event) ~ Avg.Move+Season, data=T)
## Warning messages:
1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
Loglik converged before variable 1,3,4 ; beta may be infinite.
2: In coxph(Surv(Start, Stop, Event) ~ Avg.Move + Season, data = T) :
X matrix deemed to be singular; variable 2
I've tried coding Season as numeric (1,2,3,4) and binary (10000, 0100, 0010, 0001) but nothing has helped.
Thanks in advance,
Kyle