Tugas Week 11

Probability Distribution

Tugas Week 11

Kartu Branding Naifah (Interaktif) - Revisi Jarak & Ukuran Box

Data Science | ITSB

Foto Profil Naifah Edria Arta

Naifah Edria Arta

"Digging into data, uncovering stories, and shaping the future???one insight at a time."

Skill Focus

R Program Data Visualization Data Analysis Statistics

Course

Basic Statistics

Academic Advisor

Bakti Siregar, M.Sc., CDS

Case Study 1

Confidence Interval for Mean, \(\sigma\) Known: An e-commerce platform wants to estimate the average number of daily transactions per user after launching a new feature. Based on large-scale historical data, the population standard deviation is known.

\[\begin{eqnarray*} \sigma &=& 3.2 \quad \text{(population standard deviation)} \\ n &=& 100 \quad \text{(sample size)} \\ \bar{x} &=& 12.6 \quad \text{(sample mean)} \end{eqnarray*}\]

tasks:

  1. Identify the appropriate statistical test and justify your choice.
  2. Compute the Confidence Intervals for:
    • \(90\%\)
    • \(95\%\)
    • \(99\%\)
  3. Create a comparison visualization of the three confidence intervals.
  4. Interpret the results in a business analytics context.

Answer

1. Identifikasi Uji Statistik yang Tepat

Confidence Interval untuk mean berbasis distribusi Z (Z-interval)

Alasan pemilihan:

– Simpangan baku populasi σ diketahui (σ = 3,2).

– Ukuran sampel besar (n = 100 ≥ 30) sehingga distribusi rata-rata sampel mendekati normal (Central Limit Theorem).

– Tujuan analisis adalah mengestimasi rata-rata populasi, bukan menguji perbedaan atau hipotesis.

✅ Oleh karena itu, Z Confidence Interval untuk mean adalah metode yang paling tepat.

2. Perhitungan Confidence Interval

Diketahui:

Perhitungan Confidence Interval (CI)Rumus umum untuk Confidence Interval adalah:\(\bar{x} \pm Z \left( \frac{\sigma}{\sqrt{n}} \right)\)

Di mana Standard Error (\(SE\)) adalah\(SE = \frac{3.2}{\sqrt{100}} = \frac{3.2}{10} = 0.32\)

Tabel Perhitungan Confidence Interval
Confidence_Level Z_Score Margin_of_Error Lower_Bound Upper_Bound
90% 1.645 0.526 12.074 13.126
95% 1.960 0.627 11.973 13.227
99% 2.576 0.824 11.776 13.424

3. Visualisasi Perbandingan Confidence Interval

library(ggplot2)
library(plotly)

# 1. Menyiapkan data untuk plotting
plot_data <- data.frame(
  Level = factor(c("90%", "95%", "99%"), levels = c("90%", "95%", "99%")),
  Mean = c(12.6, 12.6, 12.6),
  Lower = c(12.074, 11.973, 11.776),
  Upper = c(13.126, 13.227, 13.424)
)

# Tambahkan teks
plot_data$hover_text <- paste0(
  "Level: ", plot_data$Level,
  "\nMean: ", plot_data$Mean,
  "\nRange: [", plot_data$Lower, " - ", plot_data$Upper, "]"
)

# 2. Membuat Visualisasi Dasar dengan ggplot
p <- ggplot(plot_data, aes(x = Level, y = Mean, text = hover_text)) +
  # Rentang CI
  geom_errorbar(aes(ymin = Lower, ymax = Upper, color = Level), 
                width = 0.2, size = 0.8, show.legend = FALSE) +
  # Titik rata-rata (dibuat simpel untuk interaktivitas)
  geom_point(size = 2.5, color = "black", fill = "white", shape = 21, stroke = 1) +
  # Estetika Tema dan Label
  scale_color_manual(values = c("#E41A1C", "#377EB8", "#4DAF4A")) + # Skema Set1
  labs(
    title = "Confidence Interval: Rata-rata Transaksi",
    x = "Tingkat Kepercayaan",
    y = "Rata-rata Transaksi"
  ) +
  theme_minimal(base_size = 10) +
  theme(
    legend.position = "none",
    plot.title = element_text(face = "bold", hjust = 0.5),
    panel.grid.minor = element_blank()
  )

