Kelompok : 1

Kelas : 2023 F

Anggota Kelompok:

Naufal Faiz Nugraha (23031554020)

Bagus Febriansyah Pratama (23031554144)

Otniel Glory Joseputra Pribadi (23031554151)

Rozan Adzki Yahya (23031554236)

Multinomial

1. Load Dataset

# Load the dataset
df_mltn <- read.csv("E:/Anmul-Kelompok/car_evaluation.csv")

# Display structure of the dataset
str(df_mltn)
## 'data.frame':    1728 obs. of  7 variables:
##  $ buying  : chr  "vhigh" "vhigh" "vhigh" "vhigh" ...
##  $ maint   : chr  "vhigh" "vhigh" "vhigh" "vhigh" ...
##  $ doors   : chr  "2" "2" "2" "2" ...
##  $ persons : chr  "2" "2" "2" "2" ...
##  $ lug_boot: chr  "small" "small" "small" "med" ...
##  $ safety  : chr  "low" "med" "high" "low" ...
##  $ class   : chr  "unacc" "unacc" "unacc" "unacc" ...

Penjelasan variable:
Fitur (Variabel Independen):

  • buying (Harga pembelian)
  • maint (Biaya perawatan)
  • doors (Jumlah pintu)
  • persons (Kapasitas penumpang)
  • lug_boot (Kapasitas bagasi)
  • safety (Estimasi keamanan)

Variabel Target:

  • class (Evaluasi keseluruhan mobil)

2. Multinomial Logistic Regression with 1 Independent Variable (IV)

# Load necessary library
library(nnet)

# Fit basic multinomial logistic regression
fit_basic <- multinom(class ~ safety, data = df_mltn)
## # weights:  16 (9 variable)
## initial  value 2395.516656 
## iter  10 value 1183.561335
## iter  20 value 1130.262427
## iter  30 value 1130.161452
## final  value 1130.152825 
## converged
# Summary of the model
summary(fit_basic)
## Call:
## multinom(formula = class ~ safety, data = df_mltn)
## 
## Coefficients:
##       (Intercept) safetylow   safetymed
## good   -1.9169216 -4.329071   0.3875256
## unacc   0.3058977 30.382690   0.3788808
## vgood  -1.1437326 -5.291423 -14.3746602
## 
## Std. Errors:
##       (Intercept)    safetylow   safetymed
## good   0.19553841 2.837316e-14   0.2634993
## unacc  0.09226088 2.306790e-11   0.1298797
## vgood  0.14243096 1.166844e-13 174.6385287
## 
## Residual Deviance: 2260.306 
## AIC: 2278.306
library(broom)
library(kableExtra)

# Tidy version of the summary with confidence intervals
tidy(fit_basic, conf.int = TRUE) %>%
  kable() %>%
  kable_styling("basic", full_width = FALSE)
y.level term estimate std.error statistic p.value conf.low conf.high
good (Intercept) -1.9169216 0.1955384 -9.803300e+00 0.0000000 -2.3001699 -1.5336734
good safetylow -4.3290714 0.0000000 -1.525763e+14 0.0000000 -4.3290714 -4.3290714
good safetymed 0.3875256 0.2634993 1.470690e+00 0.1413751 -0.1289234 0.9039747
unacc (Intercept) 0.3058977 0.0922609 3.315574e+00 0.0009146 0.1250698 0.4867257
unacc safetylow 30.3826900 0.0000000 1.317098e+12 0.0000000 30.3826900 30.3826900
unacc safetymed 0.3788808 0.1298797 2.917166e+00 0.0035323 0.1243212 0.6334404
vgood (Intercept) -1.1437326 0.1424310 -8.030084e+00 0.0000000 -1.4228922 -0.8645731
vgood safetylow -5.2914234 0.0000000 -4.534818e+13 0.0000000 -5.2914234 -5.2914234
vgood safetymed -14.3746602 174.6385287 -8.231090e-02 0.9343995 -356.6598868 327.9105664

