You are on page 1of 9

1.

Data

No Lama_Rawat JK USIA BB HIPERTENSI RIWAYAT Keadaan

1 8 0 77 66 0 1 1
2 11 0 61 60 0 1 1
3 6 1 52 53 0 0 1
4 10 0 40 70 0 1 1
5 3 0 55 72 0 1 1
6 7 0 55 69 0 0 1
7 5 0 49 53 0 0 1
8 4 0 60 49 0 0 1
9 6 0 56 63 0 1 1
10 3 0 49 67 0 1 1
11 12 0 74 48 0 1 1
12 6 0 66 60 0 1 1
13 6 0 71 54 0 0 1
14 6 1 53 53 0 0 1
15 1 0 66 57 0 1 0
16 6 0 31 60 0 0 1
17 3 1 73 70 1 0 0
18 9 1 61 70 0 0 1
19 1 0 45 67 0 0 1
20 6 0 52 68 0 1 1
21 5 1 55 47 0 1 1
22 10 1 51 51 0 1 1
23 3 0 33 50 0 0 1
24 2 0 59 54 0 1 0
25 5 0 57 57 0 1 1
26 5 0 57 60 0 0 1
27 4 1 85 71 0 0 1
28 6 1 64 64 0 0 1
29 4 1 54 51 0 1 1
30 5 0 55 53 0 1 1
31 7 0 48 55 0 0 1
32 12 0 69 56 0 0 1
33 5 1 62 58 0 0 1
34 12 1 78 48 0 0 1
35 10 0 44 50 0 1 0
36 6 0 69 60 0 1 1
37 4 1 54 65 0 0 1
38 7 0 68 70 0 1 1
39 3 1 44 62 0 0 1
40 3 0 53 66 1 0 0
41 4 0 50 69 0 0 1
42 9 1 54 67 0 1 1
43 8 1 48 53 0 1 1
44 8 1 43 54 0 1 1
45 5 0 38 51 0 1 1
46 6 0 56 48 0 1 0
47 6 0 56 53 1 0 0
48 3 0 51 63 0 1 1
49 8 1 49 47 0 0 1
50 3 1 66 59 0 1 1
51 5 0 64 60 0 0 1
52 9 1 60 60 1 1 0
53 5 0 58 54 0 0 1
54 8 1 45 53 0 0 1
55 5 0 44 60 1 0 1
56 6 0 56 55 0 1 1
57 6 0 64 52 0 0 1
58 3 1 63 60 0 0 1
59 10 0 68 52 0 1 0
60 5 1 59 48 0 0 1
61 15 0 59 50 0 0 1
62 15 0 49 52 1 1 0
63 5 1 72 60 0 1 0
64 6 0 62 53 1 0 1
65 5 1 76 55 0 1 1
66 5 0 53 56 0 1 1
67 3 0 53 60 0 1 1
68 2 0 75 48 0 1 1
69 6 0 58 47 0 1 1
70 7 0 54 60 0 0 1
71 5 0 54 53 0 1 1
72 7 1 79 51 0 1 1
73 3 0 53 53 0 1 1
74 17 1 65 60 1 0 1
75 8 0 62 49 0 1 1
76 11 0 55 60 1 1 0
77 6 0 64 62 0 1 1
78 7 0 47 49 0 1 1
79 4 1 34 53 0 1 1
80 4 0 60 60 0 0 1
81 6 1 59 60 0 0 1
82 8 0 63 72 0 1 0
83 17 0 48 67 0 1 1
84 7 0 62 69 0 0 1
85 5 0 59 70 0 1 1
86 6 0 59 53 0 0 1
87 11 1 79 47 0 1 1
88 4 1 46 60 0 0 1
89 3 0 60 51 0 1 0
90 4 0 47 52 0 1 1
91 5 1 67 49 0 1 0
92 5 1 62 66 0 1 1
93 6 1 46 65 0 0 1
94 8 0 58 57 0 0 1
95 15 0 39 56 0 1 1
96 10 0 48 54 0 1 1
97 5 0 55 50 0 1 1