# 3. Konversi ke Plotly 
ggplotly(p, tooltip = "text", width = 600, height = 410) %>%
  layout(
    showlegend = FALSE,
    margin = list(t = 60, b = 40, l = 40, r = 40) # Memberi ruang agar label tidak terpotong
  ) %>%
  config(
    displayModeBar = "hover", 
    modeBarButtonsToRemove = c(
      "zoom2d", "pan2d", "select2d", "lasso2d", 
      "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d"
    ),
    displaylogo = FALSE
  )

4. Interpretasi dalam Konteks Business Analytics

– Dengan 95% keyakinan, rata-rata transaksi harian per pengguna berada di antara 11.97 hingga 13.23

– Confidence level lebih tinggi → estimasi lebih aman, tetapi kurang presisi

– 99% CI cocok untuk keputusan strategis berisiko tinggi

– 90–95% CI cocok untuk evaluasi performa fitur baru secara operasional

Implikasi bisnis:

– Fitur baru kemungkinan besar meningkatkan engagement pengguna

– Rentang CI yang relatif sempit → hasil stabil dan dapat dipercaya

Case Study 2

Confidence Interval for Mean, \(\sigma\) Unknown: A UX Research team analyzes task completion time (in minutes) for a new mobile application. The data are collected from 12 users:

\[ 8.4,\; 7.9,\; 9.1,\; 8.7,\; 8.2,\; 9.0,\; 7.8,\; 8.5,\; 8.9,\; 8.1,\; 8.6,\; 8.3 \]

Tasks:

  1. Identify the appropriate statistical test and explain why.
  2. Compute the Confidence Intervals for:
    • \(90\%\)
    • \(95\%\)
    • \(99\%\)
  3. Visualize the three intervals on a single plot.
  4. Explain how sample size and confidence level influence the interval width.

Answer

1. Identifikasi Uji Statistik

Uji statistik yang tepat adalah t-Interval (Distribusi t Student).

Alasan Pemilihan:

\(\sigma\) (Simpangan Baku Populasi) Tidak Diketahui: Kita hanya bisa menghitung standar deviasi dari data sampel (\(s\)).

– Ukuran Sampel Kecil (\(n < 30\)): Karena jumlah pengguna hanya 12 orang (\(n=12\)), distribusi normal (Z) tidak akurat untuk digunakan; distribusi t memberikan kompensasi atas ketidakpastian ekstra dari sampel kecil ini.

2. Perhitungan Statistik

Deskriptif & CIPertama, kita hitung statistik dasar dari data:

– Mean (\(\bar{x}\)): \(8.458\) menit

– Standar Deviasi Sampel (\(s\)): \(0.412\)

– Degree of Freedom (\(df\)): \(n - 1 = 11\)

– Standard Error (\(SE\)): \(\frac{s}{\sqrt{n}} = \frac{0.412}{\sqrt{12}} \approx 0.119\)

Tabel Confidence Interval: Waktu Penyelesaian Tugas (UX Research)
Confidence Level t-score (df=11) Margin of Error Lower Bound Upper Bound
90% 1.796 0.214 8.244 8.672
95% 2.201 0.262 8.196 8.720
99% 3.106 0.370 8.088 8.828

3. Visualisasi

library(ggplot2)
library(plotly)

# 1. Menyiapkan data berdasarkan perhitungan t-distribution (df = 11)
# Data: 8.4, 7.9, 9.1, 8.7, 8.2, 9.0, 7.8, 8.5, 8.9, 8.1, 8.6, 8.3
# Mean = 8.458
plot_data <- data.frame(
  Level = factor(c("90%", "95%", "99%"), levels = c("90%", "95%", "99%")),
  Mean = c(8.458, 8.458, 8.458),
  Lower = c(8.244, 8.196, 8.088),
  Upper = c(8.672, 8.720, 8.828)
)