Interpretasi:
- safety sangat signifikan dalam memengaruhi klasifikasi mobil.
- Contoh:
- Untuk kelas “unacc”, koefisien safetylow sangat besar (30.38) → mobil dengan safety=low sangat besar kemungkinannya diklasifikasikan sebagai “unacceptable”.
- P-value < 0.05 menunjukkan koefisien signifikan.

3. Multinomial Logistic Regression with Multiple Independent Variables

# Fit full multinomial logistic regression model
fit_full <- multinom(class ~ buying + maint + doors + persons + lug_boot + safety, data = df_mltn)
## # weights:  68 (48 variable)
## initial  value 2395.516656 
## iter  10 value 597.315128
## iter  20 value 467.090136
## iter  30 value 328.810480
## iter  40 value 244.612984
## iter  50 value 225.225988
## iter  60 value 224.162360
## iter  70 value 224.098885
## iter  80 value 224.087988
## iter  90 value 224.087533
## final  value 224.087526 
## converged

3.1 Interpret Relative Log Odds

# Summary output
summary(fit_full)
## Call:
## multinom(formula = class ~ buying + maint + doors + persons + 
##     lug_boot + safety, data = df_mltn)
## 
## Coefficients:
##       (Intercept) buyinglow buyingmed buyingvhigh  maintlow  maintmed
## good    -72.98492  46.65461 41.096570    8.016357 44.275659 39.476090
## unacc    70.34286  -5.02430 -3.907139    2.059538 -3.389268 -3.395281
## vgood   -83.58546  62.17300 54.746526   -8.949530 16.062733 11.340542
##       maintvhigh    doors3    doors4 doors5more   persons4 personsmore
## good  -15.139574  2.476545  3.569840   3.569871  -4.710739    -4.65662
## unacc   2.815303 -1.850896 -2.474970  -2.474970 -71.878551   -71.49822
## vgood -41.405035  4.275883  7.592428   7.592410  20.961126    22.33391
##       lug_bootmed lug_bootsmall safetylow  safetymed
## good    -3.070927     -9.435301 -19.52757  -7.969999
## unacc    1.512584      4.434169  53.67293   2.994152
## vgood   -6.412796    -32.137944 -19.60409 -37.231570
## 
## Std. Errors:
##       (Intercept) buyinglow buyingmed  buyingvhigh  maintlow  maintmed
## good    0.7059278 0.8635143 0.3687468 8.262278e-08 0.8420448 0.3745042
## unacc   0.3135998 0.5702171 0.4854407 3.744753e-01 0.4711076 0.4696660
## vgood   0.5646892 0.6400638 0.8436908 1.097143e-18 2.7185323 1.9930416
##         maintvhigh    doors3   doors4 doors5more  persons4 personsmore
## good           NaN 0.9585282 1.069365   1.069367 0.4565059   0.4706262
## unacc 4.147943e-01 0.4040376 0.427859   0.427859 0.2116368   0.2069209
## vgood 3.046022e-13 1.3524552 1.588884   1.588880 0.5365964   0.4981571
##       lug_bootmed lug_bootsmall    safetylow    safetymed
## good    0.9983513  1.961203e+00 7.482893e-14 1.601577e+00
## unacc   0.3755726  4.759416e-01 2.789120e-14 3.584065e-01
## vgood   1.3740079  9.530905e-05 2.748210e-14 1.239554e-07
## 
## Residual Deviance: 448.1751 
## AIC: 544.1751
# Tidy version
tidy(fit_full, conf.int = TRUE) %>%
  kable() %>%
  kable_styling("basic", full_width = FALSE)