Keterangan:
 Jenis Kelamin > 1 = Laki-laki , 0 = Perempuan
 Hipertensi (>140/90 mmHg) > 1 = Ya, 0 = Tidak
 Riwayat Penyakit > = 1 = Ada, 0 = Tidak Ada
 Keadaan > 1 = Sembuh, 0 = Tidak Sembuh (Belum Sembuh/Mati)

2. Program dan Output


> #membaca data

> library(readxl)

> diabetes <- read_excel("D:/New folder/diabetes.xlsx", sheet = "diabetes2")

> diabetes

# A tibble: 97 × 7

Lama_Rawat JK USIA BB HIPERTENSI RIWAYAT Keadaan

<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

1 8 0 77 66 0 1 1

2 11 0 61 60 0 1 1

3 6 1 52 53 0 0 1

4 10 0 40 70 0 1 1
5 3 0 55 72 0 1 1

6 7 0 55 69 0 0 1

7 5 0 49 53 0 0 1

8 4 0 60 49 0 0 1

9 6 0 56 63 0 1 1

10 3 0 49 67 0 1 1

# … with 87 more rows

# ℹ Use `print(n = ...)` to see more rows

> #deskriptif

> library(psych)

> describe(diabetes)

vars n mean sd median trimmed mad min max range skew kurtosis se

Lama_Rawat 1 97 6.44 3.29 6 6.05 2.97 1 17 16 1.20 1.45 0.33

JK 2 97 0.34 0.48 0 0.30 0.00 0 1 1 0.66 -1.57 0.05

USIA 3 97 57.09 10.59 56 56.91 10.38 31 85 54 0.11 0.02 1.07

BB 4 97 57.57 7.15 56 57.24 5.93 47 72 25 0.39 -1.00 0.73

HIPERTENSI 5 97 0.09 0.29 0 0.00 0.00 0 1 1 2.76 5.70 0.03

RIWAYAT 6 97 0.57 0.50 1 0.58 0.00 0 1 1 -0.27 -1.95 0.05

Keadaan 7 97 0.85 0.36 1 0.92 0.00 0 1 1 -1.88 1.55 0.04

> summary (diabetes)

Lama_Rawat JK USIA BB HIPERTENSI RIWAYAT Keadaan ...8

Min. : 1.000 Min. :0.0000 Min. :31.00 Min. :47.00 Min. :0.00000 Min. :0.000 Min. :0.0000 Min. : 1

1st Qu.: 4.000 1st Qu.:0.0000 1st Qu.:50.00 1st Qu.:52.00 1st Qu.:0.00000 1st Qu.:0.000 1st Qu.:1.0000 1st
Qu.:25

Median : 6.000 Median :0.0000 Median :56.00 Median :56.00 Median :0.00000 Median :1.000
Median :1.0000 Median :49

Mean : 6.443 Mean :0.3402 Mean :57.09 Mean :57.57 Mean :0.09278 Mean :0.567 Mean :0.8454
Mean :49
3rd Qu.: 8.000 3rd Qu.:1.0000 3rd Qu.:63.00 3rd Qu.:62.00 3rd Qu.:0.00000 3rd Qu.:1.000 3rd Qu.:1.0000
3rd Qu.:73

Max. :17.000 Max. :1.0000 Max. :85.00 Max. :72.00 Max. :1.00000 Max. :1.000 Max. :1.0000 Max.
:97

> #pengujian distribusi data

> library(survminer)

> library(survival)

> library(fitdistrplus)

> Y=diabetes$Lama_Rawat

> a=fitdist(Y, "weibull")

>a

Fitting of the distribution ' weibull ' by maximum likelihood

Parameters:

estimate Std. Error

shape 2.086406 0.1550441

scale 7.296079 0.3760616

> ks.test(Y, "pweibull", shape=2.086 , scale=7.296)

Asymptotic one-sample Kolmogorov-Smirnov test

data: Y

D = 0.16375, p-value = 0.01101

alternative hypothesis: two-sided

Warning message:

In ks.test.default(Y, "pweibull", shape = 2.086, scale = 7.296) :

ties should not be present for the Kolmogorov-Smirnov test

> a=fitdist(Y, "gamma")

>a

Fitting of the distribution ' gamma ' by maximum likelihood

Parameters:
estimate Std. Error

shape 4.1211148 0.56942001

rate 0.6396505 0.09399323

> ks.test(Y, "pgamma", shape=4.121 , rate=0.639)

