<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic using time-on-study and counting process with different time-based change the results in proc phreg in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/using-time-on-study-and-counting-process-with-different-time/m-p/880747#M43558</link>
    <description>&lt;P&gt;I recently use different time-based to model cox proportional model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have read some papers that the counting process should be the same results as it does in only one survival time variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I found something wrong here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my following example, if i use the counting process, the group 1 and group 2 are actually the same data, but with different time scale. The t1 and t 2 variables in the group 2 have a different time-based, so the t1 and t2 plus the time_shift is the t1 and t2 in the group 2 with the same id.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the two groups have the same period of t1 to t2, and the same id, drug use, and outcome (i.e., hypertension).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if i use the counting process, i will get a different HR (for group 1 and group, i.e., 2, 1.07 and 2.26, respectively).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i use hte time-on-study, i will get another different estimate, 1.19, but they are the same in the two groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to replicate in the R, the results are the estiamtes are the same in counting process or&amp;nbsp;time-on-study, they are 2.26 and 1.19, although they are still different in&amp;nbsp;counting process and&amp;nbsp;time-on-study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone explain why they are different?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
INPUT g	id	hypertension	t1	t2	drug	time	time_shift;
cards;
1	1	0	21916	24940	1	3024	16699
1	2	1	21916	21976	0	60	14510
1	3	0	21916	27089	0	5173	14550
1	4	1	21916	23765	0	1849	17177
1	5	1	21916	23067	0	1151	14896
1	6	0	21916	21949	0	33	17837
1	6	0	21949	23802	1	1853	17837
1	7	1	21916	22999	1	1083	18612
1	8	1	21916	24659	0	2743	16401
1	9	0	21916	22006	0	90	19633
1	10	0	21916	23691	0	1775	17948
1	11	1	21916	22470	0	554	14488
1	12	0	21916	24201	0	2285	16684
1	12	0	24201	24955	1	754	16684
1	13	0	21916	21951	0	35	17085
1	13	0	21951	24554	1	2603	17085
1	14	0	21916	21946	0	30	16824
1	14	1	21946	24625	1	2679	16824
1	15	0	21916	22422	0	506	17888
1	15	0	22422	23751	1	1329	17888
1	16	0	21916	23628	0	1712	18011
1	17	0	21916	23896	0	1980	17743
1	18	1	21916	23275	1	1359	16971
1	19	0	21916	21961	0	45	16993
1	19	1	21961	23665	1	1704	16993
1	20	1	21916	22364	1	448	17821
2	1	0	38615	41639	1	3024	0
2	2	1	36426	36486	0	60	0
2	3	0	36466	41639	0	5173	0
2	4	1	39093	40942	0	1849	0
2	5	1	36812	37963	0	1151	0
2	6	0	39753	39786	0	33	0
2	6	0	39786	41639	1	1853	0
2	7	1	40528	41611	1	1083	0
2	8	1	38317	41060	0	2743	0
2	9	0	41549	41639	0	90	0
2	10	0	39864	41639	0	1775	0
2	11	1	36404	36958	0	554	0
2	12	0	38600	40885	0	2285	0
2	12	0	40885	41639	1	754	0
2	13	0	39001	39036	0	35	0
2	13	0	39036	41639	1	2603	0
2	14	0	38740	38770	0	30	0
2	14	1	38770	41449	1	2679	0
2	15	0	39804	40310	0	506	0
2	15	0	40310	41639	1	1329	0
2	16	0	39927	41639	0	1712	0
2	17	0	39659	41639	0	1980	0
2	18	1	38887	40246	1	1359	0
2	19	0	38909	38954	0	45	0
2	19	1	38954	40658	1	1704	0
2	20	1	39737	40185	1	448	0
;

proc phreg data=t COVS (AGGREGATE);
model (t1, t2) * hypertension (0) = drug/risklimits; 
id id;
by g;
run;