y.level term estimate std.error statistic p.value conf.low conf.high
good (Intercept) -72.984917 0.7059278 -1.033886e+02 0.0000000 -74.3685100 -71.601324
good buyinglow 46.654614 0.8635143 5.402877e+01 0.0000000 44.9621568 48.347071
good buyingmed 41.096570 0.3687468 1.114493e+02 0.0000000 40.3738394 41.819300
good buyingvhigh 8.016357 0.0000001 9.702357e+07 0.0000000 8.0163572 8.016358
good maintlow 44.275659 0.8420448 5.258112e+01 0.0000000 42.6252816 45.926037
good maintmed 39.476090 0.3745042 1.054089e+02 0.0000000 38.7420755 40.210105
good maintvhigh -15.139574 NaN NaN NaN NaN NaN
good doors3 2.476545 0.9585282 2.583696e+00 0.0097748 0.5978644 4.355226
good doors4 3.569840 1.0693652 3.338280e+00 0.0008430 1.4739227 5.665757
good doors5more 3.569871 1.0693674 3.338302e+00 0.0008429 1.4739496 5.665793
good persons4 -4.710739 0.4565059 -1.031912e+01 0.0000000 -5.6054744 -3.816004
good personsmore -4.656620 0.4706262 -9.894519e+00 0.0000000 -5.5790303 -3.734209
good lug_bootmed -3.070927 0.9983513 -3.075998e+00 0.0020980 -5.0276597 -1.114194
good lug_bootsmall -9.435301 1.9612026 -4.810977e+00 0.0000015 -13.2791875 -5.591415
good safetylow -19.527570 0.0000000 -2.609629e+14 0.0000000 -19.5275705 -19.527570
good safetymed -7.969999 1.6015770 -4.976345e+00 0.0000006 -11.1090325 -4.830966
unacc (Intercept) 70.342864 0.3135998 2.243078e+02 0.0000000 69.7282201 70.957509
unacc buyinglow -5.024300 0.5702171 -8.811206e+00 0.0000000 -6.1419053 -3.906695
unacc buyingmed -3.907139 0.4854407 -8.048643e+00 0.0000000 -4.8585851 -2.955693
unacc buyingvhigh 2.059538 0.3744753 5.499796e+00 0.0000000 1.3255796 2.793496
unacc maintlow -3.389268 0.4711076 -7.194255e+00 0.0000000 -4.3126222 -2.465914
unacc maintmed -3.395281 0.4696660 -7.229139e+00 0.0000000 -4.3158093 -2.474752
unacc maintvhigh 2.815303 0.4147943 6.787227e+00 0.0000000 2.0023211 3.628285
unacc doors3 -1.850896 0.4040376 -4.581000e+00 0.0000046 -2.6427952 -1.058997
unacc doors4 -2.474970 0.4278590 -5.784546e+00 0.0000000 -3.3135587 -1.636382
unacc doors5more -2.474970 0.4278590 -5.784545e+00 0.0000000 -3.3135579 -1.636381
unacc persons4 -71.878551 0.2116368 -3.396317e+02 0.0000000 -72.2933513 -71.463750
unacc personsmore -71.498216 0.2069209 -3.455340e+02 0.0000000 -71.9037731 -71.092658
unacc lug_bootmed 1.512584 0.3755726 4.027407e+00 0.0000564 0.7764750 2.248693
unacc lug_bootsmall 4.434170 0.4759416 9.316626e+00 0.0000000 3.5013411 5.366998
unacc safetylow 53.672927 0.0000000 1.924368e+15 0.0000000 53.6729266 53.672927
unacc safetymed 2.994152 0.3584065 8.354066e+00 0.0000000 2.2916878 3.696615
vgood (Intercept) -83.585464 0.5646892 -1.480203e+02 0.0000000 -84.6922347 -82.478694
vgood buyinglow 62.173003 0.6400638 9.713563e+01 0.0000000 60.9185014 63.427506
vgood buyingmed 54.746526 0.8436908 6.488932e+01 0.0000000 53.0929220 56.400129
vgood buyingvhigh -8.949530 0.0000000 -8.157122e+18 0.0000000 -8.9495303 -8.949530
vgood maintlow 16.062733 2.7185323 5.908605e+00 0.0000000 10.7345077 21.390958
vgood maintmed 11.340542 1.9930416 5.690068e+00 0.0000000 7.4342522 15.246832
vgood maintvhigh -41.405035 0.0000000 -1.359315e+14 0.0000000 -41.4050354 -41.405035
vgood doors3 4.275883 1.3524552 3.161571e+00 0.0015692 1.6251197 6.926647
vgood doors4 7.592428 1.5888841 4.778466e+00 0.0000018 4.4782723 10.706583
vgood doors5more 7.592410 1.5888796 4.778468e+00 0.0000018 4.4782630 10.706557
vgood persons4 20.961126 0.5365964 3.906311e+01 0.0000000 19.9094160 22.012835
vgood personsmore 22.333908 0.4981571 4.483306e+01 0.0000000 21.3575377 23.310278
vgood lug_bootmed -6.412796 1.3740079 -4.667219e+00 0.0000031 -9.1058019 -3.719790
vgood lug_bootsmall -32.137944 0.0000953 -3.371972e+05 0.0000000 -32.1381304 -32.137757
vgood safetylow -19.604089 0.0000000 -7.133402e+14 0.0000000 -19.6040892 -19.604089
vgood safetymed -37.231570 0.0000001 -3.003625e+08 0.0000000 -37.2315707 -37.231570
  • Nilai log-odds menunjukkan arah dan kekuatan pengaruh.
  • Contoh:
  • Untuk kelas “vgood”, variabel buyinglow punya koefisien +62.17 → peluang besar mobil berkualitas sangat baik ketika harga beli rendah.