# Menyiapkan teks hover agar informatif (Informasi Mean & Rentang)
plot_data$hover_text <- paste0(
  "<b>Level: ", plot_data$Level, "</b><br>",
  "Mean: ", plot_data$Mean, " menit<br>",
  "Rentang: [", plot_data$Lower, " - ", plot_data$Upper, "]"
)

# 2. Membuat Visualisasi Dasar dengan ggplot2
p <- ggplot(plot_data, aes(x = Level, y = Mean, text = hover_text)) +
  # Rentang Confidence Interval (t-interval)
  geom_errorbar(aes(ymin = Lower, ymax = Upper, color = Level), 
                width = 0.2, size = 0.8, show.legend = FALSE) +
  # Titik Rata-rata sampel
  geom_point(size = 2.5, color = "black", fill = "white", shape = 21, stroke = 1) +
  # Estetika Warna (Skema Set1)
  scale_color_manual(values = c("#E41A1C", "#377EB8", "#4DAF4A")) + 
  labs(
    title = "Confidence Interval: Waktu Penyelesaian Tugas (UX)",
    x = "Tingkat Kepercayaan",
    y = "Waktu (Menit)"
  ) +
  theme_minimal(base_size = 10) +
  theme(
    legend.position = "none",
    plot.title = element_text(face = "bold", hjust = 0.5),
    panel.grid.minor = element_blank()
  )

# 3. Output Interaktif dengan Plotly (Ukuran Ringkas & Modebar Minimalis)
ggplotly(p, tooltip = "text", width = 600, height = 410) %>%
  layout(
    showlegend = FALSE,
    margin = list(t = 60, b = 40, l = 40, r = 40),
    hoverlabel = list(bgcolor = "white", font = list(size = 11), align = "left")
  ) %>%
  config(
    displayModeBar = "hover", 
    modeBarButtonsToRemove = c(
      "zoom2d", "pan2d", "select2d", "lasso2d", 
      "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d",
      "hoverClosestCartesian", "hoverCompareCartesian"
    ),
    displaylogo = FALSE
  )

4. Analisis Hubungan Faktor

Bagaimana variabel-variabel ini memengaruhi lebar interval?

  1. Tingkat Kepercayaan (Confidence Level):

Hubungan: Berbanding Lurus.

Penjelasan: Semakin tinggi keyakinan yang Anda inginkan (misal 99%), semakin lebar rentang yang dibutuhkan. Bayangkan seperti melempar jaring untuk menangkap ikan; jika Anda ingin 99% yakin menangkap ikan “rata-rata”, Anda butuh jaring yang lebih lebar.

  1. Ukuran Sampel (\(n\)):

    Hubungan: Berbanding Terbalik.

    Penjelasan: Semakin banyak pengguna yang Anda uji (sampel meningkat), semakin kecil Standard Error-nya. Hal ini membuat interval semakin sempit (presisi meningkat). Dalam kasus UX ini, hanya dengan 12 pengguna, interval kita relatif lebar karena ketidakpastiannya masih tinggi.

Case Study 3

Confidence Interval for a Proportion, A/B Testing: A data science team runs an A/B test on a new Call-To-Action (CTA) button design. The experiment yields:

\[ \begin{eqnarray*} n &=& 400 \quad \text{(total users)} \\ x &=& 156 \quad \text{(users who clicked the CTA)} \end{eqnarray*} \]

Tasks:

  1. Compute the sample proportion \(\hat{p}\).
  2. Compute Confidence Intervals for the proportion at:
    • \(90\%\)
    • \(95\%\)
    • \(99\%\)
  3. Visualize and compare the three intervals.
  4. Explain how confidence level affects decision-making in product experiments.

Answer

1. Menghitung Proporsi Sampel