proc phreg data=t COVS (AGGREGATE);
model time * hypertension (0) = drug/risklimits; 
id id;
by g;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 16:56:24 GMT</pubDate>
    <dc:creator>ffgsdf</dc:creator>
    <dc:date>2023-06-14T16:56:24Z</dc:date>
    <item>
      <title>using time-on-study and counting process with different time-based change the results in proc phreg</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/using-time-on-study-and-counting-process-with-different-time/m-p/880747#M43558</link>
      <description>&lt;P&gt;I recently use different time-based to model cox proportional model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have read some papers that the counting process should be the same results as it does in only one survival time variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I found something wrong here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my following example, if i use the counting process, the group 1 and group 2 are actually the same data, but with different time scale. The t1 and t 2 variables in the group 2 have a different time-based, so the t1 and t2 plus the time_shift is the t1 and t2 in the group 2 with the same id.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the two groups have the same period of t1 to t2, and the same id, drug use, and outcome (i.e., hypertension).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if i use the counting process, i will get a different HR (for group 1 and group, i.e., 2, 1.07 and 2.26, respectively).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i use hte time-on-study, i will get another different estimate, 1.19, but they are the same in the two groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to replicate in the R, the results are the estiamtes are the same in counting process or&amp;nbsp;time-on-study, they are 2.26 and 1.19, although they are still different in&amp;nbsp;counting process and&amp;nbsp;time-on-study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone explain why they are different?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
INPUT g	id	hypertension	t1	t2	drug	time	time_shift;
cards;
1	1	0	21916	24940	1	3024	16699
1	2	1	21916	21976	0	60	14510
1	3	0	21916	27089	0	5173	14550
1	4	1	21916	23765	0	1849	17177
1	5	1	21916	23067	0	1151	14896
1	6	0	21916	21949	0	33	17837
1	6	0	21949	23802	1	1853	17837
1	7	1	21916	22999	1	1083	18612
1	8	1	21916	24659	0	2743	16401
1	9	0	21916	22006	0	90	19633
1	10	0	21916	23691	0	1775	17948
1	11	1	21916	22470	0	554	14488
1	12	0	21916	24201	0	2285	16684
1	12	0	24201	24955	1	754	16684
1	13	0	21916	21951	0	35	17085
1	13	0	21951	24554	1	2603	17085
1	14	0	21916	21946	0	30	16824
1	14	1	21946	24625	1	2679	16824
1	15	0	21916	22422	0	506	17888
1	15	0	22422	23751	1	1329	17888
1	16	0	21916	23628	0	1712	18011
1	17	0	21916	23896	0	1980	17743
1	18	1	21916	23275	1	1359	16971
1	19	0	21916	21961	0	45	16993
1	19	1	21961	23665	1	1704	16993
1	20	1	21916	22364	1	448	17821
2	1	0	38615	41639	1	3024	0
2	2	1	36426	36486	0	60	0
2	3	0	36466	41639	0	5173	0
2	4	1	39093	40942	0	1849	0
2	5	1	36812	37963	0	1151	0
2	6	0	39753	39786	0	33	0
2	6	0	39786	41639	1	1853	0
2	7	1	40528	41611	1	1083	0
2	8	1	38317	41060	0	2743	0
2	9	0	41549	41639	0	90	0
2	10	0	39864	41639	0	1775	0
2	11	1	36404	36958	0	554	0
2	12	0	38600	40885	0	2285	0
2	12	0	40885	41639	1	754	0
2	13	0	39001	39036	0	35	0
2	13	0	39036	41639	1	2603	0
2	14	0	38740	38770	0	30	0
2	14	1	38770	41449	1	2679	0
2	15	0	39804	40310	0	506	0
2	15	0	40310	41639	1	1329	0
2	16	0	39927	41639	0	1712	0
2	17	0	39659	41639	0	1980	0
2	18	1	38887	40246	1	1359	0
2	19	0	38909	38954	0	45	0
2	19	1	38954	40658	1	1704	0
2	20	1	39737	40185	1	448	0
;

proc phreg data=t COVS (AGGREGATE);
model (t1, t2) * hypertension (0) = drug/risklimits; 
id id;
by g;
run;

proc phreg data=t COVS (AGGREGATE);
model time * hypertension (0) = drug/risklimits; 
id id;
by g;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 16:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/using-time-on-study-and-counting-process-with-different-time/m-p/880747#M43558</guid>
      <dc:creator>ffgsdf</dc:creator>
      <dc:date>2023-06-14T16:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: using time-on-study and counting process with different time-based change the results in proc ph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/using-time-on-study-and-counting-process-with-different-time/m-p/881294#M43604</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7185"&gt;@ffgsdf&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry to see that nobody has replied yet. I have investigated this question a bit, using a simplified input dataset -- basically a subset of only five patients from your sample data, with shifted and rounded times, but I think maintaining the relevant characteristics of the original data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input g id hypertension t1 t2 drug time time_shift;