3.2 Interpret Relative Risk Ratios (Exponentiated Coefficients)

# Exponentiate coefficients
exp(coef(fit_full))
##        (Intercept)    buyinglow    buyingmed  buyingvhigh     maintlow
## good  2.009340e-32 1.827432e+20 7.047150e+17 3.030120e+03 1.693068e+19
## unacc 3.544197e+30 6.576186e-03 2.009792e-02 7.842343e+00 3.373335e-02
## vgood 5.003734e-37 1.003211e+27 5.971920e+23 1.297981e-04 9.461420e+06
##           maintmed   maintvhigh     doors3       doors4   doors5more
## good  1.393953e+17 2.660520e-07 11.9000799 3.551091e+01 3.551202e+01
## unacc 3.353114e-02 1.669823e+01  0.1570963 8.416548e-02 8.416554e-02
## vgood 8.416563e+04 1.042369e-18 71.9436502 1.983122e+03 1.983087e+03
##           persons4  personsmore lug_bootmed lug_bootsmall    safetylow
## good  8.998123e-03 9.498514e-03 0.046378139  7.985476e-05 3.305856e-09
## unacc 6.074940e-32 8.886271e-32 4.538442419  8.428210e+01 2.041060e+23
## vgood 1.268531e+09 5.006023e+09 0.001640432  1.103236e-14 3.062332e-09
##          safetymed
## good  3.456792e-04
## unacc 1.996841e+01
## vgood 6.769154e-17
# Or using tidy
tidy(fit_full, conf.int = TRUE, exponentiate = TRUE) %>%
  kable() %>%
  kable_styling("basic", full_width = FALSE)
