데이타를 읽어온다.
require(ztable)
## Loading required package: ztable
## Welcome to package ztable ver 0.1.5
require(moonBook)
## Loading required package: moonBook
options(ztable.type="html")
#options(ztable.type="latex")
MI=read.csv("inf.csv",stringsAsFactors=FALSE)
#MI$AVB
MI$CAVB=0
MI$CAVB[MI$AVB=="Advanced"]=1
MI$CAVB[MI$AVB=="Complete"]=1
#str(MI$CAVB)
표를 만든다.
res=mytable(Temporary1~.,data=MI)
ztable(res)
p | |||
---|---|---|---|
(N=274) | (N=21) | ||
Age | 61.0 ± 12.6 | 66.5 ± 11.1 | 0.053 |
res1=mytable(Temporary1~.,data=MI[MI$CAVB==1,])
ztable(res1)
p | |||
---|---|---|---|
(N=59) | (N=16) | ||
Age | 62.8 ± 10.8 | 67.4 ± 11.1 | 0.130 |
ztable(mytable(CAVB~.,data=MI))
p | |||
---|---|---|---|
(N=220) | (N=75) | ||
Age | 60.5 ± 13.0 | 63.8 ± 10.9 | 0.055 |
생존분석
require(survival)
Loading required package: survival
Loading required package: splines
MI$Sur=Surv(MI$Fuday,MI$MACE==1)
fit=survfit(Sur~1,data=MI)
fit
Call: survfit(formula = Sur ~ 1, data = MI)
records n.max n.start events median 0.95LCL 0.95UCL
295 295 295 22 NA NA NA
plot(fit)
plot(fit,conf.int=FALSE)
fit1=survfit(Sur~Temporary1,data=MI)
plot(fit1,col=1:2,lty=1:2,xlim=c(0,600))
legend("bottomleft",legend=c("No","Yes"),col=1:2,lty=1:2)
survdiff(Sur~Temporary1,data=MI)
Call:
survdiff(formula = Sur ~ Temporary1, data = MI)
N Observed Expected (O-E)^2/E (O-E)^2/V
Temporary1=0 274 19 20.35 0.089 1.18
Temporary1=1 21 3 1.65 1.094 1.18
Chisq= 1.2 on 1 degrees of freedom, p= 0.277
out=coxph(Sur~Temporary1,data=MI)
summary(out)
Call:
coxph(formula = Sur ~ Temporary1, data = MI)
n= 295, number of events= 22
coef exp(coef) se(coef) z Pr(>|z|)
Temporary1 0.6642 1.9429 0.6217 1.068 0.285
exp(coef) exp(-coef) lower .95 upper .95
Temporary1 1.943 0.5147 0.5745 6.571
Concordance= 0.519 (se = 0.031 )
Rsquare= 0.003 (max possible= 0.529 )
Likelihood ratio test= 0.97 on 1 df, p=0.3243
Wald test = 1.14 on 1 df, p=0.2853
Score (logrank) test = 1.18 on 1 df, p=0.2766
out1=mycph(Sur~.,data=MI)
mycph : perform coxph of individual expecting variables
Call: Sur ~ ., data= MI
MACE was excluded : infinite
CASSNo1st RPL CASSNodLCX CASSNodRCA CASSNomLCX CASSNomRCA CASSNoOM1 CASSNoOM2 CASSNopLAD CASSNopLCX CASSNopRCA CASSNorPDA CASSNorPL CASSNoRPL was excluded : infinite
DXNSTEMI DXold MI DXSTEMI was excluded : infinite
EKGDxanterior, inferior EKGDxanterior, inferior, posterior EKGDxinferior EKGDxinferior, lateral EKGDxinferior, lateral, posterior EKGDxinferior, lateral, RV EKGDxinferior, posterior EKGDxinferior, posterior, RV EKGDxinferior, RV was excluded : infinite
AI was excluded : infinite
RVI was excluded : infinite
RHYTHMBPCIJunctional escape RHYTHMBPCIjunctional rhythm RHYTHMBPCIRSR RHYTHMBPCISinus RHYTHMBPCIsinus bradycardia RHYTHMBPCIventricular escape RHYTHMBPCIVentricular escape RHYTHMBPCIventricular rhythm was excluded : infinite
Rate> 60 Rate>60bpm Rate40-60 Rate40-60bpm was excluded : infinite
AVB0 AV Block AVB1st degree AVBAdvanced AVBComplete was excluded : infinite
Temporarybefore PCI, removed at Cath Room Temporaryperformed after PCI Temporaryperformed after PCI, removed at ward Temporaryperformed before PCI,removed at ward was excluded : infinite
out1
HR lcl ucl p
Age 1.07 1.03 1.11 0.001
SexM 0.58 0.25 1.35 0.205
death 35.40 14.97 83.71 0.000
MI 19.60 7.43 51.72 0.000
TVR 18.63 6.72 51.63 0.000
Stroke 14.91 4.85 45.80 0.000
Fuday 0.93 0.90 0.96 0.000
Attempted 1.41 0.79 2.51 0.250
SuccessfullyDilated 1.22 0.64 2.32 0.556
VesselR 1.68 0.39 7.27 0.486
N2BMin 0.99 0.94 1.04 0.676
D2BMin 1.00 1.00 1.00 0.883
FT 0.99 0.96 1.03 0.733
Contrast 0.99 0.99 1.00 0.140
EntryRadial 0.69 0.29 1.66 0.412
EF 0.94 0.91 0.98 0.007
Ht 0.95 0.91 0.99 0.020
WT 0.94 0.91 0.98 0.001
FBS 1.00 1.00 1.01 0.046
HbA1c 1.20 0.93 1.54 0.160
Cr 2.14 1.34 3.43 0.001
CrMax 1.73 1.29 2.33 0.000
CPKMax 1.00 1.00 1.00 0.248
CKMB 1.00 1.00 1.00 0.640
Trop 0.99 0.87 1.12 0.826
TC 0.98 0.97 0.99 0.001
LDL 0.98 0.96 0.99 0.000
HDL 0.99 0.96 1.03 0.695
TG 1.00 0.99 1.00 0.246
hs.CRP 1.01 0.93 1.11 0.776
DM 1.44 0.60 3.46 0.413
HBP 2.85 1.05 7.74 0.040
IHD 4.57 1.95 10.72 0.000
CVA 1.65 0.38 7.13 0.504
PAD 4.29 0.57 32.15 0.157
CKD 1.16 0.16 8.68 0.885
smoking 0.71 0.44 1.12 0.139
Statin 3.74 1.49 9.40 0.005
HD 1.04 0.95 1.13 0.390
LWI 0.81 0.24 2.75 0.734
precordialSTdep 0.76 0.30 1.96 0.575
BBBLBBB 2.89 0.38 21.87 0.304
BBBRBBB 2.55 0.59 11.04 0.211
BBBVentricular 2.33 0.31 17.58 0.410
VTVF 2.19 0.73 6.53 0.162
CPR 5.41 1.82 16.09 0.002
DC 3.32 1.12 9.86 0.031
IABP 3.28 0.96 11.20 0.057
ECMO 40.29 4.96 327.55 0.001
Shock 4.88 2.11 11.27 0.000
Noreflow 1.02 0.13 7.67 0.988
Temporary1 1.94 0.57 6.57 0.285
CAVB 0.89 0.33 2.40 0.811
HRplot(out1,sig.level=0.05)
out2=coxph(Sur~Temporary1+Shock+CPR+Cr+Age+LDL,data=MI)
HRplot(out2,show.CI=TRUE,type=2)
out1=mycph(Sur~.-CAVB-TVR-Stroke-DX-AI-ECMO,data=MI[MI$CAVB==1,])
mycph : perform coxph of individual expecting variables
Call: Sur ~ . - CAVB - TVR - Stroke - DX - AI - ECMO, data= [ Sur ~ . - CAVB - TVR - Stroke - DX - AI - ECMO, data= MI Sur ~ . - CAVB - TVR - Stroke - DX - AI - ECMO, data= MI$CAVB == 1 Sur ~ . - CAVB - TVR - Stroke - DX - AI - ECMO, data=
SexM was excluded : infinite
MACE was excluded : infinite
CASSNomLCX CASSNomRCA CASSNoOM1 CASSNopRCA CASSNorPL CASSNoRPL was excluded : infinite
VesselR was excluded : infinite
CVA was excluded : infinite
PAD was excluded : infinite
Statin was excluded : infinite
EKGDxinferior, lateral EKGDxinferior, posterior EKGDxinferior, posterior, RV EKGDxinferior, RV was excluded : infinite
precordialSTdep was excluded : infinite
RVI was excluded : infinite
RHYTHMBPCIJunctional escape RHYTHMBPCIjunctional rhythm RHYTHMBPCIRSR RHYTHMBPCIsinus bradycardia RHYTHMBPCIventricular escape RHYTHMBPCIVentricular escape was excluded : infinite
Rate>60bpm Rate40-60 Rate40-60bpm was excluded : infinite
AVBComplete was excluded : infinite
BBBLBBB BBBRBBB BBBVentricular was excluded : infinite
IABP was excluded : infinite
Shock was excluded : infinite
Temporarybefore PCI, removed at Cath Room Temporaryperformed after PCI Temporaryperformed after PCI, removed at ward Temporaryperformed before PCI,removed at ward was excluded : infinite
out1
HR lcl ucl p
Age 1.01 0.92 1.11 0.842
death 42.01 4.36 404.29 0.001
MI 2.84 0.15 55.62 0.491
Fuday 0.93 0.87 1.00 0.043
Attempted 1.07 0.20 5.64 0.935
SuccessfullyDilated 1.16 0.22 6.03 0.857
N2BMin 0.99 0.90 1.09 0.860
D2BMin 1.00 1.00 1.01 0.371
FT 1.00 0.93 1.09 0.907
Contrast 1.00 0.99 1.01 0.961
EntryRadial 0.99 0.16 6.01 0.995
EF 0.95 0.88 1.02 0.147
Ht 0.97 0.86 1.09 0.612
WT 0.92 0.83 1.02 0.132
FBS 1.00 0.99 1.01 0.758
HbA1c 1.14 0.64 2.04 0.647
Cr 3.89 1.65 9.19 0.002
CrMax 2.42 1.39 4.23 0.002
CPKMax 1.00 1.00 1.00 0.263
CKMB 1.00 1.00 1.01 0.156
Trop 1.09 0.93 1.28 0.297
TC 0.97 0.94 1.00 0.026
LDL 0.96 0.92 1.00 0.032
HDL 0.96 0.86 1.08 0.525
TG 1.00 0.99 1.01 0.971
hs.CRP 1.09 0.73 1.64 0.669
DM 0.73 0.07 7.17 0.789
HBP 1.27 0.21 7.62 0.794
IHD 1.53 0.12 19.42 0.743
CKD 5.00 0.52 48.30 0.164
smoking 3.01 0.54 16.69 0.208
HD 1.14 0.96 1.34 0.127
LWI 2.14 0.22 20.64 0.511
VTVF 2.43 0.37 16.09 0.356
CPR 5.00 0.52 48.30 0.164
DC 3.38 0.49 23.42 0.218
Noreflow 4.10 0.42 40.07 0.225
Temporary1 1.84 0.29 11.73 0.520
HRplot(out1,sig.level=0.05)
out2=coxph(Sur~Cr+LDL+Temporary1,data=MI[MI$CAVB==1,])
out2
Call:
coxph(formula = Sur ~ Cr + LDL + Temporary1, data = MI[MI$CAVB ==
1, ])
coef exp(coef) se(coef) z p
Cr 1.0069 2.737 0.5031 2.001 0.045
LDL -0.0339 0.967 0.0238 -1.420 0.160
Temporary1 -0.1894 0.827 1.0918 -0.173 0.860
Likelihood ratio test=11.5 on 3 df, p=0.00927 n= 75, number of events= 5
HRplot(out2,show.CI=TRUE,type=2)
require(rms)
Loading required package: rms
Loading required package: Hmisc
Loading required package: grid
Loading required package: lattice
Attaching package: 'lattice'
The following object is masked from 'package:moonBook':
densityplot
Loading required package: Formula
Attaching package: 'Hmisc'
The following objects are masked from 'package:base':
format.pval, round.POSIXt, trunc.POSIXt, units
Loading required package: SparseM
Attaching package: 'SparseM'
The following object is masked from 'package:base':
backsolve
f=npsurv(Sur~Temporary1,data=MI)
survplot(f,xlim=c(0,600),col=1:2,xlab="Follow-up days")
survplot(f,xlim=c(0,600),col=1:2,xlab="Follow-up days",conf="none")
survplot(f,xlim=c(0,600),col=1:2,xlab="Follow-up days",conf="none",label.curve=FALSE,
label.curves=list(keys="lines"))
survplot(f,xlim=c(0,600),col=1:2,xlab="Follow-up days",conf="none",label.curve=FALSE,
label.curves=list(keys="lines"),n.risk=TRUE)
survplot(f,xlim=c(0,600),ylim=c(0.6,1),col=1:2,xlab="Follow-up days",conf="none",
label.curve=FALSE,label.curves=list(keys="lines"),n.risk=TRUE)
text(360,0.92,"log rank p=0.239")
require(GGally)
## Loading required package: GGally
fit1=survfit(Sur~Temporary1,data=MI)
ggsurv(fit1)
## Loading required package: scales