(\(\hat{p}\))Proporsi sampel adalah rasio antara jumlah pengguna yang mengklik dengan total pengguna dalam eksperimen. \(\hat{p} = \frac{x}{n} = \frac{156}{400} = 0.39 \text{ atau } 39\%\)

2. Perhitungan Confidence Interval untuk Proporsi

Rumus yang digunakan adalah Normal Approximation (Z-Interval for Proportions):\(\hat{p} \pm Z \times \sqrt{\frac{\hat{p}(1 - \hat{p})}{n}}\)

Standard Error (\(SE\)) dihitung sebagai berikut:\(SE = \sqrt{\frac{0.39 \times 0.61}{400}} = \sqrt{0.00059475} \approx 0.02439\)

Estimasi berdasarkan Tingkat Kepercayaan
Confidence_Level Z_score Margin_of_Error Lower_Bound Upper_Bound
90% 1.645 4.01% 34.99% 43.01%
95% 1.960 4.78% 34.22% 43.78%
99% 2.576 6.28% 32.72% 45.28%

3. Visualisasi

library(ggplot2)
library(plotly)
library(scales)

# 1. Siapkan data untuk plotting 
# Berdasarkan p_hat = 0.39 dan MOE yang telah dihitung
plot_data <- data.frame(
  Level = factor(c("90%", "95%", "99%"), levels = c("90%", "95%", "99%")),
  Mean = c(0.39, 0.39, 0.39),
  Lower = c(0.3499, 0.3422, 0.3272),
  Upper = c(0.4301, 0.4378, 0.4528)
)

# Tambahkan teks
plot_data$hover_text <- paste0(
  "Level: ", plot_data$Level,
  "\nMean: ", percent(plot_data$Mean, 0.1),
  "\nRange: [", percent(plot_data$Lower, 0.1), " - ", percent(plot_data$Upper, 0.1), "]"
)

# 2. Membuat Visualisasi Dasar dengan ggplot
p <- ggplot(plot_data, aes(x = Level, y = Mean, text = hover_text)) +
  # Rentang CI
  geom_errorbar(aes(ymin = Lower, ymax = Upper, color = Level), 
                width = 0.2, size = 0.8, show.legend = FALSE) +
  # Titik rata-rata (dibuat simpel untuk interaktivitas)
  geom_point(size = 2.5, color = "black", fill = "white", shape = 21, stroke = 1) +
  # Estetika Tema dan Label
  scale_color_manual(values = c("#E41A1C", "#377EB8", "#4DAF4A")) + # Skema Set1 sama persis
  labs(
    title = "Confidence Interval: Proporsi Klik (CTA)",
    x = "Tingkat Kepercayaan",
    y = "Click-Through Rate (%)"
  ) +
  scale_y_continuous(labels = percent_format(), limits = c(0.3, 0.5)) +
  theme_minimal(base_size = 10) +
  theme(
    legend.position = "none",
    plot.title = element_text(face = "bold", hjust = 0.5),
    panel.grid.minor = element_blank()
  )

# 3. Konversi ke Plotly 
ggplotly(p, tooltip = "text", width = 600, height = 410) %>%
  layout(
    showlegend = FALSE,
    margin = list(t = 60, b = 40, l = 40, r = 40) # Memberi ruang agar label tidak terpotong
  ) %>%
  config(
    displayModeBar = "hover", 
    modeBarButtonsToRemove = c(
      "zoom2d", "pan2d", "select2d", "lasso2d", 
      "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d"
    ),
    displaylogo = FALSE
  )

4. Pengaruh Tingkat Kepercayaan dalam Pengambilan Keputusan