y.level term estimate std.error statistic p.value conf.low conf.high
good (Intercept) 0.000000e+00 0.7059278 -1.033886e+02 0.0000000 0.000000e+00 0.000000e+00
good buyinglow 1.827432e+20 0.8635143 5.402877e+01 0.0000000 3.363695e+19 9.928096e+20
good buyingmed 7.047150e+17 0.3687468 1.114493e+02 0.0000000 3.420863e+17 1.451748e+18
good buyingvhigh 3.030120e+03 0.0000001 9.702357e+07 0.0000000 3.030119e+03 3.030120e+03
good maintlow 1.693068e+19 0.8420448 5.258112e+01 0.0000000 3.250308e+18 8.819101e+19
good maintmed 1.393953e+17 0.3745042 1.054089e+02 0.0000000 6.690670e+16 2.904202e+17
good maintvhigh 3.000000e-07 NaN NaN NaN NaN NaN
good doors3 1.190008e+01 0.9585282 2.583696e+00 0.0097748 1.818232e+00 7.788442e+01
good doors4 3.551091e+01 1.0693652 3.338280e+00 0.0008430 4.366329e+00 2.888066e+02
good doors5more 3.551202e+01 1.0693674 3.338302e+00 0.0008429 4.366447e+00 2.888169e+02
good persons4 8.998100e-03 0.4565059 -1.031912e+01 0.0000000 3.677700e-03 2.201560e-02
good personsmore 9.498500e-03 0.4706262 -9.894519e+00 0.0000000 3.776200e-03 2.389210e-02
good lug_bootmed 4.637810e-02 0.9983513 -3.075998e+00 0.0020980 6.554100e-03 3.281795e-01
good lug_bootsmall 7.990000e-05 1.9612026 -4.810977e+00 0.0000015 1.700000e-06 3.729700e-03
good safetylow 0.000000e+00 0.0000000 -2.609629e+14 0.0000000 0.000000e+00 0.000000e+00
good safetymed 3.457000e-04 1.6015770 -4.976345e+00 0.0000006 1.500000e-05 7.978800e-03
unacc (Intercept) 3.544197e+30 0.3135998 2.243078e+02 0.0000000 1.916820e+30 6.553216e+30
unacc buyinglow 6.576200e-03 0.5702171 -8.811206e+00 0.0000000 2.150800e-03 2.010680e-02
unacc buyingmed 2.009790e-02 0.4854407 -8.048643e+00 0.0000000 7.761500e-03 5.204260e-02
unacc buyingvhigh 7.842343e+00 0.3744753 5.499796e+00 0.0000000 3.764367e+00 1.633803e+01
unacc maintlow 3.373340e-02 0.4711076 -7.194255e+00 0.0000000 1.339840e-02 8.493120e-02
unacc maintmed 3.353110e-02 0.4696660 -7.229139e+00 0.0000000 1.335570e-02 8.418380e-02
unacc maintvhigh 1.669823e+01 0.4147943 6.787227e+00 0.0000000 7.406226e+00 3.764819e+01
unacc doors3 1.570963e-01 0.4040376 -4.581000e+00 0.0000046 7.116210e-02 3.468035e-01
unacc doors4 8.416550e-02 0.4278590 -5.784546e+00 0.0000000 3.638650e-02 1.946831e-01
unacc doors5more 8.416550e-02 0.4278590 -5.784545e+00 0.0000000 3.638650e-02 1.946832e-01
unacc persons4 0.000000e+00 0.2116368 -3.396317e+02 0.0000000 0.000000e+00 0.000000e+00
unacc personsmore 0.000000e+00 0.2069209 -3.455340e+02 0.0000000 0.000000e+00 0.000000e+00
unacc lug_bootmed 4.538442e+00 0.3755726 4.027407e+00 0.0000564 2.173796e+00 9.475341e+00
unacc lug_bootsmall 8.428210e+01 0.4759416 9.316626e+00 0.0000000 3.315989e+01 2.142188e+02
unacc safetylow 2.041060e+23 0.0000000 1.924368e+15 0.0000000 2.041060e+23 2.041060e+23
unacc safetymed 1.996841e+01 0.3584065 8.354066e+00 0.0000000 9.891618e+00 4.031064e+01
vgood (Intercept) 0.000000e+00 0.5646892 -1.480203e+02 0.0000000 0.000000e+00 0.000000e+00
vgood buyinglow 1.003211e+27 0.6400638 9.713563e+01 0.0000000 2.861337e+26 3.517350e+27
vgood buyingmed 5.971920e+23 0.8436908 6.488932e+01 0.0000000 1.142781e+23 3.120793e+24
vgood buyingvhigh 1.298000e-04 0.0000000 -8.157122e+18 0.0000000 1.298000e-04 1.298000e-04
vgood maintlow 9.461420e+06 2.7185323 5.908605e+00 0.0000000 4.591319e+04 1.949733e+09
vgood maintmed 8.416563e+04 1.9930416 5.690068e+00 0.0000000 1.692991e+03 4.184223e+06
vgood maintvhigh 0.000000e+00 0.0000000 -1.359315e+14 0.0000000 0.000000e+00 0.000000e+00
vgood doors3 7.194365e+01 1.3524552 3.161571e+00 0.0015692 5.079027e+00 1.019071e+03
vgood doors4 1.983122e+03 1.5888841 4.778466e+00 0.0000018 8.808236e+01 4.464883e+04
vgood doors5more 1.983087e+03 1.5888796 4.778468e+00 0.0000018 8.808154e+01 4.464764e+04
vgood persons4 1.268531e+09 0.5365964 3.906311e+01 0.0000000 4.431487e+08 3.631223e+09
vgood personsmore 5.006023e+09 0.4981571 4.483306e+01 0.0000000 1.885649e+09 1.329000e+10
vgood lug_bootmed 1.640400e-03 1.3740079 -4.667219e+00 0.0000031 1.110000e-04 2.423910e-02
vgood lug_bootsmall 0.000000e+00 0.0000953 -3.371972e+05 0.0000000 0.000000e+00 0.000000e+00
vgood safetylow 0.000000e+00 0.0000000 -7.133402e+14 0.0000000 0.000000e+00 0.000000e+00
vgood safetymed 0.000000e+00 0.0000001 -3.003625e+08 0.0000000 0.000000e+00 0.000000e+00

