Memuat
Memuat
Bootstrap Confidence Intervals for Logistics and Supply Chain
0 views
Compute bootstrap confidence intervals for the median of supplier lead time, correlation with supplier distance and coefficient of order size; all figures come from synthetic data. The bootstrap builds confidence intervals by resampling the data many times, so it does not rely on a normality assumption. It suits theses with skewed data or statistics whose standard errors are hard to derive, such as the median, a correlation or a regression coefficient in limited samples.

Compute bootstrap confidence intervals for the median of supplier lead time, correlation with supplier distance and coefficient of order size; all figures come from synthetic data.
| Role | Variable | Unit |
|---|---|---|
| Main | Supplier lead time | days |
| Supporting 1 | Supplier distance | km |
| Supporting 2 | Order size | tons |
With 2000 bootstrap replicates, the median Supplier lead time is 13.18 (BCa 95%: 12.80 to 13.87). The correlation of Supplier lead time with Supplier distance is r = 0.667 (BCa: 0.610 to 0.715) and the regression coefficient of Supplier distance is 0.352 (BCa: 0.304 to 0.417), which excludes zero and is therefore significant.
Computed from illustrative synthetic data, not from a real study.
The bootstrap builds confidence intervals by resampling the data many times, so it does not rely on a normality assumption. It suits theses with skewed data or statistics whose standard errors are hard to derive, such as the median, a correlation or a regression coefficient in limited samples.
Report the point estimate, bootstrap standard error and 95% BCa interval (more accurate for skewed data) with the number of replicates. An interval excluding zero indicates a significant correlation or coefficient; compare with classic intervals to show the impact of the normality assumption.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
# Contoh kode R: Bootstrap Confidence Intervals
suppressPackageStartupMessages({
library(ggplot2)
library(patchwork)
library(boot)
})
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: Y menceng kanan, dipengaruhi X1 dan X2 ----
n <- 200
d <- data.frame(supplier_distance = round(pmax(rnorm(n, 50, 10), 0), 3),
order_size = round(pmax(rnorm(n, 30, 6), 0), 3))
z1 <- as.numeric(scale(d$supplier_distance))
z2 <- as.numeric(scale(d$order_size))
lat <- runif(1, 0.45, 0.8) * z1 + runif(1, 0.15, 0.4) * sample(c(-1, 1), 1) * z2 + rnorm(n, 0, runif(1, 0.6, 0.85))
w <- exp(runif(1, 0.45, 0.7) * lat) # transformasi eksponensial -> menceng kanan
d$supplier_lead_time <- round(pmax(100 + 15 * (w - mean(w)) / sd(w), 0.05 * abs(100)), 3)
write.csv(d, "data_contoh.csv", row.names = FALSE)
# ---- Statistik yang di-bootstrap (median, korelasi, koefisien regresi) ----
statistik <- function(data, i) {
s <- data[i, ]
c(median = median(s$supplier_lead_time),
korelasi = cor(s$supplier_lead_time, s$supplier_distance),
koef = unname(coef(lm(supplier_lead_time ~ supplier_distance + order_size, data = s))[2]))
}
print(summary(d))
cat("Skewness Y:", round(mean((d$supplier_lead_time - mean(d$supplier_lead_time))^3) / sd(d$supplier_lead_time)^3, 3), "\n")
# ---- Bootstrap nonparametrik R = 2000 ----
b <- boot::boot(d, statistik, R = 2000)
print(b)
ci <- lapply(1:3, function(j) boot::boot.ci(b, conf = 0.95, type = c("perc", "bca"), index = j))
print(ci)
# ---- Interval kepercayaan klasik sebagai pembanding ----
ys <- sort(d$supplier_lead_time)
kb <- qbinom(c(0.025, 0.975), n, 0.5) # CI median berbasis statistik tataan (binomial)
ci_med <- c(ys[max(kb[1], 1)], ys[min(kb[2] + 1, n)])
ct <- cor.test(d$supplier_lead_time, d$supplier_distance) # CI Fisher z untuk korelasi
fit <- lm(supplier_lead_time ~ supplier_distance + order_size, data = d)
ci_koef <- confint(fit)[2, ] # CI t (asumsi normal) untuk koefisien
print(summary(fit))
tabel <- do.call(rbind, lapply(1:3, function(j) {
klasik <- list(ci_med, as.numeric(ct$conf.int), as.numeric(ci_koef))[[j]]
data.frame(stat = c("Median", "Correlation", "Coefficient")[j], estimasi = unname(b$t0[j]),
metode = c("Classic", "Percentile", "BCa"),
bawah = c(klasik[1], ci[[j]]$percent[4], ci[[j]]$bca[4]),
atas = c(klasik[2], ci[[j]]$percent[5], ci[[j]]$bca[5]))
}))
tabel$lebar <- tabel$atas - tabel$bawah
print(tabel)
se_boot <- apply(b$t, 2, sd)
# ---- Grafik ----
nm_stat <- c("Median", "Correlation", "Coefficient")
db <- data.frame(stat = factor(rep(nm_stat, each = nrow(b$t)), levels = nm_stat), nilai = as.vector(b$t))
tabel$stat <- factor(tabel$stat, levels = nm_stat)
tabel$metode <- factor(tabel$metode, levels = c("BCa", "Percentile", "Classic"))
garis <- rbind(transform(tabel[tabel$metode != "Classic", ], x = bawah),
transform(tabel[tabel$metode != "Classic", ], x = atas))
p1 <- ggplot(db, aes(nilai)) +
geom_histogram(bins = 35, fill = pal[1], colour = warna$panel, alpha = 0.75) +
geom_vline(data = garis, aes(xintercept = x, colour = metode, linetype = metode), linewidth = 0.8) +
geom_vline(data = tabel[tabel$metode == "BCa", ], aes(xintercept = estimasi), colour = warna$teks, linewidth = 0.9) +
facet_wrap(~stat, scales = "free") +
scale_colour_manual(values = c(BCa = pal[2], Percentile = pal[3]), name = "95% CI") +
scale_linetype_manual(values = c(BCa = "solid", Percentile = "dashed"), name = "95% CI") +
scale_x_continuous(n.breaks = 4) +
labs(title = "Bootstrap distributions (R = 2000)", x = "Bootstrap estimate", y = "Count") +
theme(legend.position = "bottom")
p2 <- ggplot(tabel, aes(estimasi, metode, colour = metode)) +
geom_errorbarh(aes(xmin = bawah, xmax = atas), height = 0.3, linewidth = 1) +
geom_point(size = 2.4) +
facet_wrap(~stat, scales = "free_x", ncol = 1) +
scale_colour_manual(values = c(BCa = pal[2], Percentile = pal[3], Classic = warna$redup), guide = "none") +
scale_x_continuous(n.breaks = 5) +
labs(title = "95% CI: classic vs percentile vs BCa", x = "Estimate", y = NULL)
idx <- replicate(60, sample(n, replace = TRUE), simplify = FALSE)
gb <- do.call(rbind, lapply(seq_along(idx), function(k) {
cf <- coef(lm(supplier_lead_time ~ supplier_distance, data = d[idx[[k]], ]))
data.frame(rep = k, a = cf[1], b = cf[2])
}))
p3 <- ggplot(d, aes(supplier_distance, supplier_lead_time)) +
geom_point(colour = pal[4], alpha = 0.45, size = 1.3) +
geom_abline(data = gb, aes(intercept = a, slope = b), colour = pal[2], alpha = 0.15, linewidth = 0.6) +
geom_smooth(method = "lm", formula = y ~ x, se = FALSE, colour = warna$teks, linewidth = 1) +
labs(title = "Bootstrap regression lines (60 resamples)", x = "supplier_distance", y = "supplier_lead_time")
p_hasil <- if (tata == 1) p1 / (p3 | p2) + plot_layout(heights = c(0.9, 1.2)) else p1 / (p2 | p3) + plot_layout(heights = c(0.9, 1.2))
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$125
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. Bootstrap Confidence Intervals is commonly used at this level in Logistics and Supply Chain. 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$125, 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