cards;
1  4 1   100  2000 0 1900 17000
1  8 1   100  3000 0 2900 16400
1 14 0   100   130 0   30 16800
1 14 1   130  2800 1 2670 16800
1 15 0   100   600 0  500 17900
1 15 0   600  1900 1 1300 17900
1 20 1   100   500 1  400 17800
2  4 1 17100 19000 0 1900     0
2  8 1 16500 19400 0 2900     0
2 14 0 16900 16930 0   30     0
2 14 1 16930 19600 1 2670     0
2 15 0 18000 18500 0  500     0
2 15 0 18500 19800 1 1300     0
2 20 1 17900 18300 1  400     0
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With this HAVE dataset it is feasible to reproduce at least the parameter estimates and hazard ratios from the two PROC PHREG steps by manual calculation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Luckily, there are no ties in the event times, so the formula for the partial likelihood function (to be maximized) simplifies from the expressions (e.g., Breslow's) given in the documentation:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_details05.htm" target="_blank" rel="noopener"&gt;Partial Likelihood Function for the Cox Model&lt;/A&gt;. The relevant formula can also be found in &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_references.htm#statug_phregklei_j03" target="_blank" rel="noopener"&gt;Klein and Moeschberger (2003)&lt;/A&gt;: formula (9.2.1) on page 297.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is only one dichotomous covariate, variable &lt;FONT face="courier new,courier"&gt;drug&lt;/FONT&gt;, which simplifies the formula further: Only one parameter (&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) is to be estimated and the partial likelihood &lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) is a product of a few fractions -- one for each event time. The numerators of these fractions are either exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) or exp(0)=1, depending on whether the relevant value of &lt;FONT face="courier new,courier"&gt;drug&lt;/FONT&gt; equals 1 or 0. The denominators are sums of a few of such terms (i.e.,&amp;nbsp;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) or 1), the number of which depends on the risk set at the relevant point in time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's start with group 1 (&lt;FONT face="courier new,courier"&gt;g=1&lt;/FONT&gt;) using the counting process data (&lt;FONT face="courier new,courier"&gt;t1&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;t2&lt;/FONT&gt;). We have four distinct event times: t&lt;SUB&gt;1&lt;/SUB&gt;=500 (from id 20; not to be confused with &lt;EM&gt;variable&lt;/EM&gt; &lt;FONT face="courier new,courier"&gt;t1&lt;/FONT&gt;), t&lt;SUB&gt;2&lt;/SUB&gt;=2000 (from id 4), t&lt;SUB&gt;3&lt;/SUB&gt;=2800 (id 14) and t&lt;SUB&gt;4&lt;/SUB&gt;=3000 (id 8). Note that id 15 (&lt;FONT face="courier new,courier"&gt;hypertension=0&lt;/FONT&gt;) contributes only censored observations, no event times. The first factor in the product &lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;), i.e., the factor for event time t&lt;SUB&gt;1&lt;/SUB&gt;=500, has the numerator&amp;nbsp;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) because the patient with &lt;FONT face="courier new,courier"&gt;id=20&lt;/FONT&gt;&amp;nbsp;was on drug (&lt;FONT face="courier new,courier"&gt;drug=1&lt;/FONT&gt;) when the event (&lt;FONT face="courier new,courier"&gt;hypertension=1&lt;/FONT&gt;) occurred. The denominator is 1 + 1 +&amp;nbsp;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) + 1 +&amp;nbsp;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) = 3 + 2exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) -- the sum of the corresponding terms for the patients at risk at time t&lt;SUB&gt;1&lt;/SUB&gt;=500: &lt;FONT face="courier new,courier"&gt;id=4&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt; (hence the first 1),&amp;nbsp;&lt;FONT face="courier new,courier"&gt;id=8&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt; (hence the second 1),&amp;nbsp;&lt;FONT face="courier new,courier"&gt;id=14&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;drug=1&lt;/FONT&gt; (hence exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)),&amp;nbsp; and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;id=15&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt; (at that time, hence the third 1), and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;id=20&lt;/FONT&gt;&amp;nbsp;itself with &lt;FONT face="courier new,courier"&gt;drug=1&lt;/FONT&gt;&amp;nbsp;(hence the second exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;), as in the numerator).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second factor in the product &lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;), i.e., the factor for event time t&lt;SUB&gt;2&lt;/SUB&gt;=2000, has the numerator 1&amp;nbsp;because the corresponding patient (&lt;FONT face="courier new,courier"&gt;id=4&lt;/FONT&gt;) was not on drug (&lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt;) when the event (&lt;FONT face="courier new,courier"&gt;hypertension=1&lt;/FONT&gt;) occurred. The denominator is 1 + 1 +&amp;nbsp;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)&amp;nbsp;-- the sum of the corresponding terms for the patients at risk at time t&lt;SUB&gt;2&lt;/SUB&gt;=2000: &lt;FONT face="courier new,courier"&gt;id=4&lt;/FONT&gt;&amp;nbsp;itself with &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt; (hence the first 1),&amp;nbsp;&lt;FONT face="courier new,courier"&gt;id=8&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt; (hence the second 1) and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;id=14&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;drug=1&lt;/FONT&gt; (hence exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)). The other two patients are no longer at risk at time t&lt;SUB&gt;2&lt;/SUB&gt;=2000 (id 15 was censored at time 1900, id 20 has had their event already at time 500).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, we obtain&amp;nbsp;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)/(1+exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)) for the third factor in the product&amp;nbsp;&lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) and simply 1/1 = 1 for the fourth factor, so&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) = exp(2&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)/((3+2exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*(2+exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*(1+exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)))&lt;/STRONG&gt;. This function (see a plot) exhibits a unique maximum at &lt;FONT face="symbol"&gt;b&lt;/FONT&gt;≈1.07307 -- matching the parameter estimate from PROC PHREG exactly. The hazard ratio of "&lt;FONT face="courier new,courier"&gt;drug=1&lt;/FONT&gt; vs. &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt;" is therefore exp(&lt;FONT face="symbol"&gt;b)&lt;/FONT&gt;=exp(1.07307)≈2.924, again matching the&amp;nbsp;PROC PHREG output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Performing the analogous calculation for the second group (&lt;FONT face="courier new,courier"&gt;g=2&lt;/FONT&gt;) -- the four event times are now&amp;nbsp;t&lt;SUB&gt;1&lt;/SUB&gt;=18300 (from id 20), t&lt;SUB&gt;2&lt;/SUB&gt;=19000 (id 4), t&lt;SUB&gt;3&lt;/SUB&gt;=19400 (id &lt;U&gt;8&lt;/U&gt;) and t&lt;SUB&gt;4&lt;/SUB&gt;=19600 (id &lt;U&gt;14&lt;/U&gt;) --, it becomes obvious that a &lt;EM&gt;constant&lt;/EM&gt; &lt;FONT face="courier new,courier"&gt;time_shift&lt;/FONT&gt; would not change the results, whereas&amp;nbsp;&lt;FONT face="courier new,courier"&gt;time_shift&lt;/FONT&gt;&amp;nbsp;values &lt;EM&gt;varying&lt;/EM&gt; between patients have a potential impact. Indeed, this is the case for your data (and for our simplified dataset HAVE as well). For example, patients 14 and 15 are now in the risk set at the event time of patient 8 (t&lt;SUB&gt;3&lt;/SUB&gt;=19400), which was not the case for &lt;FONT face="courier new,courier"&gt;g=1&lt;/FONT&gt;. We end up with a &lt;EM&gt;different partial likelihood function&lt;/EM&gt;, &lt;STRONG&gt;&lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) = exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)/((3+2exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*(2+2exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*(1+2exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*2)&lt;/STRONG&gt;&amp;nbsp;(one factor exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) cancels out) and, not surprisingly, this function has its maximum at a quite different place:&amp;nbsp;&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;≈-0.82168 -- matching the parameter estimate from PROC PHREG &lt;FONT face="helvetica"&gt;(&lt;/FONT&gt;-0.821&lt;STRONG&gt;5&lt;/STRONG&gt;8&lt;FONT face="helvetica"&gt;)&lt;/FONT&gt; almost exactly. Why only "almost"? It turns out that it takes a tighter convergence criterion to get the more accurate parameter estimate&amp;nbsp;-0.821&lt;STRONG&gt;6&lt;/STRONG&gt;8 from PROC PHREG: adding the option &lt;FONT face="courier new,courier"&gt;xconv=1e-8&lt;/FONT&gt;, for instance, to the MODEL statement does the trick. The hazard ratio exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)≈0.440 this time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is a question for the &lt;EM&gt;study statistician&lt;/EM&gt; familiar with the research question (and the subject matter in general), what time shifts (if any) are appropriate to ensure that &lt;EM&gt;corresponding&lt;/EM&gt; times of different patients are "synchronized" so that the risk sets at each event time are built correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now let's turn to the second PROC PHREG step, using variable &lt;FONT face="courier new,courier"&gt;time&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;t1&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;t2&lt;/FONT&gt;, with event times&amp;nbsp;t&lt;SUB&gt;1&lt;/SUB&gt;=400 (id 20), t&lt;SUB&gt;2&lt;/SUB&gt;=1900 (id 4), t&lt;SUB&gt;3&lt;/SUB&gt;=2670 (id 14) and t&lt;SUB&gt;4&lt;/SUB&gt;=2900 (id 8). I strongly suspect that this is &lt;EM&gt;inappropriate&lt;/EM&gt; with the dataset in its current form. It appears to me that the two observations for id=14 are treated by PROC PHREG as if they were from different (albeit somewhat related [ID statement]) patients: one with &lt;FONT face="courier new,courier"&gt;drug=1&lt;/FONT&gt; and an event, one with &lt;FONT face="courier new,courier"&gt;drug=0&lt;/FONT&gt; and censored. Similarly,&amp;nbsp;the two observations with id=15 have different &lt;FONT face="courier new,courier"&gt;drug&lt;/FONT&gt; values, but both are censored. The different &lt;FONT face="courier new,courier"&gt;drug&lt;/FONT&gt; values are &lt;EM&gt;not&lt;/EM&gt; treated as they should for a time-dependent covariate. As a matter of fact, we obtain yet another partial likelihood function, &lt;STRONG&gt;&lt;EM&gt;L&lt;/EM&gt;(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;) = exp(2&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)/((3+&lt;U&gt;3&lt;/U&gt;exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*(2+exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;))*(1+exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)))&lt;/STRONG&gt;, resulting in the estimate&amp;nbsp;&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;≈0.94061 (again, use &lt;FONT face="courier new,courier"&gt;xconv=1e-8&lt;/FONT&gt; to get the last two decimals right) and the hazard ratio exp(&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;)≈2.561.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To correct this, you can aggregate the data to one observation per patient and then use programming statements in the PROC PHREG step to create&amp;nbsp;a really time-dependent covariate &lt;FONT face="courier new,courier"&gt;d&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have_td; /* "td" indicating the time-dependent covariate */
set have;
by g id;
if last.id;
run;

proc phreg data=have_td COVS (AGGREGATE);
model time * hypertension (0) = d/risklimits; 
*id id; /* ID statement is now redundant */
where g=1; /* no difference between the groups */
if id=14 then d=(time&amp;gt;30);
else if id=15 then d=(time&amp;gt;500);
else d=drug;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(In the PROC PHREG step I used hardcoded IDs and time thresholds for simplicity; see&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_examples07.htm" target="_blank" rel="noopener"&gt;Example 92.7 Time-Dependent Repeated Measurements of a Covariate&lt;/A&gt; for another technique.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, the results, parameter estimate&amp;nbsp;&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;≈1.07307 and hazard ratio exp(&lt;FONT face="symbol"&gt;b)&lt;/FONT&gt;≈2.924, match exactly those from &lt;FONT face="courier new,courier"&gt;g=1&lt;/FONT&gt; with the data in counting process style (see above) and are not impacted by the &lt;EM&gt;constant&lt;/EM&gt; time shift from &lt;FONT face="courier new,courier"&gt;time=0&lt;/FONT&gt; to &lt;FONT face="courier new,courier"&gt;t1=100&lt;/FONT&gt; as the start time.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2023 22:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/using-time-on-study-and-counting-process-with-different-time/m-p/881294#M43604</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-06-17T22:41:43Z</dc:date>
    </item>
  </channel>
</rss>