Interpretasi:
- exp(coef) mengubah log-odds menjadi rasio risiko.
- Contoh:
- vgood:persons4 = 1.26e+09 → kemungkinan mobil “vgood” meningkat drastis saat kapasitas 4 penumpang.
- safetylow pada “unacc” = 2.04e+23 → fitur safety sangat menentukan.

3.3 Interpret Marginal Effects

# Load library
library(marginaleffects)

# Marginal effect for 'safety'
mfx_safety <- avg_comparisons(fit_full, variables = "safety", type = "probs")
mfx_safety
## 
##  Group   Contrast Estimate Std. Error      z Pr(>|z|)     S   2.5 %  97.5 %
##  acc   low - high  -0.3542    0.00923 -38.37   <0.001   Inf -0.3723 -0.3361
##  acc   med - high  -0.0417    0.01394  -2.99   0.0028   8.5 -0.0690 -0.0143
##  good  low - high  -0.0521    0.00486 -10.71   <0.001  86.5 -0.0616 -0.0426
##  good  med - high   0.0156    0.00659   2.37   0.0178   5.8  0.0027  0.0285
##  unacc low - high   0.5191    0.00831  62.50   <0.001   Inf  0.5028  0.5354
##  unacc med - high   0.1389    0.01259  11.03   <0.001  91.6  0.1142  0.1636
##  vgood low - high  -0.1128    0.00473 -23.86   <0.001 415.7 -0.1221 -0.1036
##  vgood med - high  -0.1128    0.00473 -23.86   <0.001 415.7 -0.1221 -0.1036
## 
## Term: safety
## Type:  probs

Interpretasi:
- Perubahan dari safety=high ke safety=low meningkatkan probabilitas klasifikasi ke “unacc” sebesar +51.9%.
- Untuk “good”, probabilitas turun -5.2%, menunjukkan safety sangat berpengaruh negatif.


Ordinal

1. Load Dataset

# Load the dataset
df_ord <- read.csv("E:/Anmul-Kelompok/user_knowledge_modeling.csv")

# Display structure of the dataset
str(df_ord)
## 'data.frame':    403 obs. of  6 variables:
##  $ STG: num  0 0.08 0.06 0.1 0.08 0.09 0.1 0.15 0.2 0 ...
##  $ SCG: num  0 0.08 0.06 0.1 0.08 0.15 0.1 0.02 0.14 0 ...
##  $ STR: num  0 0.1 0.05 0.15 0.08 0.4 0.43 0.34 0.35 0.5 ...
##  $ LPR: num  0 0.24 0.25 0.65 0.98 0.1 0.29 0.4 0.72 0.2 ...
##  $ PEG: num  0 0.9 0.33 0.3 0.24 0.66 0.56 0.01 0.25 0.85 ...
##  $ UNS: chr  "very_low" "High" "Low" "Middle" ...

Penjelasan variabel:
Fitur (Variabel Independen):

  • STG (Study Time for Goal object materials)
  • SCG (Study Time for Related objects with Goal object)
  • STR (Repetition Number of User for Goal object materials)
  • LPR (User Performance in Lower Assessment)
  • PEG (User Performance in Exam for Goal object materials)

