Input Data
library(readxl)
data_sur <- read_excel("D:/data_sp.xlsx")
View(data_sur)
head(data_sur)
## # A tibble: 6 × 7
## gender status ipk asal_sekolah organisasi bekerja lama_studi
## <chr> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
## 1 2 1 3.71 1 1 0 48
## 2 2 1 3.89 1 1 0 48
## 3 1 1 3.47 1 0 1 47
## 4 2 1 3.92 3 1 0 47
## 5 1 1 3.46 1 0 1 47
## 6 1 1 3.40 1 0 1 47
attach(data_sur)
data=data_sur
Data merupakan data kelulusan mahasiswa event nya adalah kelulusan jumlah mahasiswa 838 baik yang sudah lulus maupun yang belum lulus hingga februari 2019
variabel dependen : Gender = laki-laki (1),perempuan (2) Asal_sekolah = SMA (1),MA (2),SMK (3) organisasi = tidak (0),ya (1) bekerja = tidak (0),ya (1)
#Statistika Deskriptif
boxplot(lama_studi~gender, data = data_sur, main = "Boxplot", xlab = "Jenis Kelamin",
ylab = "Waktu hingga lulus (bulan))",
col=c("light blue","pink"), border = "black")
#Statistika Deskriptif
boxplot(lama_studi~asal_sekolah, data = data_sur, main = "Boxplot", xlab = "Asal Sekolah",
ylab = "Waktu hingga lulus (bulan))",
col=c("light blue","pink", "yellow"), border = "black")
Variabel Gender dan Status
xtabs(~ gender + status, data = data_sur)
## status
## gender 0 1
## 1 201 156
## 2 148 333
Interpretasi Dapat disimpulkan bahwa mahasiswa perempuan lebih banyak yang lulus daripada mahasiswa laki-laki.
Variabel Asal sekolah dan Status
xtabs(~ asal_sekolah + status, data = data_sur)
## status
## asal_sekolah 0 1
## 1 110 189
## 2 136 172
## 3 103 128
Interpretasi Mahasiswa yang berasal dari lulusan MA lebih banyak dibandingkan dari SMA dan SMK.
Variabel Organisasi dan Status
xtabs(~ organisasi + status, data = data_sur)
## status
## organisasi 0 1
## 0 215 231
## 1 134 258
Interpretasi Terlihat bahwa lebih sedikit mahasiswa yang mengikuti organisasi daripada yang tidak mengikuti organisasi saat menempuh studi.
Variabel Bekerja dan Status
xtabs(~ bekerja + status, data = data_sur)
## status
## bekerja 0 1
## 0 164 262
## 1 185 227
Interpretasi lebih banyak mahasiswa yang tidak bekerja. Dan terlihat bahwa mahasiswa yang bekerja yang telah lulus lebih banyak 10,2% dibandingkan yang belum lulus tetapi bekerja.
Statistika Deskriptif Lama Studi dan IPK
summary(data_sur$lama_studi)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 47.0 48.0 48.0 50.3 54.0 54.0
summary(data_sur$ipk)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.600 3.082 3.328 3.343 3.591 3.966
Interpretasi rata-rata nilai IPK mahasiswa sebesar 3,343 dengan nilai IPK terkecil 2,6 dan terbesar 3,97. Untuk lama studi paling cepat mahasiswa menempuh studi selama 47 bulan.
Penentuan Distribusidari data waktu survival, yaitu lama studi mahasiswa.
library(survival)
syahrina=survreg(Surv(lama_studi)~1,dist="extreme")
syahrina
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "extreme")
##
## Coefficients:
## (Intercept)
## 51.9063
##
## Scale= 2.859826
##
## Loglik(model)= -2189 Loglik(intercept only)= -2189
## n= 838
summary(syahrina)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "extreme")
## Value Std. Error z p
## (Intercept) 51.9063 0.1047 496 <2e-16
## Log(scale) 1.0508 0.0277 38 <2e-16
##
## Scale= 2.86
##
## Extreme value distribution
## Loglik(model)= -2189 Loglik(intercept only)= -2189
## Number of Newton-Raphson Iterations: 6
## n= 838
fit.wei=survreg(Surv(lama_studi)~1,dist="weibull")
fit.wei
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "weibull")
##
## Coefficients:
## (Intercept)
## 3.947738
##
## Scale= 0.05635799
##
## Loglik(model)= -2180.2 Loglik(intercept only)= -2180.2
## n= 838
summary(fit.wei)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "weibull")
## Value Std. Error z p
## (Intercept) 3.94774 0.00206 1913 <2e-16
## Log(scale) -2.87603 0.02766 -104 <2e-16
##
## Scale= 0.0564
##
## Weibull distribution
## Loglik(model)= -2180.2 Loglik(intercept only)= -2180.2
## Number of Newton-Raphson Iterations: 6
## n= 838
fit.log=survreg(Surv(lama_studi)~1,dist="logistic")
fit.log
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "logistic")
##
## Coefficients:
## (Intercept)
## 50.09018
##
## Scale= 2.004731
##
## Loglik(model)= -2208.4 Loglik(intercept only)= -2208.4
## n= 838
summary(fit.log)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "logistic")
## Value Std. Error z p
## (Intercept) 50.0902 0.1277 392.3 <2e-16
## Log(scale) 0.6955 0.0271 25.7 <2e-16
##
## Scale= 2
##
## Logistic distribution
## Loglik(model)= -2208.4 Loglik(intercept only)= -2208.4
## Number of Newton-Raphson Iterations: 5
## n= 838
fit.gau=survreg(Surv(lama_studi)~1,dist="gaussian")
fit.gau
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "gaussian")
##
## Coefficients:
## (Intercept)
## 50.30072
##
## Scale= 3.146051
##
## Loglik(model)= -2149.5 Loglik(intercept only)= -2149.5
## n= 838
summary(fit.gau)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "gaussian")
## Value Std. Error z p
## (Intercept) 50.3007 0.1087 462.8 <2e-16
## Log(scale) 1.1461 0.0244 46.9 <2e-16
##
## Scale= 3.15
##
## Gaussian distribution
## Loglik(model)= -2149.5 Loglik(intercept only)= -2149.5
## Number of Newton-Raphson Iterations: 5
## n= 838
fit.exp=survreg(Surv(lama_studi)~1,dist="exponential")
fit.exp
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "exponential")
##
## Coefficients:
## (Intercept)
## 3.918019
##
## Scale fixed at 1
##
## Loglik(model)= -4121.3 Loglik(intercept only)= -4121.3
## n= 838
summary(fit.exp)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "exponential")
## Value Std. Error z p
## (Intercept) 3.9180 0.0345 113 <2e-16
##
## Scale fixed at 1
##
## Exponential distribution
## Loglik(model)= -4121.3 Loglik(intercept only)= -4121.3
## Number of Newton-Raphson Iterations: 2
## n= 838
fit.ray=survreg(Surv(lama_studi)~1,dist="rayleigh")
fit.ray
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "rayleigh")
##
## Coefficients:
## (Intercept)
## 3.919971
##
## Scale fixed at 0.5
##
## Loglik(model)= -3545.3 Loglik(intercept only)= -3545.3
## n= 838
summary(fit.ray)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "rayleigh")
## Value Std. Error z p
## (Intercept) 3.9200 0.0173 227 <2e-16
##
## Scale fixed at 0.5
##
## Rayleigh distribution
## Loglik(model)= -3545.3 Loglik(intercept only)= -3545.3
## Number of Newton-Raphson Iterations: 3
## n= 838
fit.lg=survreg(Surv(lama_studi)~1,dist="loggaussian")
fit.lg
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "loggaussian")
##
## Coefficients:
## (Intercept)
## 3.916083
##
## Scale= 0.06205618
##
## Loglik(model)= -2141.3 Loglik(intercept only)= -2141.3
## n= 838
summary(fit.lg)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "loggaussian")
## Value Std. Error z p
## (Intercept) 3.91608 0.00214 1827 <2e-16
## Log(scale) -2.77972 0.02443 -114 <2e-16
##
## Scale= 0.0621
##
## Log Normal distribution
## Loglik(model)= -2141.3 Loglik(intercept only)= -2141.3
## Number of Newton-Raphson Iterations: 5
## n= 838
fit.ln=survreg(Surv(lama_studi)~1,dist="lognormal")
fit.ln
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "lognormal")
##
## Coefficients:
## (Intercept)
## 3.916083
##
## Scale= 0.06205618
##
## Loglik(model)= -2141.3 Loglik(intercept only)= -2141.3
## n= 838
summary(fit.ln)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "lognormal")
## Value Std. Error z p
## (Intercept) 3.91608 0.00214 1827 <2e-16
## Log(scale) -2.77972 0.02443 -114 <2e-16
##
## Scale= 0.0621
##
## Log Normal distribution
## Loglik(model)= -2141.3 Loglik(intercept only)= -2141.3
## Number of Newton-Raphson Iterations: 5
## n= 838
fit.ll=survreg(Surv(lama_studi)~1,dist="loglogistic")
fit.ll
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "loglogistic")
##
## Coefficients:
## (Intercept)
## 3.911999
##
## Scale= 0.03953291
##
## Loglik(model)= -2200.1 Loglik(intercept only)= -2200.1
## n= 838
summary(fit.ll)
##
## Call:
## survreg(formula = Surv(lama_studi) ~ 1, dist = "loglogistic")
## Value Std. Error z p
## (Intercept) 3.91200 0.00252 1554 <2e-16
## Log(scale) -3.23062 0.02707 -119 <2e-16
##
## Scale= 0.0395
##
## Log logistic distribution
## Loglik(model)= -2200.1 Loglik(intercept only)= -2200.1
## Number of Newton-Raphson Iterations: 5
## n= 838
Nilai AIC
AIC(syahrina)
## [1] 4382.025
AIC(fit.ray)
## [1] 7092.674
AIC(fit.log)
## [1] 4420.877
AIC(fit.ll)
## [1] 4404.222
AIC(fit.wei)
## [1] 4364.477
AIC(fit.ln)
## [1] 4286.694
Kesimpulan Ada tiga distribusi yang memiliki nilai AIC terkecil yaitu distribusi Log-normal,Weibull dan ekstrim. Katiga distribusi tersebut yang digunakan untuk menentukan faktor-faktor yang mempengaruhi lama studi mahasi
Analisis Survival Model Regresi Log-normal
reg.lognormal=survreg(Surv(data$lama_studi,data$status)~gender+ipk+organisasi+asal_sekolah+bekerja,data=data,dist="lognormal")
reg.lognormal
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ gender +
## ipk + organisasi + asal_sekolah + bekerja, data = data, dist = "lognormal")
##
## Coefficients:
## (Intercept) gender2 ipk organisasi asal_sekolah2
## 4.723961277 0.002663398 -0.234669054 -0.014980252 0.016401382
## asal_sekolah3 bekerja
## -0.004464257 0.001594012
##
## Scale= 0.06028064
##
## Loglik(model)= -1419.4 Loglik(intercept only)= -1762.3
## Chisq= 685.94 on 6 degrees of freedom, p= <2e-16
## n= 838
summary(reg.lognormal)
##
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ gender +
## ipk + organisasi + asal_sekolah + bekerja, data = data, dist = "lognormal")
## Value Std. Error z p
## (Intercept) 4.72396 0.03192 148.00 <2e-16
## gender2 0.00266 0.00520 0.51 0.6088
## ipk -0.23467 0.00945 -24.84 <2e-16
## organisasi -0.01498 0.00470 -3.19 0.0014
## asal_sekolah2 0.01640 0.00544 3.02 0.0026
## asal_sekolah3 -0.00446 0.00594 -0.75 0.4526
## bekerja 0.00159 0.00478 0.33 0.7386
## Log(scale) -2.80874 0.03541 -79.31 <2e-16
##
## Scale= 0.0603
##
## Log Normal distribution
## Loglik(model)= -1419.4 Loglik(intercept only)= -1762.3
## Chisq= 685.94 on 6 degrees of freedom, p= 6.6e-145
## Number of Newton-Raphson Iterations: 6
## n= 838
Karena masih terdapat varibel yang tidak signifikan, maka variabel tersebut dikeluarkan secara bertahap melalui eliminasi backward.
reg.lognormal1=survreg(Surv(data$lama_studi,data$status)~ipk+organisasi+asal_sekolah,data=data,dist="lognormal")
reg.lognormal1
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ ipk +
## organisasi + asal_sekolah, data = data, dist = "lognormal")
##
## Coefficients:
## (Intercept) ipk organisasi asal_sekolah2 asal_sekolah3
## 4.721240180 -0.233135775 -0.015307583 0.016365265 -0.004254921
##
## Scale= 0.06028596
##
## Loglik(model)= -1419.5 Loglik(intercept only)= -1762.3
## Chisq= 685.6 on 4 degrees of freedom, p= <2e-16
## n= 838
summary(reg.lognormal1)
##
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ ipk +
## organisasi + asal_sekolah, data = data, dist = "lognormal")
## Value Std. Error z p
## (Intercept) 4.72124 0.03064 154.07 <2e-16
## ipk -0.23314 0.00879 -26.51 <2e-16
## organisasi -0.01531 0.00466 -3.29 0.0010
## asal_sekolah2 0.01637 0.00542 3.02 0.0025
## asal_sekolah3 -0.00425 0.00588 -0.72 0.4691
## Log(scale) -2.80866 0.03542 -79.31 <2e-16
##
## Scale= 0.0603
##
## Log Normal distribution
## Loglik(model)= -1419.5 Loglik(intercept only)= -1762.3
## Chisq= 685.6 on 4 degrees of freedom, p= 4.6e-147
## Number of Newton-Raphson Iterations: 6
## n= 838
Berdasarkan hasil pengujian signifikansi parameter secara parsial, variabel IPK, organisasi_1 dan asal sekolah telah signifikan terhadap lama studi mahasiswa. Hal ini terlihat dari nilai p-value yang kurang dari 0,05.
Analisis Survival Model Regresi Weibull
reg.wei=survreg(Surv(data$lama_studi,data$status)~gender+ipk+organisasi+asal_sekolah+bekerja,data=data,dist="weibull")
reg.wei
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ gender +
## ipk + organisasi + asal_sekolah + bekerja, data = data, dist = "weibull")
##
## Coefficients:
## (Intercept) gender2 ipk organisasi asal_sekolah2
## 4.8306711008 -0.0017722757 -0.2604160906 -0.0073069323 0.0188209094
## asal_sekolah3 bekerja
## 0.0001497121 0.0040505818
##
## Scale= 0.04533259
##
## Loglik(model)= -1400.2 Loglik(intercept only)= -1862.1
## Chisq= 923.8 on 6 degrees of freedom, p= <2e-16
## n= 838
summary(reg.wei)
##
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ gender +
## ipk + organisasi + asal_sekolah + bekerja, data = data, dist = "weibull")
## Value Std. Error z p
## (Intercept) 4.83067 0.02824 171.08 < 2e-16
## gender2 -0.00177 0.00483 -0.37 0.71377
## ipk -0.26042 0.00832 -31.30 < 2e-16
## organisasi -0.00731 0.00427 -1.71 0.08699
## asal_sekolah2 0.01882 0.00485 3.88 0.00011
## asal_sekolah3 0.00015 0.00537 0.03 0.97774
## bekerja 0.00405 0.00429 0.94 0.34557
## Log(scale) -3.09373 0.03781 -81.82 < 2e-16
##
## Scale= 0.0453
##
## Weibull distribution
## Loglik(model)= -1400.2 Loglik(intercept only)= -1862.1
## Chisq= 923.8 on 6 degrees of freedom, p= 2.7e-196
## Number of Newton-Raphson Iterations: 6
## n= 838
Karena masih terdapat varibel yang tidak signifikan, maka variabel tersebut dikeluarkan secara bertahap melalui eliminasi backward.
reg.wei=survreg(Surv(data$lama_studi,data$status)~ipk+organisasi+asal_sekolah,data=data,dist="weibull")
reg.wei
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ ipk +
## organisasi + asal_sekolah, data = data, dist = "weibull")
##
## Coefficients:
## (Intercept) ipk organisasi asal_sekolah2 asal_sekolah3
## 4.835876621 -0.261771510 -0.007092476 0.018555625 0.001271243
##
## Scale= 0.04536182
##
## Loglik(model)= -1400.8 Loglik(intercept only)= -1862.1
## Chisq= 922.69 on 4 degrees of freedom, p= <2e-16
## n= 838
summary(reg.wei)
##
## Call:
## survreg(formula = Surv(data$lama_studi, data$status) ~ ipk +
## organisasi + asal_sekolah, data = data, dist = "weibull")
## Value Std. Error z p
## (Intercept) 4.83588 0.02732 177.01 < 2e-16
## ipk -0.26177 0.00775 -33.77 < 2e-16
## organisasi -0.00709 0.00424 -1.67 0.09422
## asal_sekolah2 0.01856 0.00485 3.83 0.00013
## asal_sekolah3 0.00127 0.00525 0.24 0.80878
## Log(scale) -3.09308 0.03783 -81.76 < 2e-16
##
## Scale= 0.0454
##
## Weibull distribution
## Loglik(model)= -1400.8 Loglik(intercept only)= -1862.1
## Chisq= 922.69 on 4 degrees of freedom, p= 2e-198
## Number of Newton-Raphson Iterations: 6
## n= 838
Berdasarkan hasil pengujian signifikansi parameter secara parsial, variabel IPK, organisasi_1 DAN ASAL SEKOLAH telah signifikan terhadap lama studi mahasiswa. Hal ini terlihat dari nilai p-value yang kurang dari 0,05.
Penentuan Model Terbaik
AIC(reg.lognormal1)
## [1] 2851.072
AIC(reg.wei)
## [1] 2813.535
Kesimpulan nilai AIC untuk model regresi survival Weibull lebih kecil dibandingkan model regresi survival Log-normal. Dengan demikian, dapat dikatakan bahwa model regresi survival Weibull lebih baik untuk menentukan faktor-faktor yang berpengaruh secara signifikan terhadap lama studi mahasiswa.