Dalam pengembangan produk, pemilihan tingkat kepercayaan (Confidence Level) adalah tentang menyeimbangkan risiko dan kecepatan:

  1. Tingkat Kepercayaan Tinggi (99%): * Kapan digunakan: Digunakan saat perubahan desain melibatkan risiko besar, misalnya merombak alur pembayaran (checkout). Kita ingin sangat yakin bahwa estimasi kita tidak salah sebelum melakukan investasi besar. * Konsekuensi: Interval akan melebar. Jika batas bawah (32.7%) masih dianggap menguntungkan dibanding desain lama, maka keputusan “Luncurkan” sangat aman secara statistik.

  2. Tingkat Kepercayaan Standar (95%): * Kapan digunakan: Standar industri untuk sebagian besar eksperimen produk. Memberikan keseimbangan yang adil antara akurasi dan kepastian.

  3. Tingkat Kepercayaan Rendah (90%): * Kapan digunakan: Digunakan saat iterasi cepat (rapid prototyping) di mana biaya kesalahan rendah. * Konsekuensi: Interval lebih sempit (presisi tinggi), tapi ada peluang 10% bahwa CTR asli populasi sebenarnya berada di luar rentang tersebut.

Kesimpulan untuk Tim Produk: Jika desain CTA lama memiliki CTR sebesar 30%, maka pada ketiga tingkat kepercayaan di atas, desain baru secara konsisten menunjukkan hasil yang lebih baik (karena batas bawah terendah 32.7% masih > 30%). Desain ini layak untuk diimplementasikan.

Case Study 4

Precision Comparison (Z-Test vs t-Test): Two data teams measure API latency (in milliseconds) under different conditions.

\[\begin{eqnarray*} \text{Team A:} \\ n &=& 36 \quad \text{(sample size)} \\ \bar{x} &=& 210 \quad \text{(sample mean)} \\ \sigma &=& 24 \quad \text{(known population standard deviation)} \\[6pt] \text{Team B:} \\ n &=& 36 \quad \text{(sample size)} \\ \bar{x} &=& 210 \quad \text{(sample mean)} \\ s &=& 24 \quad \text{(sample standard deviation)} \end{eqnarray*}\]

Tasks

  1. Identify the statistical test used by each team.
  2. Compute Confidence Intervals for 90%, 95%, and 99%.
  3. Create a visualization comparing all intervals.
  4. Explain why the interval widths differ, even with similar data.

Answer

1. Identifikasi Uji Statistik

Identifikasi Uji Statistik: Team A vs Team B
Tim Uji Statistik Alasan Pemilihan
Team A Z-Interval Simpangan baku populasi (σ) diketahui secara pasti.
Team B t-Interval Simpangan baku populasi tidak diketahui, menggunakan simpangan baku sampel (s).

2. Perhitungan Confidence Interval

Keduanya memiliki Standard Error (\(SE\)) yang sama secara matematis: \(SE = \frac{24}{\sqrt{36}} = 4\). Namun, nilai kritis yang digunakan berbeda.

Perbandingan Presisi: Team A (Z-Test) vs Team B (t-Test)
Team A (σ Diketahui)
Team B (σ Tidak Diketahui)
Level Z-Score CI Team A t-Score (df=35) CI Team B
90% 1.645 203.42 - 216.58 1.690 203.24 - 216.76
95% 1.960 202.16 - 217.84 2.030 201.88 - 218.12
99% 2.576 199.70 - 220.30 2.724 199.10 - 220.90

3. Visualisasi

library(ggplot2)
library(plotly)

# 1. Menyiapkan data untuk plotting (Latensi API)
# Menggabungkan data Team A dan Team B
plot_data <- data.frame(
  Team = rep(c("Team A (Z-Test)", "Team B (t-Test)"), each = 3),
  Level = factor(rep(c("90%", "95%", "99%"), 2), levels = c("90%", "95%", "99%")),
  Mean = 210,
  Lower = c(203.42, 202.16, 199.70,  # Team A
            203.24, 201.88, 199.10), # Team B
  Upper = c(216.58, 217.84, 220.30,  # Team A
            216.76, 218.12, 220.90)  # Team B
)

# Menyiapkan teks hover agar membedakan antar tim
plot_data$hover_text <- paste0(
  "<b>", plot_data$Team, "</b>",
  "\nLevel: ", plot_data$Level,
  "\nMean: ", plot_data$Mean, " ms",
  "\nRange: [", plot_data$Lower, " - ", plot_data$Upper, "]"
)