Variabel Target:

  • UNS (User Knowledge Level)

2. Ordinal Logistic Regression with 1 Independent Variable (IV)

# Load necessary library
library(MASS)

# Convert the UNS variable to an ordered factor
df_ord$UNS <- factor(df_ord$UNS, ordered = TRUE)

# Fit basic ordinal logistic regression
fit_basic <- polr(UNS ~ PEG, data = df_ord, Hess = TRUE)

# Summary of the model
summary(fit_basic)
## Call:
## polr(formula = UNS ~ PEG, data = df_ord, Hess = TRUE)
## 
## Coefficients:
##     Value Std. Error t value
## PEG -5.03      0.421  -11.95
## 
## Intercepts:
##                   Value    Std. Error t value 
## High|Low           -3.5456   0.2544   -13.9367
## Low|Middle         -1.7910   0.2029    -8.8262
## Middle|Very Low     0.0635   0.2133     0.2978
## Very Low|very_low   1.0664   0.2466     4.3250
## 
## Residual Deviance: 980.4873 
## AIC: 990.4873
library(broom)
library(kableExtra)

# Tidy version of the summary with confidence intervals
tidy(fit_basic, conf.int = TRUE) %>%
  kable() %>%
  kable_styling("basic", full_width = FALSE)
term estimate std.error statistic conf.low conf.high coef.type
PEG -5.0300645 0.4209646 -11.9489011 -5.869162 -4.21746 coefficient
High&#124;Low -3.5455722 0.2544062 -13.9366585 NA NA scale
Low&#124;Middle -1.7910226 0.2029215 -8.8261822 NA NA scale
Middle&#124;Very Low 0.0635231 0.2133103 0.2977966 NA NA scale
Very Low&#124;very_low 1.0664483 0.2465762 4.3250257 NA NA scale

Interpretasi:
- PEG memiliki pengaruh negatif signifikan (koef = -5.03, p < 0.001)
- Artinya, semakin tinggi nilai ujian PEG, semakin besar peluang masuk kategori UNS yang lebih tinggi.

3. Ordinal Logistic Regression with Multiple Independent Variables

# Fit full ordinal logistic regression model
fit_full <- polr(UNS ~ STG + SCG + STR + LPR + PEG,
               data = df_ord, Hess = TRUE)
  • LPR dan PEG memiliki koefisien negatif signifikan, menurunkan peluang masuk kategori rendah (pengetahuan meningkat).
  • Variabel lain seperti SCG, STR, dan STG tidak signifikan (p > 0.05).

3.1 Interpret Relative Log Odds

# Summary output
summary(fit_full)
## Call:
## polr(formula = UNS ~ STG + SCG + STR + LPR + PEG, data = df_ord, 
##     Hess = TRUE)
## 
## Coefficients:
##       Value Std. Error  t value
## STG  0.2283     0.4918   0.4642
## SCG -0.5580     0.4845  -1.1516
## STR  0.1046     0.4096   0.2555
## LPR -3.5800     0.4318  -8.2900
## PEG -5.6935     0.4577 -12.4385
## 
## Intercepts:
##                   Value    Std. Error t value 
## High|Low           -5.6482   0.4331   -13.0415
## Low|Middle         -3.6504   0.3810    -9.5813
## Middle|Very Low    -1.5322   0.3637    -4.2125
## Very Low|very_low  -0.3507   0.3661    -0.9579
## 
## Residual Deviance: 897.9469 
## AIC: 915.9469
# Tidy version
tidy(fit_full, conf.int = TRUE) %>%
  kable() %>%
  kable_styling("basic", full_width = FALSE)
