# Confidence interval of Kaplan-Meier and Cox analysis

I have a question about the 95% confidence interval of KM and Cox. Excuse me that I am not familiar with their deep statistic theory but I thought the p-value, HR and 95%CI should be close to each other in terms of a two-group analysis.

Here is my example.

group   OS  OS.time
C1  0   0.77260274
C2  1   2.61369863
C1  1   2.136986301
C1  0   1.095890411
C2  0   0.821917808
C2  1   1.967123288
C1  0   7.131506849
C1  0   2.794520548
C2  1   4.093150685
C2  1   4.997260274
C1  0   1.120547945
C2  0   1.6
C1  0   0.775342466
C2  0   1.493150685
C1  0   7.02739726
C2  1   3.342465753
C2  0   1.506849315
C1  0   2.073972603
C1  0   8.224657534
C2  0   4.438356164
C2  0   8.180821918
C2  1   3.698630137
C2  0   1.997260274
C1  0   1.490410959
C2  0   4.243835616
C2  1   1.726027397
C2  1   3.695890411
C1  0   3.405479452
C2  1   1.361643836
C2  0   3.876712329
C1  0   2.117808219
C2  0   7.408219178
C1  0   3.994520548
C2  0   0.164383562
C1  0   5.178082192


First, I used KM analysis and calculate 95%CI manually,

fitd=survdiff(Surv(OS.time, OS)~ group, data=tmp, na.action=na.exclude)
p.val <- 1-pchisq(fitd$chisq, length(fitd$n)-1) #0.127
HR = (fitd$obs[2]/fitd$exp[2])/(fitd$obs[1]/fitd$exp[1]) #0.232
up95 = exp(log(HR) + qnorm(0.975)*sqrt(1/fitd$exp[2]+1/fitd$exp[1])) #0.874
low95 = exp(log(HR) - qnorm(0.975)*sqrt(1/fitd$exp[2]+1/fitd$exp[1])) #0.061


Second, I used univariate cox analysis and it calculate 95%CI automatically,

cox <- coxph(Surv(OS.time, OS) ~ group, data = tmp)
summary(cox)
> summary(cox)
Call:
coxph(formula = Surv(OS.time, OS) ~ group, data = tmp)

n= 35, number of events= 10

coef exp(coef) se(coef)      z Pr(>|z|)
groupC2 -1.4768    0.2284   1.0573 -1.397    0.162

exp(coef) exp(-coef) lower .95 upper .95
groupC2    0.2284      4.379   0.02875     1.814

Concordance= 0.589  (se = 0.09 )
Rsquare= 0.078   (max possible= 0.795 )
Likelihood ratio test= 2.83  on 1 df,   p=0.09
Wald test            = 1.95  on 1 df,   p=0.2
Score (logrank) test = 2.33  on 1 df,   p=0.1


You could see the pvalue for both is not significant, and HR is quite close to 0.23, but 95%CI is quite different in terms of the upper.95 is more than 1, which confused me a lot.

Could anyone explain these two CI to me and which one should I use?