# 2. Membuat Visualisasi Dasar dengan ggplot
p <- ggplot(plot_data, aes(x = Level, y = Mean, color = Team, text = hover_text)) +
  # Menggunakan position_dodge agar garis tidak tumpang tindih
  geom_errorbar(aes(ymin = Lower, ymax = Upper), 
                width = 0.3, size = 0.8, 
                position = position_dodge(width = 0.5)) +
  # Titik rata-rata
  geom_point(size = 2, color = "black", fill = "white", shape = 21, stroke = 1,
             position = position_dodge(width = 0.5)) +
  # Estetika Warna: Biru untuk Team A, Merah untuk Team B
  scale_color_manual(values = c("#377EB8", "#E41A1C")) + 
  labs(
    title = "Perbandingan Presisi: Z-Interval vs t-Interval",
    x = "Tingkat Kepercayaan",
    y = "Latensi API (ms)"
  ) +
  theme_minimal(base_size = 10) +
  theme(
    legend.position = "none", # Menghilangkan legenda sesuai permintaan
    plot.title = element_text(face = "bold", hjust = 0.5),
    panel.grid.minor = element_blank()
  )

# 3. Konversi ke Plotly dengan fitur minimalis
ggplotly(p, tooltip = "text", width = 600, height = 410) %>%
  layout(
    showlegend = FALSE,
    margin = list(t = 60, b = 40, l = 40, r = 40)
  ) %>%
  config(
    displayModeBar = "hover", 
    modeBarButtonsToRemove = c(
      "zoom2d", "pan2d", "select2d", "lasso2d", 
      "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d"
    ),
    displaylogo = FALSE
  )

4. Mengapa Lebar Interval Berbeda?

Meskipun nilai rata-rata sampel (\(\bar{x}\)) dan deviasi standarnya sama, Team B (t-test) selalu memiliki interval yang lebih lebar daripada Team A (Z-test). Berikut alasannya:

  1. Ketidakpastian Tambahan: Team A menggunakan \(\sigma\) (parameter populasi yang pasti). Team B menggunakan \(s\) (estimasi dari sampel). Karena \(s\) sendiri bisa bervariasi dari satu sampel ke sampel lainnya, distribusi-\(t\) memberikan “hukuman” berupa rentang yang lebih lebar untuk mengompensasi ketidakpastian estimasi tersebut.

  2. Karakteristik Distribusi: Distribusi-\(t\) memiliki heavier tails (ekor yang lebih tebal) dibandingkan distribusi normal standar. Hal ini menyebabkan nilai kritis \(t^*\) selalu lebih besar daripada \(z^*\) untuk tingkat kepercayaan yang sama.

  3. Derajat Kebebasan (\(df\)): Seiring bertambahnya ukuran sampel (\(n\)), distribusi-\(t\) akan semakin mendekati distribusi-\(Z\). Pada kasus ini (\(n=36\)), perbedaannya kecil namun tetap nyata secara statistik.

Case Study 5

One-Sided Confidence Interval: A Software as a Service (SaaS) company wants to ensure that at least 70% of weekly active users utilize a premium feature.

From the experiment:

\[ \begin{eqnarray*} n &=& 250 \quad \text{(total users)} \\ x &=& 185 \quad \text{(active premium users)} \end{eqnarray*} \]

Management is only interested in the lower bound of the estimate.

Tasks:

  1. Identify the type of Confidence Interval and the appropriate test.
  2. Compute the one-sided lower Confidence Interval at:
    • \(90\%\)
    • \(95\%\)
    • \(99\%\)
  3. Visualize the lower bounds for all confidence levels.
  4. Determine whether the 70% target is statistically satisfied.

Answer

1.Identifikasi Uji Statistik

Uji statistik yang sesuai adalah One-Sided Confidence Interval for Proportion menggunakan distribusi Z (Normal Standar).

Alasan Pemilihan:

