Y: Keputusan menolak atau menerima pelamar pekerja pada PT A dengan 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 Perguruaan Tinggi)
X4: IPK (Skala 4)
X1: Lama pengalaman kerja sebelumnya (bulan)
Membangkitkan X1 dengan lama pekerjaan 0-60 bulan dengan nilai tengah 12 dan banyaknya pelamar adalah 100.
set.seed(1234)
n <- 100
u <- runif(n)
x1 <- round(60*(-(log(1-u)/12)))
x1
## [1] 1 5 5 5 10 5 0 1 5 4 6 4 2 13 2 9 2 2 1 1 2 2 1 0 1
## [26] 8 4 12 9 0 3 2 2 4 1 7 1 1 24 8 4 5 2 5 2 3 6 3 1 7
## [51] 0 2 6 4 1 4 3 7 1 9 10 0 2 0 1 6 2 4 0 4 1 11 0 8 0
## [76] 4 2 0 2 6 13 3 1 4 1 11 2 2 1 11 1 12 1 1 1 4 2 0 2 7
X2: Status pekerjaan saat ini (0: Bekerja & 1: Tidak bekerja)
0 = Tidak bekerja
1 = Bekerja
set.seed(12345)
x2 <- round(runif(n))
x2
## [1] 1 1 1 1 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 1 0 0 1 0 0 1
## [38] 1 1 0 1 0 1 1 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 0 1 1 1 0 1 0 1 1 1 1 0 0
## [75] 0 1 1 1 1 0 1 1 0 0 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 0
X3: Tingkat Pendidikan (0: Lulusan Sekolah Menengah & 1: Lulusan Perguruaan Tinggi)
0 = Lulusan SMA/Tidak kuliah
1 = Lulus Kuliah
set.seed(123)
x3 <- round(runif(n))
x3
## [1] 0 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 0 1
## [38] 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0 0 0 1 0 1 1 1 0 1 1 1 0
## [75] 0 0 0 1 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 0 0 1 0 0 1
X4: IPK (Skala 4)
Data IPK Pelamar dengan skala 4
set.seed(222)
x4 <- round(rnorm(n, 3, 0.5), 2)
x4
## [1] 3.74 3.00 3.69 2.81 3.09 2.88 2.39 3.78 3.21 2.40 3.53 2.35 2.65 3.30 2.90
## [16] 2.41 2.00 3.00 3.26 2.63 3.36 3.36 2.67 3.75 2.28 1.92 3.20 2.80 2.85 3.67
## [31] 2.59 3.34 2.89 2.94 2.90 3.20 3.33 3.05 2.91 3.47 3.10 3.25 2.72 3.56 4.10
## [46] 3.16 2.53 3.41 2.81 3.17 3.30 3.26 2.52 2.39 2.90 3.53 3.19 3.62 3.16 2.48
## [61] 2.43 3.62 3.39 3.37 3.03 3.42 3.10 3.73 2.77 1.61 3.03 2.97 2.41 1.74 3.41
## [76] 3.13 2.97 3.34 3.01 3.27 3.34 2.40 2.38 3.11 2.27 2.94 3.27 3.36 2.21 3.55
## [91] 2.83 3.31 3.25 3.84 3.19 3.12 3.21 2.41 2.68 3.03
b0 <- -11
b1 <- 3.5
b2 <- 0.5
b3 <- 2.7
b4 <- 2.2
set.seed(1)
datapendukung <- b0+(b1*x1)+(b2*b2)+(b3*x3)+(b4*x4)
datapendukung
## [1] 0.978 16.050 14.868 15.632 33.748 13.086 -2.792 3.766 16.512 8.530
## [11] 20.716 8.420 4.780 44.710 2.630 28.752 0.650 2.850 -0.078 1.236
## [21] 6.342 6.342 1.324 0.200 0.466 24.174 12.990 40.110 27.020 -2.676
## [31] 8.148 6.298 5.308 12.418 -0.870 20.790 2.776 -0.540 79.652 24.884
## [41] 10.070 13.900 2.234 14.582 5.270 6.702 15.816 7.252 -1.068 23.424
## [51] -3.490 3.422 18.494 8.508 1.830 11.016 6.768 24.414 2.402 26.206
## [61] 32.296 -2.786 3.708 -3.336 2.116 17.774 5.770 14.156 -1.956 6.792
## [71] 2.116 36.984 -2.748 21.078 -3.248 10.136 2.784 -0.702 2.872 17.444
## [81] 42.098 7.730 -2.014 12.792 -2.256 34.218 6.144 6.342 0.312 35.560
## [91] -1.024 41.232 -0.100 3.898 -0.232 10.114 6.012 -5.448 2.146 23.116
p <- exp(datapendukung)/(1+exp(datapendukung))
p
## [1] 0.726711192 0.999999893 0.999999651 0.999999837 1.000000000 0.999997926
## [7] 0.057758015 0.977379092 0.999999933 0.999802584 0.999999999 0.999779634
## [13] 0.991673907 1.000000000 0.932767549 1.000000000 0.657010463 0.945318683
## [19] 0.480509880 0.774866989 0.998242318 0.998242318 0.789846432 0.549833997
## [25] 0.614436574 1.000000000 0.999997717 1.000000000 1.000000000 0.064404483
## [31] 0.999710770 0.998163398 0.995072579 0.999995955 0.295254302 0.999999999
## [37] 0.941365046 0.368187582 1.000000000 1.000000000 0.999957671 0.999999081
## [43] 0.903261444 0.999999535 0.994882711 0.998773055 0.999999865 0.999291747
## [49] 0.255783615 1.000000000 0.029598104 0.968385060 0.999999991 0.999798194
## [55] 0.861761727 0.999983564 0.998851329 1.000000000 0.916979686 1.000000000
## [61] 1.000000000 0.058085415 0.976060622 0.034356616 0.892448595 0.999999981
## [67] 0.996889945 0.999999289 0.123900592 0.998878538 0.892448595 1.000000000
## [73] 0.060199702 0.999999999 0.037398821 0.999960375 0.941805065 0.331368951
## [79] 0.946444813 0.999999973 1.000000000 0.999560749 0.117740830 0.999997217
## [85] 0.094833172 1.000000000 0.997858276 0.998242318 0.577373363 1.000000000
## [91] 0.264248982 1.000000000 0.475020813 0.980120764 0.442258757 0.999959493
## [97] 0.997556799 0.004286453 0.895294400 1.000000000
set.seed(2)
y <- rbinom(n, 1, p)
y
## [1] 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1
## [38] 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1
## [75] 0 1 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1
datagab <- data.frame(y, x1, x2, x3, x4)
datagab
## y x1 x2 x3 x4
## 1 1 1 1 0 3.74
## 2 1 5 1 1 3.00
## 3 1 5 1 0 3.69
## 4 1 5 1 1 2.81
## 5 1 10 0 1 3.09
## 6 1 5 0 0 2.88
## 7 0 0 0 1 2.39
## 8 1 1 1 1 3.78
## 9 1 5 1 1 3.21
## 10 1 4 1 0 2.40
## 11 1 6 0 1 3.53
## 12 1 4 0 0 2.35
## 13 1 2 1 1 2.65
## 14 1 13 0 1 3.30
## 15 1 2 0 0 2.90
## 16 1 9 0 1 2.41
## 17 0 2 0 0 2.00
## 18 0 2 0 0 3.00
## 19 0 1 0 0 3.26
## 20 1 1 1 1 2.63
## 21 1 2 0 1 3.36
## 22 1 2 0 1 3.36
## 23 1 1 1 1 2.67
## 24 0 0 1 1 3.75
## 25 1 1 1 1 2.28
## 26 1 8 0 1 1.92
## 27 1 4 1 1 3.20
## 28 1 12 1 1 2.80
## 29 1 9 0 0 2.85
## 30 0 0 0 0 3.67
## 31 1 3 1 1 2.59
## 32 1 2 0 1 3.34
## 33 1 2 0 1 2.89
## 34 1 4 1 1 2.94
## 35 1 1 0 0 2.90
## 36 1 7 0 0 3.20
## 37 1 1 1 1 3.33
## 38 0 1 1 0 3.05
## 39 1 24 1 0 2.91
## 40 1 8 0 0 3.47
## 41 1 4 1 0 3.10
## 42 1 5 0 0 3.25
## 43 1 2 1 0 2.72
## 44 1 5 1 0 3.56
## 45 1 2 0 0 4.10
## 46 1 3 0 0 3.16
## 47 1 6 0 0 2.53
## 48 1 3 0 0 3.41
## 49 1 1 0 0 2.81
## 50 1 7 1 1 3.17
## 51 0 0 1 0 3.30
## 52 1 2 1 0 3.26
## 53 1 6 0 1 2.52
## 54 1 4 0 0 2.39
## 55 1 1 1 1 2.90
## 56 1 4 0 0 3.53
## 57 1 3 1 0 3.19
## 58 1 7 0 1 3.62
## 59 1 1 0 1 3.16
## 60 1 9 0 0 2.48
## 61 1 10 1 1 2.43
## 62 0 0 0 0 3.62
## 63 1 2 1 0 3.39
## 64 0 0 1 0 3.37
## 65 1 1 1 1 3.03
## 66 1 6 0 0 3.42
## 67 1 2 1 1 3.10
## 68 1 4 0 1 3.73
## 69 0 0 1 1 2.77
## 70 1 4 1 0 1.61
## 71 1 1 1 1 3.03
## 72 1 11 1 1 2.97
## 73 0 0 0 1 2.41
## 74 1 8 0 0 1.74
## 75 0 0 0 0 3.41
## 76 1 4 1 0 3.13
## 77 1 2 1 0 2.97
## 78 0 0 1 1 3.34
## 79 1 2 1 0 3.01
## 80 1 6 0 0 3.27
## 81 1 13 1 0 3.34
## 82 1 3 1 1 2.40
## 83 0 1 0 0 2.38
## 84 1 4 0 1 3.11
## 85 0 1 0 0 2.27
## 86 1 11 0 0 2.94
## 87 1 2 1 1 3.27
## 88 1 2 1 1 3.36
## 89 1 1 1 1 2.21
## 90 1 11 0 0 3.55
## 91 1 1 1 0 2.83
## 92 1 12 1 1 3.31
## 93 0 1 0 0 3.25
## 94 1 1 1 1 3.84
## 95 0 1 1 0 3.19
## 96 1 4 1 0 3.12
## 97 1 2 1 1 3.21
## 98 0 0 1 0 2.41
## 99 1 2 0 0 2.68
## 100 1 7 0 1 3.03
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:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -8.598 4.048 -2.124 0.033658 *
## x1 3.734 1.045 3.573 0.000353 ***
## x2 1.415 1.163 1.217 0.223684
## x3 2.887 1.251 2.308 0.021018 *
## x4 1.059 1.139 0.930 0.352426
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 97.245 on 99 degrees of freedom
## Residual deviance: 27.247 on 95 degrees of freedom
## AIC: 37.247
##
## Number of Fisher Scoring iterations: 9