term estimate std.error statistic conf.low conf.high coef.type
STG 0.2282968 0.4917878 0.4642180 -0.7410857 1.1893214 coefficient
SCG -0.5579528 0.4845045 -1.1515947 -1.5141430 0.3875627 coefficient
STR 0.1046400 0.4095556 0.2554965 -0.6983297 0.9088211 coefficient
LPR -3.5799523 0.4318379 -8.2900376 -4.4424867 -2.7477296 coefficient
PEG -5.6934772 0.4577302 -12.4385008 -6.6078809 -4.8118616 coefficient
High&#124;Low -5.6481945 0.4330929 -13.0415319 NA NA scale
Low&#124;Middle -3.6503755 0.3809896 -9.5812997 NA NA scale
Middle&#124;Very Low -1.5321805 0.3637200 -4.2125269 NA NA scale
Very Low&#124;very_low -0.3507019 0.3661202 -0.9578873 NA NA scale
  • LPR dan PEG memiliki koefisien negatif signifikan, menurunkan peluang masuk kategori rendah (pengetahuan meningkat).
  • Variabel lain seperti SCG, STR, dan STG tidak signifikan (p > 0.05).

3.2 Interpret Relative Risk Ratios (Exponentiated Coefficients)

# Exponentiate coefficients
exp(coef(fit_full))
##         STG         SCG         STR         LPR         PEG 
## 1.256458149 0.572379649 1.110310835 0.027877028 0.003367862
# Or using tidy
tidy(fit_full, conf.int = TRUE, exponentiate = TRUE) %>%
  kable() %>%
  kable_styling("basic", full_width = FALSE)
term estimate std.error statistic conf.low conf.high coef.type
STG 1.2564581 0.4917878 0.4642180 0.4765962 3.2848512 coefficient
SCG 0.5723796 0.4845045 -1.1515947 0.2199967 1.4733853 coefficient
STR 1.1103108 0.4095556 0.2554965 0.4974155 2.4813955 coefficient
LPR 0.0278770 0.4318379 -8.2900376 0.0117666 0.0640732 coefficient
PEG 0.0033679 0.4577302 -12.4385008 0.0013497 0.0081327 coefficient
High&#124;Low 0.0035239 0.4330929 -13.0415319 NA NA scale
Low&#124;Middle 0.0259814 0.3809896 -9.5812997 NA NA scale
Middle&#124;Very Low 0.2160640 0.3637200 -4.2125269 NA NA scale
Very Low&#124;very_low 0.7041936 0.3661202 -0.9578873 NA NA scale

Interpretasi:
- PEG = 0.0034 → Setiap peningkatan PEG mengurangi risiko berada di kategori rendah sebesar 99.66%.
- LPR = 0.0279 → Semakin tinggi nilai LPR, peluang pengetahuan rendah juga turun.

3.3 Interpret Marginal Effects

# Load library
library(marginaleffects)

# Marginal effect for 'PEG'
mfx_peg <- avg_comparisons(fit_full, variables = "PEG", type = "probs")
mfx_peg
## 
##     Group Estimate Std. Error      z Pr(>|z|)     S   2.5 %  97.5 %
##  High       0.6784     0.0165  41.08   <0.001   Inf  0.6460  0.7107
##  Low       -0.2668     0.0193 -13.79   <0.001 141.3 -0.3048 -0.2289
##  Middle    -0.2730     0.0194 -14.09   <0.001 147.3 -0.3110 -0.2350
##  Very Low  -0.0802     0.0142  -5.65   <0.001  25.9 -0.1080 -0.0523
##  very_low  -0.0584     0.0108  -5.40   <0.001  23.9 -0.0796 -0.0372
## 
## Term: PEG
## Type:  probs 
## Comparison: +1

Interpretasi:
- Peningkatan 1 unit PEG meningkatkan probabilitas kategori “High” sebesar 67.8%.
- Sebaliknya, menurunkan probabilitas “Low” dan “Middle” secara signifikan.


Kesimpulan

  • Untuk MLR, variabel safety, persons, buying, dan maint sangat berpengaruh.
  • Untuk OLR, PEG dan LPR adalah faktor paling dominan dalam menentukan tingkat pengetahuan.

Seluruh model menunjukkan konvergensi baik dan hasil yang valid. Evaluasi melalui log-odds, RRR, dan marginal effects memberikan pemahaman komprehensif terhadap pengaruh variabel dalam model.