Before the description, here are my questions
(1) Is the set-up of my time-dependent data correct?
(2) Are the ways I run my Cox proportional hazard model with a time-dependent variable/ non time-dependent variable correct?
(3) Which one would be valid for my purpose (described below)?
(4) Why are the Schoenfeld residuals different between the two methods?
(5) Cox proportional hazard assumes that the hazard ratio stays constant through time. Does that mean that variable effect stays constant through time? I'm having difficulty thinking about how the effect of the variable (described below) may change through time, because the variable itself changes with time, so it's not easy to point to a start time and say that the effect of the variable with the value at that time varies as time goes on.
Data
After various transformation, my data look like this
state start stop time event statesh nail
(chr) (dbl) (dbl) (dbl) (int) (int) (chr)
1 California 1956 1957 NA 0 NA 0
2 California 1957 1958 NA 0 NA 0
3 California 1958 1959 NA 0 NA 0
4 California 1959 1960 NA 0 NA 0
5 California 1960 1961 NA 0 NA 0
6 California 1961 1962 NA 0 NA 0
7 California 1962 1963 NA 0 NA 0
8 California 1963 1964 NA 0 NA 0
9 California 1964 1965 NA 0 NA 0
10 California 1965 1966 NA 0 NA 0
11 California 1966 1967 NA 0 NA 0
12 California 1967 1968 NA 0 NA 0
13 California 1968 1969 NA 0 NA 0
14 California 1969 1970 NA 0 NA 0
15 California 1970 1971 NA 0 519228 0
16 California 1971 1972 NA 0 575740 1
17 California 1972 1973 NA 0 625530 1
18 California 1973 1974 8 1 644516 1
...
with state
being the subject. There are 50 states, so there are 50 subjects.
Problem and variables description
I'd like to model the relationship between the independent variable statesh
and the time to event.
statesh
is a state's annual expense related to the event I'm interested in, so it is time-dependent (right?). This variable has a large portion of missing values.
nail
is a categorical control variable that I'll include in the model later; it is a historical variable in the sense that it resulted from legislation decision, so I don't think it is time-dependent even though it varies with time.
Models result
When I run the Cox proportional hazard model with statesh
as time-dependent variable, I get
> coxph = coxph(Surv(start, stop, event) ~ statesh, data = first.data, method = "breslow")
> kable(tidyoutput(coxph))
|term | estimate| exp.coef| p.value|
|:-------|--------:|--------:|--------:|
|statesh | 1.5e-06| 1.000001| 0.018621|
> test = cox.zph(coxph, transform = log)
> test
rho chisq p
statesh 0.0518 0.0825 0.774
> plot(test)
When I run the Cox model with statesh
as a static variable (i.e., from the dataset above, I filter out every row where time == NA
), I get
> coxph = coxph(Surv(time, event) ~ statesh, data = first.data, method = "breslow")
> kable(tidyoutput(coxph))
|term | estimate| exp.coef| p.value|
|:-------|--------:|--------:|--------:|
|statesh | 4e-07| 1| 0.627078|
> test = cox.zph(coxph, transform = log)
> test
rho chisq p
statesh 0.0138 0.0111 0.916
coxph
has no mechanism for keeping track of individuals. It simply finds each event time, and evaluates, at each event time, based on all the data rows that are still at risk at that time. I suspect that the cases with NA values forstatesh
are silently ignored in the first model. As thenail
variable changes with time, it would seem you need to treat is as time-dependent if you incorporate it as a covariate. $\endgroup$ – EdM Jul 1 '16 at 19:07first.data
is not the same asfirst.data
in the first model, but contains only the rows wheretime
is not NA, and so there will be only one row for each subject. With that, is my second model doing what I think? Anyway, the first model is the correct way to do it, isn't it, based on your response on my other question? Thank you for your time. $\endgroup$ – user90593 Jul 1 '16 at 21:33