Memuat
Memuat
Ordinal Logistic Regression for Informatics and Information Systems
0 views
Through synthetic data, the illustrated aim is to estimate the odds of a higher level of user satisfaction level given app loading time and usability score. Ordinal logistic regression (the proportional odds model) models an ordered categorical outcome, such as low, medium and high, from several predictors. It suits theses whose outcome is a level, grade or ordered rating.

Through synthetic data, the illustrated aim is to estimate the odds of a higher level of user satisfaction level given app loading time and usability score.
| Role | Variable | Unit |
|---|---|---|
| Main | User satisfaction level | class |
| Supporting 1 | App loading time | s |
| Supporting 2 | Usability score | score |
A one-SD increase in App loading time multiplies the odds of a higher User satisfaction level category by 4.84 (p < 0.001); the OR for Usability score is 1.43. The model is significant (LR test p < 0.001, McFadden R2 = 0.215) and the proportional odds test (p = 0.280) supports the assumption. Classification accuracy is 61.5%.
Computed from illustrative synthetic data, not from a real study.
Ordinal logistic regression (the proportional odds model) models an ordered categorical outcome, such as low, medium and high, from several predictors. It suits theses whose outcome is a level, grade or ordered rating.
An OR above 1 means a higher predictor value shifts respondents towards higher categories; report the OR, 95% confidence interval and p-value. Include the likelihood ratio test, the proportional odds test (p > 0.05 means the assumption holds) and a plot of predicted category probabilities.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
# Contoh kode R: Ordinal Logistic Regression
suppressPackageStartupMessages({
library(ggplot2)
library(patchwork)
library(MASS)
library(ordinal)
})
set.seed(42)
# ---- Gaya grafik ----
pal <- c("#1f6feb", "#e8590c", "#2f9e44", "#ae3ec9", "#f59f00")
warna <- list(bg = "#f4f6fa", panel = "#ffffff", teks = "#1f2933", redup = "#5f6b78", grid = "#e3e8ee", bar = "#1d3557")
tata <- 1
theme_set(theme_minimal(base_size = 11) + theme(legend.position = "bottom"))
# ---- Data sintetis ----
n <- 200
d <- data.frame(app_loading_time = rnorm(n, 50, 10),
usability_score = rnorm(n, 30, 6))
z1 <- as.numeric(scale(d$app_loading_time))
z2 <- as.numeric(scale(d$usability_score))
b1 <- runif(1, 0.9, 1.6)
b2 <- runif(1, 0.3, 0.8) * sample(c(-1, 1), 1)
laten <- b1 * z1 + b2 * z2 + rlogis(n) # variabel laten kontinu di balik kategori
batas <- quantile(laten, c(runif(1, 0.25, 0.4), runif(1, 0.6, 0.75)))
kat <- c("A", "B", "C") # urutan rendah ke tinggi
d$user_satisfaction_level <- factor(kat[findInterval(laten, batas) + 1], levels = kat, ordered = TRUE)
write.csv(d, "data_contoh.csv", row.names = FALSE)
# ---- Analisis: regresi logistik ordinal (proportional odds, MASS::polr) ----
d$user_satisfaction_level <- factor(d$user_satisfaction_level, levels = kat, ordered = TRUE) # pastikan urutan kategori benar (mis. setelah read.csv)
fit <- MASS::polr(user_satisfaction_level ~ app_loading_time + usability_score, data = d, Hess = TRUE)
print(summary(fit))
ct <- coef(summary(fit))
pval <- 2 * pnorm(abs(ct[, "t value"]), lower.tail = FALSE) # p-value aproksimasi normal
print(cbind(ct, "p value" = round(pval, 4)))
or_tab <- exp(cbind(OR = coef(fit), confint.default(fit))) # odds ratio per satuan + CI Wald 95%
print(round(or_tab, 4))
# OR per 1 simpangan baku (sebanding antarprediktor)
sdx <- c(sd(d$app_loading_time), sd(d$usability_score))
se_b <- ct[1:2, "Std. Error"]
or_sd <- data.frame(var = c("app_loading_time", "usability_score"),
or = exp(coef(fit) * sdx), lo = exp((coef(fit) - 1.96 * se_b) * sdx),
hi = exp((coef(fit) + 1.96 * se_b) * sdx), p = pval[1:2])
# ---- Uji model: LR terhadap model null dan uji asumsi odds proporsional (ordinal::clm) ----
f_clm <- ordinal::clm(user_satisfaction_level ~ app_loading_time + usability_score, data = d)
f_null <- ordinal::clm(user_satisfaction_level ~ 1, data = d)
lr <- anova(f_null, f_clm)
print(lr)
p_lr <- lr[2, "Pr(>Chisq)"]
r2_mcf <- 1 - as.numeric(logLik(f_clm)) / as.numeric(logLik(f_null))
p_po <- tryCatch({
f_nom <- ordinal::clm(user_satisfaction_level ~ 1, nominal = ~ app_loading_time + usability_score, data = d) # ambang berbeda per prediktor
a <- anova(f_clm, f_nom); print(a); a[2, "Pr(>Chisq)"]
}, error = function(e) {
nt <- ordinal::nominal_test(f_clm); print(nt); min(nt[-1, "Pr(>Chi)"], na.rm = TRUE)
})
if (!is.finite(p_po)) p_po <- 1
prob <- predict(fit, type = "probs")
d$prediksi <- factor(kat[max.col(prob)], levels = kat)
tab <- table(Aktual = d$user_satisfaction_level, Prediksi = d$prediksi)
print(tab)
akurasi <- mean(as.character(d$prediksi) == as.character(d$user_satisfaction_level))
# ---- Grafik ----
# Peluang prediksi tiap kategori menurut X1 (X2 pada rata-rata), area bertumpuk
g <- data.frame(app_loading_time = seq(min(d$app_loading_time), max(d$app_loading_time), length.out = 120), usability_score = mean(d$usability_score))
pg <- predict(fit, newdata = g, type = "probs")
dg <- data.frame(x = rep(g$app_loading_time, 3), kategori = factor(rep(kat, each = nrow(g)), levels = rev(kat)),
p = as.numeric(pg))
p1 <- ggplot(dg, aes(x, p, fill = kategori)) +
geom_area(alpha = 0.8, colour = warna$panel, linewidth = 0.3) +
scale_fill_manual(values = setNames(pal[1:3], kat), breaks = kat, name = NULL,
labels = function(s) substr(s, 1, 18)) +
scale_y_continuous(labels = scales::percent) +
labs(title = "Predicted category probabilities", x = "app_loading_time", y = "Probability")
# Distribusi kategori: teramati vs prediksi model
dk <- rbind(data.frame(kategori = kat, jenis = "Observed", jml = as.numeric(table(d$user_satisfaction_level))),
data.frame(kategori = kat, jenis = "Predicted", jml = as.numeric(colSums(prob))))
dk$kategori <- factor(dk$kategori, levels = kat)
p2 <- ggplot(dk, aes(kategori, jml, fill = jenis)) +
geom_col(position = position_dodge(width = 0.75), width = 0.7, alpha = 0.85) +
scale_fill_manual(values = c(Observed = pal[4], Predicted = pal[5]), name = NULL) +
scale_x_discrete(labels = function(s) substr(s, 1, 12)) +
labs(title = "Category distribution", x = NULL, y = "Count")
p3 <- ggplot(or_sd, aes(or, var)) +
geom_vline(xintercept = 1, linetype = "dashed", colour = warna$redup) +
geom_segment(aes(x = lo, xend = hi, yend = var), colour = pal[1], linewidth = 1.1) +
geom_point(colour = pal[2], size = 3.2) +
geom_text(aes(label = sprintf("%.2f", or)), vjust = -1.1, colour = warna$teks, size = 3.2) +
scale_x_log10() +
labs(title = "Proportional odds ratio per 1 SD (95% CI)", x = "Odds ratio (log scale)", y = NULL)
p_hasil <- if (tata == 1) p1 | (p2 / p3) else p1 / (p2 | p3)
print(p_hasil)
The original project file is available. It is not just the picture above: you get the working R project. It can be downloaded after payment, and we send it by WhatsApp or email.
ZIP: analisis.R + data_contoh.csv + BACA-DULU.txt
Choose how much help you need. Each higher package includes everything in the lower ones. Prices exclude 11% VAT.
Package 1
US$19
excl. 11% VAT
Duration: 5 working days
Output: R files + result figures
Deliverables
Package 2 · most chosen
US$56
excl. 11% VAT
Duration: 9 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$128
excl. 11% VAT
Duration: 14-17 working days
Output: Code + analysis + guidance until ready to present
Includes all of Packages 1 & 2, plus
Yes. The original project file is a ZIP containing the complete analisis.R script, a data_contoh.csv sample dataset and a BACA-DULU.txt guide. It can be downloaded after payment, and we send it by WhatsApp or email. For your own data (Package 2 and 3) the script is adapted to your dataset.
Yes. Ordinal Logistic Regression is commonly used at this level in Informatics and Information Systems. We adapt the analysis to your research question, your own data and your supervisor's requirements.
No. The sheet is computed from illustrative synthetic data so you can see the kind of output R Studio gives. For your order we run the same method on your own data.
That is the point of the packages. Every script is commented, and Package 3 includes two coaching sessions plus practice questions so you can explain the method and the results at your seminar and defence.
Each project has three packages: Package 1 (code and explanation) US$19, Package 2 (your data analysis and interpretation) US$56 and Package 3 (full guidance) US$128, excluding 11% VAT. Larger datasets, extra methods or tight deadlines adjust the quote after a short consultation.
The result sheet uses illustrative synthetic data. R is a programming language of the R Foundation project; RStudio and Posit are trademarks of Posit PBC.
Back to R Studio portfolio