Y: Keputusan menolak/menerima pelamar kerja pada PT A posisi B X1 : Lama Pengalaman kerja sebelumnya (bulan) X2 : Status pekerjaan saat ini (0: Bekerja, 1: tidak bekerja) X3 : Tingkat pendidikan (0: Lulusan Sekolah Menengah, 1: Lulusan Perguruan Tinggi) X4 : IPK (skala 4)
X1 : Lama Pengalaman kerja sebelumnya (bulan) membangkitkan variabel x1 dengan lama pekerjaan 0-60 bulan dengan nilai tengah 12 dan banyak pelamar adalah 100.
set.seed(100) ## mengunci data set seed
n <- 100
u <- runif(n)
## 60 = lama pekerja
## 12 = nilai tengah
## 100 = banyak pelamar
x1 <- round(60*(-(log(1-u)/12)))
x1
## [1] 2 1 4 0 3 3 8 2 4 1 5 11 2 3 7 6 1 2 2 6 4 6 4 7 3
## [26] 1 7 11 4 2 3 13 2 15 6 11 1 5 23 1 2 10 8 9 5 3 8 11 1 2
## [51] 2 1 1 2 4 1 1 1 5 1 3 5 16 6 3 2 3 3 1 6 3 2 4 17 5
## [76] 5 10 7 9 0 3 5 13 20 0 4 7 1 2 7 12 1 2 3 12 2 4 1 0 7
X2 : Status pekerjaan saat ini (0: Bekerja, 1: tidak bekerja)
set.seed(100) ## mengunci data set seed
x2 <- round(runif(n))
x2
## [1] 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 1 0 1 1 1 0
## [38] 1 1 0 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1
## [75] 1 1 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1
x3 : Tingkat Pendidikan X3 : Tingkat pendidikan (0: Lulusan Sekolah Menengah, 1: Lulusan Perguruan Tinggi)
set.seed(100) ## mengunci data set seed
x3 <- round(runif(n))
x3
## [1] 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 1 0 1 1 1 0
## [38] 1 1 0 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1
## [75] 1 1 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1
X4 : IPK (skala 4)
set.seed(11)
x4 <- round(rnorm(n,3,0.5),2)
x4
## [1] 2.70 3.01 2.24 2.32 3.59 2.53 3.66 3.31 2.98 2.50 2.59 2.83 2.23 2.87 2.43
## [16] 3.01 2.89 3.44 2.70 2.67 2.66 2.99 2.78 3.18 3.04 3.00 2.91 2.62 2.89 2.51
## [31] 2.45 2.53 3.34 2.21 2.57 3.24 2.91 3.77 2.69 2.83 2.18 3.01 3.45 2.56 3.45
## [46] 2.83 1.91 3.44 3.36 3.11 3.39 2.89 2.59 3.25 3.08 3.27 2.92 3.22 3.74 3.03
## [61] 2.58 4.17 2.94 2.02 3.27 3.85 2.60 2.46 2.70 3.38 3.23 2.94 2.62 3.11 3.56
## [76] 3.08 2.66 3.23 2.47 3.20 2.97 3.16 2.70 2.55 4.13 2.70 2.35 3.25 2.57 2.25
## [91] 3.60 2.49 3.47 2.73 3.26 2.82 3.66 2.43 3.71 2.70
menentukan Koefesien
b0 <- -10
b1 <- 3.5
b2 <- 0.5
b3 <- 2.7
b4 <- 1.2
set.seed(2)
datapendukung <- b0+(b1*x1)+(b2*x2)+(b3*x3)+(b4*x4)
datapendukung
## [1] 0.240 -2.888 9.888 -7.216 4.808 3.536 25.592 0.972 10.776 -3.500
## [11] 13.808 35.096 -0.324 3.944 20.616 17.812 -3.032 1.128 0.240 17.404
## [21] 10.392 17.788 10.536 21.516 4.148 -2.900 21.192 34.844 10.668 0.012
## [31] 3.440 41.736 1.008 48.352 17.284 35.588 -3.008 15.224 76.928 -3.104
## [41] -0.384 31.812 25.340 27.772 14.840 3.896 23.492 35.828 -2.468 0.732
## [51] 1.068 -3.032 -3.392 0.900 10.896 -2.576 -2.996 -2.636 15.188 -2.864
## [61] 3.596 15.704 52.728 16.624 4.424 1.620 3.620 3.452 -3.260 18.256
## [71] 4.376 0.528 10.344 56.432 14.972 14.396 31.392 21.576 27.664 -6.160
## [81] 4.064 14.492 41.940 66.260 -5.044 10.440 20.520 -2.600 0.084 20.400
## [91] 39.520 -3.512 1.164 3.776 39.112 0.384 11.592 -3.584 -5.548 20.940
p <- exp(datapendukung)/(1+exp(datapendukung))
p
## [1] 0.5597136493 0.0527499639 0.9999492222 0.0007341961 0.9919019422
## [6] 0.9716949037 1.0000000000 0.7255179607 0.9999791054 0.0293122308
## [11] 0.9999989925 1.0000000000 0.4197012277 0.9809975119 0.9999999989
## [16] 0.9999999816 0.0460009775 0.7554696173 0.5597136493 0.9999999724
## [21] 0.9999693240 0.9999999812 0.9999734379 0.9999999995 0.9844496560
## [26] 0.0521535631 0.9999999994 1.0000000000 0.9999767225 0.5029999640
## [31] 0.9689315158 1.0000000000 0.7326285637 1.0000000000 0.9999999688
## [36] 1.0000000000 0.0470657656 0.9999997555 1.0000000000 0.0429425601
## [41] 0.4051625091 1.0000000000 1.0000000000 1.0000000000 0.9999996410
## [46] 0.9800817580 0.9999999999 1.0000000000 0.0781321687 0.6752440053
## [51] 0.7442163851 0.0460009775 0.0325464221 0.7109495026 0.9999814681
## [56] 0.0706990829 0.0476069073 0.0668571527 0.9999997465 0.0539621349
## [61] 0.9732992517 0.9999998487 1.0000000000 0.9999999397 0.9881557756
## [66] 0.8347951298 0.9739159249 0.9692907290 0.0369692093 0.9999999882
## [71] 0.9875806203 0.6290165230 0.9999678157 1.0000000000 0.9999996854
## [76] 0.9999994404 1.0000000000 0.9999999996 1.0000000000 0.0021078011
## [81] 0.9831100119 0.9999994916 1.0000000000 1.0000000000 0.0064065959
## [86] 0.9999707616 0.9999999988 0.0691384203 0.5209876607 0.9999999986
## [91] 1.0000000000 0.0289727162 0.7620587757 0.9775991322 1.0000000000
## [96] 0.5948374909 0.9999907604 0.0270143796 0.0038801259 0.9999999992
set.seed(3)
y <- rbinom(n,1,p)
y
## [1] 1 0 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 0
## [38] 1 1 0 0 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1
## [75] 1 1 1 1 1 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1
datagab <- data.frame(y,x1,x2,x3,x4)
datagab
## y x1 x2 x3 x4
## 1 1 2 0 0 2.70
## 2 0 1 0 0 3.01
## 3 1 4 1 1 2.24
## 4 0 0 0 0 2.32
## 5 1 3 0 0 3.59
## 6 1 3 0 0 2.53
## 7 1 8 1 1 3.66
## 8 1 2 0 0 3.31
## 9 1 4 1 1 2.98
## 10 0 1 0 0 2.50
## 11 1 5 1 1 2.59
## 12 1 11 1 1 2.83
## 13 0 2 0 0 2.23
## 14 1 3 0 0 2.87
## 15 1 7 1 1 2.43
## 16 1 6 1 1 3.01
## 17 0 1 0 0 2.89
## 18 1 2 0 0 3.44
## 19 0 2 0 0 2.70
## 20 1 6 1 1 2.67
## 21 1 4 1 1 2.66
## 22 1 6 1 1 2.99
## 23 1 4 1 1 2.78
## 24 1 7 1 1 3.18
## 25 1 3 0 0 3.04
## 26 0 1 0 0 3.00
## 27 1 7 1 1 2.91
## 28 1 11 1 1 2.62
## 29 1 4 1 1 2.89
## 30 0 2 0 0 2.51
## 31 1 3 0 0 2.45
## 32 1 13 1 1 2.53
## 33 1 2 0 0 3.34
## 34 1 15 1 1 2.21
## 35 1 6 1 1 2.57
## 36 1 11 1 1 3.24
## 37 0 1 0 0 2.91
## 38 1 5 1 1 3.77
## 39 1 23 1 1 2.69
## 40 0 1 0 0 2.83
## 41 0 2 0 0 2.18
## 42 1 10 1 1 3.01
## 43 1 8 1 1 3.45
## 44 1 9 1 1 2.56
## 45 1 5 1 1 3.45
## 46 1 3 0 0 2.83
## 47 1 8 1 1 1.91
## 48 1 11 1 1 3.44
## 49 0 1 0 0 3.36
## 50 1 2 0 0 3.11
## 51 1 2 0 0 3.39
## 52 0 1 0 0 2.89
## 53 0 1 0 0 2.59
## 54 1 2 0 0 3.25
## 55 1 4 1 1 3.08
## 56 0 1 0 0 3.27
## 57 1 1 0 0 2.92
## 58 0 1 0 0 3.22
## 59 1 5 1 1 3.74
## 60 0 1 0 0 3.03
## 61 1 3 0 0 2.58
## 62 1 5 1 1 4.17
## 63 1 16 1 1 2.94
## 64 1 6 1 1 2.02
## 65 1 3 0 0 3.27
## 66 1 2 0 0 3.85
## 67 1 3 0 0 2.60
## 68 1 3 0 0 2.46
## 69 0 1 0 0 2.70
## 70 1 6 1 1 3.38
## 71 1 3 0 0 3.23
## 72 1 2 0 0 2.94
## 73 1 4 1 1 2.62
## 74 1 17 1 1 3.11
## 75 1 5 1 1 3.56
## 76 1 5 1 1 3.08
## 77 1 10 1 1 2.66
## 78 1 7 1 1 3.23
## 79 1 9 1 1 2.47
## 80 0 0 0 0 3.20
## 81 1 3 0 0 2.97
## 82 1 5 1 1 3.16
## 83 1 13 1 1 2.70
## 84 1 20 1 1 2.55
## 85 0 0 0 0 4.13
## 86 1 4 1 1 2.70
## 87 1 7 1 1 2.35
## 88 0 1 0 0 3.25
## 89 0 2 0 0 2.57
## 90 1 7 1 1 2.25
## 91 1 12 1 1 3.60
## 92 0 1 0 0 2.49
## 93 0 2 0 0 3.47
## 94 1 3 0 0 2.73
## 95 1 12 1 1 3.26
## 96 1 2 0 0 2.82
## 97 1 4 1 1 3.66
## 98 0 1 0 0 2.43
## 99 0 0 0 0 3.71
## 100 1 7 1 1 2.70
modelreglog <- glm(y~x1+x2+x3+x4, family = binomial(link = "logit"), data=datagab)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
summary(modelreglog)
##
## Call:
## glm(formula = y ~ x1 + x2 + x3 + x4, family = binomial(link = "logit"),
## data = datagab)
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -17.221 5.777 -2.981 0.002875 **
## x1 4.107 1.140 3.603 0.000315 ***
## x2 11.607 3780.458 0.003 0.997550
## x3 NA NA NA NA
## x4 3.324 1.578 2.107 0.035152 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 114.611 on 99 degrees of freedom
## Residual deviance: 22.764 on 96 degrees of freedom
## AIC: 30.764
##
## Number of Fisher Scoring iterations: 21