Asymptotic one-sample Kolmogorov-Smirnov test

data: Y

D = 0.14103, p-value = 0.04219

alternative hypothesis: two-sided

Warning message:

In ks.test.default(Y, "pgamma", shape = 4.121, rate = 0.639) :

ties should not be present for the Kolmogorov-Smirnov test

> a=fitdist(Y, "exp")

>a

Fitting of the distribution ' exp ' by maximum likelihood

Parameters:

estimate Std. Error

rate 0.1552 0.01575752

> ks.test(Y, "pexp")

Asymptotic one-sample Kolmogorov-Smirnov test

data: Y

D = 0.90898, p-value < 2.2e-16

alternative hypothesis: two-sided

Warning message:

In ks.test.default(Y, "pexp") :

ties should not be present for the Kolmogorov-Smirnov test


> a=fitdist(Y, "lnorm")

>a

Fitting of the distribution ' lnorm ' by maximum likelihood

Parameters:

estimate Std. Error

meanlog 1.7367992 0.05284575

sdlog 0.5204703 0.03736697

> ks.test(Y, "plnorm")

Asymptotic one-sample Kolmogorov-Smirnov test

data: Y

D = 0.82279, p-value < 2.2e-16

alternative hypothesis: two-sided

Warning message:

In ks.test.default(Y, "plnorm") :

ties should not be present for the Kolmogorov-Smirnov test

> #Pengujian Asumsi Cox-PH

> modelcoxph=coxph(Surv(Lama_Rawat, Keadaan) ~ JK + USIA + BB + HIPERTENSI + RIWAYAT , data = diabetes)

> asumsi.ph=cox.zph(modelcoxph)

> asumsi.ph

chisq df p

JK 2.112 1 0.15

USIA 1.807 1 0.18

BB 0.498 1 0.48

HIPERTENSI 0.101 1 0.75

RIWAYAT 0.791 1 0.37

GLOBAL 3.783 5 0.58


> #Pemodelan Regresi Cox-PH

> zmodelcoxph=coxph(Surv(Lama_Rawat, Keadaan) ~ JK + USIA + BB + HIPERTENSI + RIWAYAT, data = diabetes)

> zmodelcoxph

Call:

coxph(formula = Surv(Lama_Rawat, Keadaan) ~ JK + USIA + BB +

HIPERTENSI + RIWAYAT, data = diabetes)

coef exp(coef) se(coef) z p

JK 0.129658 1.138439 0.243347 0.533 0.59416

USIA -0.009243 0.990800 0.010284 -0.899 0.36879

BB 0.012043 1.012116 0.015136 0.796 0.42623

HIPERTENSI -1.680757 0.186233 0.602986 -2.787 0.00531

RIWAYAT -0.420387 0.656793 0.230976 -1.820 0.06875

Likelihood ratio test=16.85 on 5 df, p=0.004792

n= 97, number of events= 82

> #pemilihan model terbaik

> model.a=coxph(Surv(Lama_Rawat, Keadaan) ~ JK + USIA + BB + HIPERTENSI + RIWAYAT, data = diabetes)

> model.b=coxph(Surv(Lama_Rawat, Keadaan) ~ USIA + BB + HIPERTENSI + RIWAYAT, data = diabetes)

> model.c=coxph(Surv(Lama_Rawat, Keadaan) ~ BB + HIPERTENSI + RIWAYAT, data = diabetes)

> model.d=coxph(Surv(Lama_Rawat, Keadaan) ~ HIPERTENSI + RIWAYAT, data = diabetes)

> model.e=coxph(Surv(Lama_Rawat, Keadaan) ~ HIPERTENSI, data = diabetes)

> model.e

Call:

coxph(formula = Surv(Lama_Rawat, Keadaan) ~ HIPERTENSI, data = diabetes)

coef exp(coef) se(coef) z p

HIPERTENSI -1.6013 0.2016 0.5963 -2.685 0.00724


Likelihood ratio test=11.81 on 1 df, p=0.0005903

n= 97, number of events= 82

> Aic.model=c(AIC(model.a), AIC(model.b), AIC(model.c), AIC(model.d))

> Aic.model

[1] 589.7097 587.9909 586.7178 585.4072

You might also like