Memuat
Memuat
Binary Logistic Regression for Informatics and Information Systems
0 views
The goal is to model the probability of failed deployment from changed lines of code and test coverage using odds ratios; all illustrations use synthetic data. Binary logistic regression models the probability of a yes/no event from several predictors through the logit link and expresses effects as odds ratios. It suits theses whose outcome is dichotomous, such as loan default, on-time graduation or disease status.

The goal is to model the probability of failed deployment from changed lines of code and test coverage using odds ratios; all illustrations use synthetic data.
| Role | Variable | Unit |
|---|---|---|
| Main | Failed deployment | 0/1 |
| Supporting 1 | Changed lines of code | lines |
| Supporting 2 | Test coverage | % |
The logistic model for Failed deployment is significant overall (LR test p < 0.001, McFadden R2 = 0.151). A one-SD increase in Changed lines of code raises the odds by a factor of 2.75 (p < 0.001). The model separates the two classes with an AUC of 0.752 and 68.8% accuracy at the 0.5 cut-off.
Computed from illustrative synthetic data, not from a real study.
Binary logistic regression models the probability of a yes/no event from several predictors through the logit link and expresses effects as odds ratios. It suits theses whose outcome is dichotomous, such as loan default, on-time graduation or disease status.
Report odds ratios with 95% confidence intervals and p-values; an OR above 1 raises the odds of the event and below 1 lowers them. Add the likelihood ratio test, McFadden pseudo R2, AUC and accuracy as measures of model quality.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
# Contoh kode R: Binary Logistic Regression
suppressPackageStartupMessages({
library(ggplot2)
library(patchwork)
library(pROC)
})
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(changed_lines_of_code = rnorm(n, 50, 10),
test_coverage = rnorm(n, 30, 6))
z1 <- as.numeric(scale(d$changed_lines_of_code))
z2 <- as.numeric(scale(d$test_coverage))
b0 <- runif(1, -0.8, 0.3)
b1 <- runif(1, 0.8, 1.5)
b2 <- runif(1, 0.25, 0.75) * sample(c(-1, 1), 1)
d$failed_deployment <- rbinom(n, 1, plogis(b0 + b1 * z1 + b2 * z2)) # 1 = kejadian terjadi, 0 = tidak
write.csv(d, "data_contoh.csv", row.names = FALSE)
# ---- Analisis: regresi logistik biner (glm, family binomial) ----
fit <- glm(failed_deployment ~ changed_lines_of_code + test_coverage, family = binomial, data = d)
s <- summary(fit)
print(s)
or_tab <- exp(cbind(OR = coef(fit), confint.default(fit))) # odds ratio per satuan + CI Wald 95%
print(round(or_tab, 4))
# Odds ratio per 1 simpangan baku (lebih mudah dibandingkan antarprediktor)
sdx <- c(sd(d$changed_lines_of_code), sd(d$test_coverage))
se_b <- s$coefficients[2:3, 2]
or_sd <- data.frame(var = c("changed_lines_of_code", "test_coverage"),
or = exp(coef(fit)[2:3] * sdx),
lo = exp((coef(fit)[2:3] - 1.96 * se_b) * sdx),
hi = exp((coef(fit)[2:3] + 1.96 * se_b) * sdx),
p = s$coefficients[2:3, 4])
print(or_sd)
# ---- Uji kelayakan model ----
fit0 <- glm(failed_deployment ~ 1, family = binomial, data = d)
lr <- anova(fit0, fit, test = "Chisq") # uji likelihood ratio (omnibus)
print(lr)
p_lr <- lr[2, "Pr(>Chi)"]
r2_mcf <- 1 - as.numeric(logLik(fit)) / as.numeric(logLik(fit0)) # pseudo R2 McFadden
d$peluang <- fitted(fit)
roc_obj <- pROC::roc(d$failed_deployment, d$peluang, quiet = TRUE)
auc_v <- as.numeric(pROC::auc(roc_obj))
d$kelas <- as.integer(d$peluang >= 0.5)
print(table(Aktual = d$failed_deployment, Prediksi = factor(d$kelas, levels = 0:1))) # matriks klasifikasi
akurasi <- mean(d$kelas == d$failed_deployment)
cat(sprintf("AUC = %.3f; akurasi (ambang 0.5) = %.3f; McFadden R2 = %.3f\n", auc_v, akurasi, r2_mcf))
# ---- Grafik ----
# Kurva peluang prediksi menurut X1 (X2 ditahan pada rata-ratanya) dengan pita 95%
g <- data.frame(changed_lines_of_code = seq(min(d$changed_lines_of_code), max(d$changed_lines_of_code), length.out = 120), test_coverage = mean(d$test_coverage))
pr <- predict(fit, newdata = g, type = "link", se.fit = TRUE)
g$m <- plogis(pr$fit); g$lo <- plogis(pr$fit - 1.96 * pr$se.fit); g$hi <- plogis(pr$fit + 1.96 * pr$se.fit)
p1 <- ggplot() +
geom_jitter(data = d, aes(changed_lines_of_code, failed_deployment), height = 0.04, width = 0, colour = pal[1], alpha = 0.35, size = 1.5) +
geom_ribbon(data = g, aes(changed_lines_of_code, ymin = lo, ymax = hi), fill = pal[2], alpha = 0.2) +
geom_line(data = g, aes(changed_lines_of_code, m), colour = pal[2], linewidth = 1.2) +
scale_y_continuous(breaks = c(0, 0.25, 0.5, 0.75, 1)) +
labs(title = "Predicted probability (observed 0/1 jittered)", x = "changed_lines_of_code", y = "P(event = 1)")
dr <- data.frame(fpr = 1 - roc_obj$specificities, tpr = roc_obj$sensitivities)
dr <- dr[order(dr$fpr, dr$tpr), ]
p2 <- ggplot(dr, aes(fpr, tpr)) +
geom_abline(slope = 1, intercept = 0, linetype = "dashed", colour = warna$redup) +
geom_area(fill = pal[3], alpha = 0.15) +
geom_path(colour = pal[3], linewidth = 1.1) +
annotate("text", x = 0.62, y = 0.18, label = sprintf("AUC = %.3f", auc_v), colour = warna$teks, size = 3.6) +
labs(title = "ROC curve", x = "1 - specificity", y = "Sensitivity")
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 = "Odds ratio per 1 SD (95% CI, log scale)", x = "Odds ratio", 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$16
excl. 11% VAT
Duration: 3 working days
Output: R files + result figures
Deliverables
Package 2 · most chosen
US$47
excl. 11% VAT
Duration: 7 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$103
excl. 11% VAT
Duration: 12-15 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. Binary 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$16, Package 2 (your data analysis and interpretation) US$47 and Package 3 (full guidance) US$103, 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