– Tujuan Estimasi: Manajemen hanya peduli pada “setidaknya”, yang berarti kita mencari Lower Bound (batas bawah) untuk memastikan apakah proporsi sebenarnya tidak jatuh di bawah angka tertentu.

– Ukuran Sampel: \(n = 250\) cukup besar untuk memenuhi syarat aproksimasi normal (\(np \ge 5\) dan \(n(1-p) \ge 5\)), di mana \(250 \times 0.74 = 185\).

2. Perhitungan Confidence Interval

Batas Bawah Confidence Interval Satu Arah (p-hat = 0.74)
Confidence_Level Z_Score_One_Sided Lower_Bound Status_Target_70pct
90% 1.282 0.7044 Terpenuhi
95% 1.645 0.6944 Belum Terpenuhi
99% 2.326 0.6755 Belum Terpenuhi

3. Visualisasi

library(ggplot2)
library(plotly)

plot_data <- data.frame(
  Team = rep(c("Team A (Z-Test)", "Team B (t-Test)"), each = 3),
  Level = factor(rep(c("90%", "95%", "99%"), 2),
                 levels = c("90%", "95%", "99%")),
  Mean = c(205, 205, 205, 205, 205, 205),
  Lower = c(
    198.8, 197.2, 194.5,   # Team A
    198.2, 196.6, 193.8    # Team B
  ),
  Upper = c(
    211.2, 212.8, 215.5,   # Team A
    211.8, 213.4, 216.2    # Team B
  )
)

# Hover text
plot_data$hover_text <- paste0(
  "<b>", plot_data$Team, "</b>",
  "<br>Tingkat Kepercayaan: ", plot_data$Level,
  "<br>Mean: ", plot_data$Mean, " ms",
  "<br>CI: [", plot_data$Lower, " , ", plot_data$Upper, "]"
)


p <- ggplot(plot_data, aes(x = Level, y = Mean, color = Team, text = hover_text)) +
  geom_errorbar(
    aes(ymin = Lower, ymax = Upper),
    width = 0.3,
    size = 0.8,
    position = position_dodge(width = 0.5)
  ) +
  geom_point(
    size = 2,
    color = "black",
    fill = "white",
    shape = 21,
    stroke = 1,
    position = position_dodge(width = 0.5)
  ) +
  scale_color_manual(values = c("#377EB8", "#E41A1C")) +
  labs(
    title = "Perbandingan Presisi Confidence Interval",
    x = "Tingkat Kepercayaan",
    y = "Latensi API (ms)"
  ) +
  theme_minimal(base_size = 10) +
  theme(
    legend.position = "none",
    plot.title = element_text(face = "bold", hjust = 0.5),
    panel.grid.minor = element_blank()
  )


ggplotly(p, tooltip = "text", width = 600, height = 410) %>%
  layout(
    showlegend = FALSE,
    margin = list(t = 60, b = 40, l = 40, r = 40)
  ) %>%
  config(
    displayModeBar = "hover",
    modeBarButtonsToRemove = c(
      "zoom2d", "pan2d", "select2d", "lasso2d",
      "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d"
    ),
    displaylogo = FALSE
  )

4. Kesimpulan Statistik

Berdasarkan hasil analisis:

– Pada Tingkat Kepercayaan 90% (Batas bawah \(\approx\) 70.5%): Target Terpenuhi. Kita yakin 90% bahwa proporsi pengguna setidaknya 70.5%.

– Pada Tingkat Kepercayaan 95% (Batas bawah \(\approx\) 69.4%): Target Secara Teknis Belum Terpenuhi. Ada kemungkinan proporsi sebenarnya sedikit di bawah 70%.

– Pada Tingkat Kepercayaan 99% (Batas bawah \(\approx\) 67.5%): Target Belum Terpenuhi.

Kesimpulan Akhir: Jika manajemen ingin sangat yakin (95% atau 99%), mereka belum bisa menyatakan target 70% tercapai secara statistik karena batas bawah interval berada di bawah target.