# ANALISIS PENGUKURAN BERULANG KADAR ASAM URAT: 3 KELOMPOK x 4 WAKTU
# Jalankan seluruh script melalui Source di RStudio.
#
# **Nama:** Akhmad Tarmizi 
# **NIM:** 2611018025  
# **Mata Kuliah:** Biostatistika Intermediete  
# **Program Studi:** Magister Kesehatan Masyarakat Universitas Mulawarman
#
# ## Metode
# Data mencakup tiga kelompok dan empat pengukuran kadar asam urat per peserta.
# Analisis meliputi repeated-measures ANOVA satu arah pada kelompok DASH+AF, mixed ANOVA kelompok x waktu, koreksi
# Greenhouse-Geisser, pendekatan multivariat, post hoc, kontras interaksi,
# alternatif nonparametrik, dan linear mixed model (LMM).
# Baseline, minggu ke-4, minggu ke-8 dan minggu ke-12 berjarak sama.
# Sumber: data_asam_urat_wide.xlsx, sheet Data Asam Urat.
# Satuan pengukuran dan status asal data tidak dicantumkan dalam workbook.
# ======================= PARAMETER ANALISIS =========================
FILE_DATA <- "data_asam_urat_wide.xlsx"
SHEET_DATA <- "Data Asam Urat"
FOLDER_HASIL <- "Hasil_Analisis_Asam_Urat"
INSTALL_PAKET_OTOMATIS <- TRUE
BUKA_HTML_OTOMATIS <- TRUE

analisis_asam_urat <- function() {
  paket <- c("readxl", "dplyr", "tidyr", "ggplot2", "afex", "emmeans", "rstatix",
             "car", "effectsize", "lme4", "lmerTest", "pbkrtest",
             "performance", "ggpubr", "WRS2", "htmltools", "base64enc")
  belum <- paket[!vapply(paket, requireNamespace, logical(1), quietly = TRUE)]
  if (length(belum)) {
    if (!INSTALL_PAKET_OTOMATIS)
      stop("Paket belum tersedia: ", paste(belum, collapse = ", "))
    install.packages(belum, repos = "https://cloud.r-project.org")
  }
  gagal <- paket[!vapply(paket, requireNamespace, logical(1), quietly = TRUE)]
  if (length(gagal)) stop("Paket belum tersedia: ", paste(gagal, collapse = ", "))
  suppressPackageStartupMessages({
    library(dplyr); library(tidyr); library(ggplot2)
  })
  opsi_lama <- options(contrasts = c("contr.sum", "contr.poly"), width = 120)
  on.exit(options(opsi_lama), add = TRUE)
  afex::afex_options(emmeans_model = "multivariate")
  theme_set(theme_bw(base_size = 12))
  set.seed(2026)
  # Cari data di folder script dan direktori kerja.
  sumber <- unlist(lapply(sys.frames(), function(fr) {
    if (!is.null(fr$ofile)) as.character(fr$ofile) else character(0)
  }))
  if (requireNamespace("rstudioapi", quietly = TRUE) && rstudioapi::isAvailable()) {
    aktif <- tryCatch(rstudioapi::getSourceEditorContext()$path,
                     error = function(e) "")
    if (nzchar(aktif)) sumber <- c(sumber, aktif)
  }
  kandidat <- unique(c(file.path(dirname(sumber), FILE_DATA), FILE_DATA))
  kandidat <- kandidat[file.exists(kandidat)]
  if (!length(kandidat)) stop(
    "Berkas Excel tidak ditemukan. Letakkan data dan script dalam folder yang sama, ",
    "atau isi FILE_DATA dengan lokasi lengkap berkas. Nama yang dicari: ", FILE_DATA)
  path_data <- normalizePath(kandidat[1], winslash = "/", mustWork = TRUE)
  if (!SHEET_DATA %in% readxl::excel_sheets(path_data))
    stop("Sheet tidak ditemukan: ", SHEET_DATA)
  folder <- file.path(dirname(path_data), FOLDER_HASIL)
  message("Data: ", path_data, "\nSheet: ", SHEET_DATA, "\nHasil: ", folder)
  dir.create(folder, recursive = TRUE, showWarnings = FALSE)
  hasil <- list(); isi <- list(); grafik <- list()
  teks <- function(judul, x) {
    cat("\n", judul, "\n", sep = "")
    cat(x, "\n")
    isi[[length(isi) + 1L]] <<- htmltools::tagList(
      htmltools::tags$h2(judul), htmltools::tags$p(x))
  }
  tampil <- function(nama, x) {
    hasil[[nama]] <<- x
    cat("\n", gsub("_", " ", nama), "\n", sep = "")
    print(x)
    cetak <- capture.output(print(x))
    writeLines(cetak, file.path(folder, paste0(nama, ".txt")))
    if (is.data.frame(x)) write.csv(x, file.path(folder, paste0(nama, ".csv")), row.names = FALSE)
    isi[[length(isi) + 1L]] <<- htmltools::tagList(
      htmltools::tags$h2(gsub("_", " ", nama)),
      htmltools::tags$pre(paste(cetak, collapse = "\n")))
    invisible(x)
  }
  gambar <- function(nama, p, lebar = 11, tinggi = 6) {
    print(p)
    berkas <- file.path(folder, paste0(nama, ".png"))
    ggsave(berkas, plot = p, width = lebar, height = tinggi, dpi = 300, bg = "white")
    grafik[[nama]] <<- p
    isi[[length(isi) + 1L]] <<- htmltools::tagList(
      htmltools::tags$h2(gsub("_", " ", nama)),
      htmltools::tags$img(src = base64enc::dataURI(file = berkas, mime = "image/png"),
                         style = "max-width:100%;height:auto;"))
    invisible(p)
  }
  opsional <- function(nama, ekspresi) {
    tryCatch(tampil(nama, ekspresi), error = function(e) {
      teks(nama, paste("Analisis tidak dapat diestimasi:", conditionMessage(e)))
      invisible(NULL)
    })
  }
  fp <- function(p) ifelse(is.na(p), "NA", ifelse(p < .001, "< 0,001",
                          paste0("= ", formatC(p, digits = 3, format = "f", decimal.mark = ","))))

  dat_wide <- as.data.frame(readxl::read_excel(path_data, sheet = SHEET_DATA))
  names(dat_wide) <- trimws(names(dat_wide))
  kolom <- c("id", "kelompok", "usia", "jk", "AU_M0", "AU_M4", "AU_M8", "AU_M12")
  if (!all(kolom %in% names(dat_wide)))
    stop("Kolom tidak ditemukan: ", paste(setdiff(kolom, names(dat_wide)), collapse = ", "))
  if (!nrow(dat_wide)) stop("Sheet data tidak memiliki peserta.")
  if (anyNA(dat_wide$id) || anyDuplicated(dat_wide$id))
    stop("ID peserta kosong atau duplikat. Periksa kolom id.")
  dat_wide$id <- trimws(as.character(dat_wide$id))
  dat_wide$kelompok <- trimws(as.character(dat_wide$kelompok))
  if (any(!nzchar(dat_wide$id)) || anyDuplicated(dat_wide$id))
    stop("ID peserta kosong atau duplikat setelah spasi dibersihkan.")
  minggu <- c(0, 4, 8, 12)
  kolom_au <- c("AU_M0", "AU_M4", "AU_M8", "AU_M12")
  kelompok <- c("Kontrol", "DASH", "DASH+AF")
  if (anyNA(dat_wide$kelompok) || !setequal(unique(dat_wide$kelompok), kelompok))
    stop("Kolom kelompok harus memuat Kontrol, DASH, dan DASH+AF tanpa nilai kosong.")
  if (!all(vapply(dat_wide[kolom_au], is.numeric, logical(1))))
    stop("Kolom AU_M0, AU_M4, AU_M8, dan AU_M12 harus berisi angka.")
  if (!all(is.finite(as.matrix(dat_wide[kolom_au]))))
    stop("Pengukuran asam urat mengandung nilai kosong atau tak hingga. ",
         "Versi analisis ini membutuhkan empat pengukuran lengkap per peserta.")
  dat_wide <- dat_wide |> mutate(id = factor(id), kelompok = factor(kelompok, levels = c("Kontrol", "DASH", "DASH+AF")))
  dat_long <- dat_wide |>
    pivot_longer(all_of(kolom_au), names_to = "waktu", values_to = "asam_urat") |>
    mutate(waktu = factor(waktu, levels = kolom_au, labels = c("M0", "M4", "M8", "M12")),
           minggu = minggu[as.integer(waktu)]) |> arrange(id, waktu)
  teks("Identitas", paste("Nama: Akhmad Tarmizi | NIM: 2611018025 | |",
       "Mata Kuliah: Biostatistika Intermediete | Magister Kesehatan Masyarakat Universitas Mulawarman"))
  teks("Desain", paste(nrow(dat_wide), "peserta; tiga kelompok; empat pengukuran berulang.",
                      "Tanpa nilai hilang. Satuan kadar asam urat tidak dicantumkan dalam workbook."))
  tampil("01_Jumlah_Peserta", dat_wide |> count(kelompok, name = "n"))
  tampil("01a_Usia", dat_wide |> group_by(kelompok) |> summarise(n = n(), mean = mean(usia), sd = sd(usia), min = min(usia), max = max(usia), .groups = "drop"))
  tampil("01b_Jenis_Kelamin", dat_wide |> count(kelompok, jk))
  teks("Berkas data yang digunakan", paste(path_data, "| Sheet:", SHEET_DATA))
  teks("Sumber data", "Analisis dihitung dari sheet Data Asam Urat. Sheet Ringkasan hanya berisi statistik agregat. Satuan pengukuran dan status data asli/simulasi tidak dicantumkan; interpretasi menggunakan skala numerik dalam workbook.")
  tampil("02_Data_Wide", head(dat_wide))
  tampil("03_Data_Long", head(dat_long, 12))
  desk <- dat_long |> group_by(kelompok, waktu, minggu) |>
    summarise(n = n(), mean = mean(asam_urat), sd = sd(asam_urat), median = median(asam_urat),
              min = min(asam_urat), max = max(asam_urat), se = sd / sqrt(n),
              lower = mean - qt(.975, n - 1) * se,
              upper = mean + qt(.975, n - 1) * se, .groups = "drop")
  tampil("04_Deskriptif", desk)
  tampil("05_Kovarians", cov(dat_wide[kolom_au]))
  tampil("06_Korelasi", cor(dat_wide[kolom_au]))
  pasangan <- combn(kolom_au, 2)
  tampil("07_Varians_Selisih", data.frame(
    pasangan = apply(pasangan, 2, paste, collapse = " - "),
    varians = apply(pasangan, 2, function(p) var(dat_wide[[p[1]]] - dat_wide[[p[2]]]))))
  gambar("G01_Profil_Rerata_CI95", ggplot(desk, aes(minggu, mean, color = kelompok, group = kelompok)) +
    geom_line(linewidth = 1) + geom_point(size = 3) +
    geom_errorbar(aes(ymin = lower, ymax = upper), width = .5) +
    scale_x_continuous(breaks = minggu) +
    labs(title = "Profil rerata kadar asam urat dan interval kepercayaan 95%", x = "Minggu", y = "Kadar asam urat", color = "Kelompok") +
    theme(legend.position = "bottom"))
  gambar("G02_Lintasan_Individu", ggplot(dat_long, aes(minggu, asam_urat, group = id)) +
    geom_line(alpha = .25) + stat_summary(aes(group = kelompok), fun = mean,
      geom = "line", color = "firebrick", linewidth = 1.2) +
    facet_wrap(~ kelompok) + scale_x_continuous(breaks = minggu) +
    labs(title = "Lintasan individu dan rerata kelompok", x = "Minggu", y = "Kadar asam urat"))
  gambar("G03_Boxplot", ggplot(dat_long, aes(waktu, asam_urat, fill = kelompok)) +
    geom_boxplot() + labs(title = "Distribusi kadar asam urat berdasarkan kelompok dan waktu", x = "Waktu", y = "Kadar asam urat", fill = "Kelompok") +
    theme(legend.position = "bottom"))

  d1 <- droplevels(filter(dat_long, kelompok == "DASH+AF"))
  tampil("08_Outlier_Satu_Kelompok", d1 |> group_by(waktu) |> rstatix::identify_outliers(asam_urat))
  tampil("09_Shapiro_Satu_Kelompok", d1 |> group_by(waktu) |> rstatix::shapiro_test(asam_urat))
  gambar("G04_QQ_Satu_Kelompok", ggpubr::ggqqplot(d1, "asam_urat", facet.by = "waktu"))
  aov1_rs <- rstatix::anova_test(data = d1, dv = asam_urat, wid = id, within = waktu, effect.size = "pes")
  tampil("10_ANOVA_Rstatix_Satu_Kelompok", aov1_rs)
  aov1 <- afex::aov_ez(id = "id", dv = "asam_urat", data = d1, within = "waktu",
                       anova_table = list(es = c("ges", "pes"), correction = "GG"))
  tampil("11_RM_ANOVA", aov1)
  tampil("12_Sferisitas_dan_Koreksi_RM", summary(aov1))
  tampil("13_Multivariat_RM", aov1$Anova)
  tampil("14_Eta_Kuadrat_RM", effectsize::eta_squared(aov1, partial = TRUE))
  em1 <- emmeans::emmeans(aov1, ~ waktu)
  tampil("15_EMM_RM", as.data.frame(em1))
  tampil("16_Posthoc_RM_Bonferroni", as.data.frame(pairs(em1, adjust = "bonferroni")))
  tampil("17_RM_vs_Baseline_Holm", as.data.frame(emmeans::contrast(em1, "trt.vs.ctrl", ref = 1, adjust = "holm")))
  tampil("18_Tren_Polinomial_RM", as.data.frame(emmeans::contrast(em1, "poly")))
  tampil("19_Friedman", rstatix::friedman_test(d1, asam_urat ~ waktu | id))
  tampil("20_Kendall_W", rstatix::friedman_effsize(d1, asam_urat ~ waktu | id))
  tampil("21_Wilcoxon_Berpasangan", d1 |> arrange(waktu, id) |>
           rstatix::wilcox_test(asam_urat ~ waktu, paired = TRUE, p.adjust.method = "bonferroni"))
  opsional("22_Robust_RM_Trim20", WRS2::rmanova(d1$asam_urat, d1$waktu, d1$id, tr = .2))

  tampil("23_Outlier_Mixed", dat_long |> group_by(kelompok, waktu) |> rstatix::identify_outliers(asam_urat))
  tampil("24_Shapiro_Mixed", dat_long |> group_by(kelompok, waktu) |> rstatix::shapiro_test(asam_urat))
  gambar("G05_QQ_Mixed", ggpubr::ggqqplot(dat_long, "asam_urat", ggtheme = theme_bw()) +
           facet_grid(waktu ~ kelompok), tinggi = 9)
  tampil("25_Levene", dat_long |> group_by(waktu) |> rstatix::levene_test(asam_urat ~ kelompok))
  tampil("26_Box_M", rstatix::box_m(dat_wide[kolom_au], dat_wide$kelompok))
  aov2 <- afex::aov_ez(id = "id", dv = "asam_urat", data = dat_long, between = "kelompok", within = "waktu",
                       anova_table = list(es = c("ges", "pes"), correction = "GG"))
  tampil("27_Mixed_ANOVA", aov2)
  tampil("28_Sferisitas_dan_Koreksi_Mixed", summary(aov2))
  tampil("29_Multivariat_Mixed", aov2$Anova)
  tampil("30_Eta_Kuadrat_Mixed", effectsize::eta_squared(aov2, partial = TRUE))
  gambar("G06_Profil_Mixed_ANOVA", afex::afex_plot(aov2, x = "waktu", trace = "kelompok",
           error = "within", mapping = c("colour", "shape", "linetype")) +
           labs(title = "Profil mixed ANOVA", x = "Waktu", y = "Kadar asam urat"))
  teks("Interval grafik mixed ANOVA", "Interval within-subject pada grafik afex berbeda dari interval kepercayaan rerata biasa pada grafik profil deskriptif.")
  tampil("31_Efek_Waktu_per_Kelompok", as.data.frame(emmeans::joint_tests(aov2, by = "kelompok")))
  tampil("32_Efek_Kelompok_per_Waktu", as.data.frame(emmeans::joint_tests(aov2, by = "waktu")))
  em2 <- emmeans::emmeans(aov2, ~ waktu | kelompok)
  em2b <- emmeans::emmeans(aov2, ~ kelompok | waktu)
  tampil("33_EMM_Waktu_per_Kelompok", as.data.frame(em2))
  tampil("34_Waktu_vs_Baseline_Holm", as.data.frame(emmeans::contrast(em2, "trt.vs.ctrl", ref = 1, adjust = "holm")))
  tampil("35_Antarkelompok_Tukey", as.data.frame(pairs(em2b, adjust = "tukey")))
  em_full <- emmeans::emmeans(aov2, ~ waktu * kelompok)
  ki <- emmeans::contrast(em_full, interaction = list(
    waktu = list("M12-M0" = c(-1, 0, 0, 1)), kelompok = "pairwise"), adjust = "holm")
  tampil("36_Kontras_Perbedaan_Perubahan", as.data.frame(ki))
  tren <- as.data.frame(emmeans::contrast(em_full,
    interaction = c(waktu = "poly", kelompok = "pairwise"), adjust = "none"))
  tren_lin <- subset(tren, waktu_poly == "linear")
  tren_lin$p.holm <- p.adjust(tren_lin$p.value, "holm")
  tampil("37_Kontras_Tren_Linear", tren_lin)
  teks("Koreksi perbandingan", "Holm untuk waktu versus baseline berlaku dalam tiap kelompok; Tukey berlaku dalam tiap waktu. Kontras perbedaan perubahan dan tren linear memakai Holm pada masing-masing keluarga kontras.")
  tabel_gg <- as.data.frame(afex::nice(aov2, correction = "GG", es = "pes"))
  tampil("38_Tabel_ANOVA_GG", tabel_gg)
  tab_num <- as.data.frame(aov2$anova_table)
  if ("kelompok:waktu" %in% rownames(tab_num)) {
    r <- tab_num["kelompok:waktu", , drop = FALSE]
    teks("Interpretasi interaksi", paste0("Mixed ANOVA dengan koreksi Greenhouse-Geisser menghasilkan interaksi kelompok x waktu: F(",
      round(r[["num Df"]], 2), ", ", round(r[["den Df"]], 2), ") = ", round(r[["F"]], 3),
      "; p ", fp(r[["Pr(>F)"]]), ". ",
      if (r[["Pr(>F)"]] < .05) "Pola perubahan kadar asam urat berbeda secara statistik antar kelompok."
      else "Belum ditemukan bukti statistik perbedaan pola perubahan kadar asam urat antar kelompok.",
      " Arah dan besarnya perbedaan dinilai dari rerata serta kontras perubahan M12-M0."))
  }

  kontrol <- lme4::lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 200000))
  lmm1 <- lmerTest::lmer(asam_urat ~ kelompok * waktu + (1 | id), data = dat_long, REML = TRUE, control = kontrol)
  lmm2 <- lmerTest::lmer(asam_urat ~ kelompok * waktu + (1 + minggu | id), data = dat_long, REML = TRUE, control = kontrol)
  tampil("39_LMM_Intersep", summary(lmm1))
  tampil("40_LMM_Intersep_Slope", summary(lmm2))
  tampil("41_Perbandingan_LMM_REML", anova(lmm1, lmm2, refit = FALSE))
  teks("Perbandingan model", "Kedua model mempunyai fixed effects yang sama. Perbandingan REML mengikuti materi; nilai p likelihood-ratio bersifat pendekatan karena varians acak diuji pada batas ruang parameter.")
  tampil("42_Singularitas_LMM", data.frame(model = c("Intersep", "Intersep dan slope"),
         singular = c(lme4::isSingular(lmm1), lme4::isSingular(lmm2))))
  opsional("43_LMM_Kenward_Roger", anova(lmm2, ddf = "Kenward-Roger"))
  opsional("44_ICC", performance::icc(lmm1))
  rd <- data.frame(prediksi = fitted(lmm2), residual = resid(lmm2))
  gambar("G07_QQ_Residual_LMM", ggplot(rd, aes(sample = residual)) + stat_qq() + stat_qq_line() +
         labs(title = "Q-Q residual LMM", x = "Kuantil teoretis", y = "Kuantil residual"))
  ra <- data.frame(intersep = lme4::ranef(lmm2)$id[, 1])
  gambar("G08_QQ_Intersep_Acak", ggplot(ra, aes(sample = intersep)) + stat_qq() + stat_qq_line() +
         labs(title = "Q-Q intersep acak LMM", x = "Kuantil teoretis", y = "Kuantil intersep acak"))
  gambar("G09_Residual_vs_Prediksi", ggplot(rd, aes(prediksi, residual)) + geom_point(alpha = .5) +
         geom_hline(yintercept = 0, linetype = 2) + labs(title = "Residual versus nilai prediksi LMM", x = "Prediksi kadar asam urat", y = "Residual"))
  em_lmm <- emmeans::emmeans(lmm2, ~ waktu | kelompok, lmer.df = "kenward-roger")
  tampil("45_EMM_LMM", as.data.frame(em_lmm))

  set.seed(1)
  dat_miss <- dat_long
  indeks_hilang <- sample(which(dat_miss$waktu != "M0"), 30)
  dat_miss$asam_urat[indeks_hilang] <- NA_real_
  teks("Demonstrasi data hilang", "Sebanyak 30 pengukuran pascabaseline dihapus secara acak hanya pada salinan demonstrasi. Analisis utama tetap menggunakan seluruh data yang dilampirkan; demonstrasi ini mengikuti bagian LMM data hilang dalam materi.")
  lmm_miss <- lmerTest::lmer(asam_urat ~ kelompok * waktu + (1 + minggu | id), data = dat_miss,
                            REML = TRUE, control = kontrol, na.action = na.omit)
  opsional("46_LMM_Data_Hilang_KR", anova(lmm_miss, ddf = "Kenward-Roger"))
  tampil("47_Ringkasan_Data_Hilang", data.frame(pengukuran_hilang = sum(is.na(dat_miss$asam_urat)),
    peserta_terdampak = n_distinct(dat_miss$id[is.na(dat_miss$asam_urat)]),
    peserta_lengkap = n_distinct(dat_miss$id) - n_distinct(dat_miss$id[is.na(dat_miss$asam_urat)]),
    pengukuran_dianalisis_LMM = nobs(lmm_miss)))
  tampil("48_Informasi_Sesi", sessionInfo())
  write.csv(dat_wide, file.path(folder, "Data_Asam_Urat_Wide.csv"), row.names = FALSE)
  write.csv(dat_long, file.path(folder, "Data_Asam_Urat_Long.csv"), row.names = FALSE)
  write.csv(dat_miss, file.path(folder, "Data_Demonstrasi_Missing.csv"), row.names = FALSE)
  saveRDS(list(hasil = hasil, data_wide = dat_wide, data_long = dat_long,
    aov1 = aov1, aov2 = aov2, lmm1 = lmm1, lmm2 = lmm2, lmm_miss = lmm_miss),
    file.path(folder, "Objek_Analisis_Asam_Urat.rds"))
  laporan <- htmltools::tags$html(lang = "id",
    htmltools::tags$head(htmltools::tags$meta(charset = "UTF-8"),
      htmltools::tags$title("Analisis Kadar Asam Urat: 3 x 4"),
      htmltools::tags$style("body{font-family:Arial,sans-serif;max-width:1100px;margin:40px auto;padding:20px;line-height:1.6;color:#17342e}h1,h2{color:#0b6b4f}h2{border-bottom:1px solid #d9e4e0;padding-top:24px}pre{background:#f3f7f5;padding:16px;overflow:auto;font-size:13px}img{display:block;margin:15px auto}")),
    htmltools::tags$body(htmltools::tags$h1("Analisis Pengukuran Berulang Kadar Asam Urat: 3 x 4"), isi))
  path_html <- file.path(folder, "Laporan_Analisis_Asam_Urat.html")
  htmltools::save_html(laporan, path_html)
  if (BUKA_HTML_OTOMATIS && interactive())
    try(utils::browseURL(path_html), silent = TRUE)
  cat("\nHasil analisis: ", normalizePath(folder), "\n", sep = "")
  invisible(list(hasil = hasil, grafik = grafik, data_wide = dat_wide,
                 data_long = dat_long, aov1 = aov1, aov2 = aov2,
                 lmm1 = lmm1, lmm2 = lmm2, lmm_miss = lmm_miss))
}

hasil_asam_urat <- analisis_asam_urat()
## Registered S3 method overwritten by 'lme4':
##   method           from
##   na.action.merMod car
## Data: E:/Tarmizi new/data_asam_urat_wide.xlsx
## Sheet: Data Asam Urat
## Hasil: E:/Tarmizi new/Hasil_Analisis_Asam_Urat
## 
## Identitas
## Nama: Akhmad Tarmizi | NIM: 2611018025 | | Mata Kuliah: Biostatistika Intermediete | Magister Kesehatan Masyarakat Universitas Mulawarman 
## 
## Desain
## 90 peserta; tiga kelompok; empat pengukuran berulang. Tanpa nilai hilang. Satuan kadar asam urat tidak dicantumkan dalam workbook. 
## 
## 01 Jumlah Peserta
##   kelompok  n
## 1  Kontrol 30
## 2     DASH 30
## 3  DASH+AF 30
## 
## 01a Usia
## # A tibble: 3 × 6
##   kelompok     n  mean    sd   min   max
##   <fct>    <int> <dbl> <dbl> <dbl> <dbl>
## 1 Kontrol     30  51.2  8.60    38    65
## 2 DASH        30  49.7  9.79    35    64
## 3 DASH+AF     30  49.1  8.07    36    64
## 
## 01b Jenis Kelamin
##   kelompok jk  n
## 1  Kontrol  L  9
## 2  Kontrol  P 21
## 3     DASH  L 19
## 4     DASH  P 11
## 5  DASH+AF  L 14
## 6  DASH+AF  P 16
## 
## Berkas data yang digunakan
## E:/Tarmizi new/data_asam_urat_wide.xlsx | Sheet: Data Asam Urat 
## 
## Sumber data
## Analisis dihitung dari sheet Data Asam Urat. Sheet Ringkasan hanya berisi statistik agregat. Satuan pengukuran dan status data asli/simulasi tidak dicantumkan; interpretasi menggunakan skala numerik dalam workbook. 
## 
## 02 Data Wide
##     id kelompok usia jk AU_M0 AU_M4 AU_M8 AU_M12
## 1 P001  Kontrol   42  L   6.7   7.2   6.4    6.5
## 2 P002  Kontrol   43  L   7.0   6.3   7.0    6.8
## 3 P003  Kontrol   62  P   5.1   5.2   4.7    6.3
## 4 P004  Kontrol   40  P   6.6   6.4   6.0    7.0
## 5 P005  Kontrol   53  P   6.1   5.8   6.6    6.2
## 6 P006  Kontrol   42  L   7.1   6.6   6.9    6.5
## 
## 03 Data Long
## # A tibble: 12 × 7
##    id    kelompok  usia jk    waktu asam_urat minggu
##    <fct> <fct>    <dbl> <chr> <fct>     <dbl>  <dbl>
##  1 P001  Kontrol     42 L     M0          6.7      0
##  2 P001  Kontrol     42 L     M4          7.2      4
##  3 P001  Kontrol     42 L     M8          6.4      8
##  4 P001  Kontrol     42 L     M12         6.5     12
##  5 P002  Kontrol     43 L     M0          7        0
##  6 P002  Kontrol     43 L     M4          6.3      4
##  7 P002  Kontrol     43 L     M8          7        8
##  8 P002  Kontrol     43 L     M12         6.8     12
##  9 P003  Kontrol     62 P     M0          5.1      0
## 10 P003  Kontrol     62 P     M4          5.2      4
## 11 P003  Kontrol     62 P     M8          4.7      8
## 12 P003  Kontrol     62 P     M12         6.3     12
## 
## 04 Deskriptif
## # A tibble: 12 × 12
##    kelompok waktu minggu     n  mean    sd median   min   max    se lower upper
##    <fct>    <fct>  <dbl> <int> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1 Kontrol  M0         0    30  6.78 1.07    6.7    4.6   8.9 0.194  6.38  7.18
##  2 Kontrol  M4         4    30  6.78 1.12    6.75   4.5   9.1 0.205  6.36  7.20
##  3 Kontrol  M8         8    30  6.64 1.25    6.6    3.6   9.2 0.228  6.17  7.11
##  4 Kontrol  M12       12    30  6.75 1.01    6.55   5.1   9.4 0.185  6.37  7.13
##  5 DASH     M0         0    30  6.97 1.00    6.95   5.3   9.2 0.183  6.59  7.34
##  6 DASH     M4         4    30  6.68 0.982   6.45   5.1   8.9 0.179  6.31  7.05
##  7 DASH     M8         8    30  6.45 1.01    6.3    4.6   8.7 0.184  6.08  6.83
##  8 DASH     M12       12    30  6.18 1.07    6.15   4.6   8.9 0.195  5.78  6.58
##  9 DASH+AF  M0         0    30  6.83 1.04    6.7    4.4   9.1 0.190  6.44  7.22
## 10 DASH+AF  M4         4    30  6.47 1.18    6.2    4     8.8 0.215  6.03  6.91
## 11 DASH+AF  M8         8    30  6.08 1.24    5.95   3.2   8.7 0.227  5.62  6.55
## 12 DASH+AF  M12       12    30  5.84 1.17    5.85   3.6   8.2 0.214  5.40  6.27
## 
## 05 Kovarians
##            AU_M0    AU_M4    AU_M8    AU_M12
## AU_M0  1.0548077 1.041194 1.104733 0.9831161
## AU_M4  1.0411935 1.193703 1.131793 1.0251386
## AU_M8  1.1047328 1.131793 1.394433 1.1479476
## AU_M12 0.9831161 1.025139 1.147948 1.2955506
## 
## 06 Korelasi
##            AU_M0     AU_M4     AU_M8    AU_M12
## AU_M0  1.0000000 0.9278904 0.9109022 0.8409903
## AU_M4  0.9278904 1.0000000 0.8772430 0.8243417
## AU_M8  0.9109022 0.8772430 1.0000000 0.8540750
## AU_M12 0.8409903 0.8243417 0.8540750 1.0000000
## 
## 07 Varians Selisih
##         pasangan   varians
## 1  AU_M0 - AU_M4 0.1661236
## 2  AU_M0 - AU_M8 0.2397753
## 3 AU_M0 - AU_M12 0.3841261
## 4  AU_M4 - AU_M8 0.3245506
## 5 AU_M4 - AU_M12 0.4389763
## 6 AU_M8 - AU_M12 0.3940886

## 
## 08 Outlier Satu Kelompok
## [1] waktu      id         kelompok   usia       jk         asam_urat  minggu     is.outlier is.extreme
## <0 rows> (or 0-length row.names)
## 
## 09 Shapiro Satu Kelompok
## # A tibble: 4 × 4
##   waktu variable  statistic     p
##   <fct> <chr>         <dbl> <dbl>
## 1 M0    asam_urat     0.986 0.956
## 2 M4    asam_urat     0.965 0.424
## 3 M8    asam_urat     0.973 0.612
## 4 M12   asam_urat     0.979 0.808

## 
## 10 ANOVA Rstatix Satu Kelompok
## ANOVA Table (type III tests)
## 
## $ANOVA
##   Effect DFn DFd      F        p p<.05   pes
## 1  waktu   3  87 45.869 7.15e-18     * 0.613
## 
## $`Mauchly's Test for Sphericity`
##   Effect     W     p p<.05
## 1  waktu 0.694 0.072      
## 
## $`Sphericity Corrections`
##   Effect   GGe      DF[GG]    p[GG] p[GG]<.05   HFe     DF[HF]    p[HF] p[HF]<.05
## 1  waktu 0.845 2.54, 73.54 1.84e-15         * 0.933 2.8, 81.18 7.88e-17         *
## 
## 
## 11 RM ANOVA
## Anova Table (Type 3 tests)
## 
## Response: asam_urat
##   Effect          df  MSE         F  ges  pes p.value
## 1  waktu 2.54, 73.54 0.15 45.87 *** .099 .613   <.001
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG 
## 
## 12 Sferisitas dan Koreksi RM
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##             Sum Sq num Df Error SS den Df F value    Pr(>F)    
## (Intercept) 4769.1      1  144.965     29 954.048 < 2.2e-16 ***
## waktu         17.1      3   10.816     87  45.869 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##       Test statistic  p-value
## waktu        0.69402 0.071917
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##        GG eps Pr(>F[GG])    
## waktu 0.84532  1.839e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##          HF eps   Pr(>F[HF])
## waktu 0.9330749 7.880193e-17
## 
## 13 Multivariat RM
## 
## Type III Repeated Measures MANOVA Tests: Pillai test statistic
##             Df test stat approx F num Df den Df    Pr(>F)    
## (Intercept)  1   0.97050   954.05      1     29 < 2.2e-16 ***
## waktu        1   0.85808    54.42      3     27 1.416e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 14 Eta Kuadrat RM
## # Effect Size for ANOVA (Type III)
## 
## Parameter | Eta2 (partial) |       95% CI
## -----------------------------------------
## waktu     |           0.61 | [0.50, 1.00]
## 
## - One-sided CIs: upper bound fixed at [1.00].
## 15 EMM RM
##  waktu   emmean        SE df lower.CL upper.CL
##  M0    6.830000 0.1897457 29 6.441926 7.218074
##  M4    6.466667 0.2147082 29 6.027539 6.905794
##  M8    6.083333 0.2265221 29 5.620044 6.546623
##  M12   5.836667 0.2136429 29 5.399718 6.273615
## 
## Confidence level used: 0.95 
## 
## 16 Posthoc RM Bonferroni
##  contrast  estimate         SE df t.ratio p.value
##  M0 - M4  0.3633333 0.07038210 29   5.162 <0.0001
##  M0 - M8  0.7466667 0.07874494 29   9.482 <0.0001
##  M0 - M12 0.9933333 0.08800906 29  11.287 <0.0001
##  M4 - M8  0.3833333 0.10732734 29   3.572  0.0076
##  M4 - M12 0.6300000 0.10138693 29   6.214 <0.0001
##  M8 - M12 0.2466667 0.09501764 29   2.596  0.0879
## 
## P value adjustment: bonferroni method for 6 tests 
## 
## 17 RM vs Baseline Holm
##  contrast   estimate         SE df t.ratio p.value
##  M4 - M0  -0.3633333 0.07038210 29  -5.162 <0.0001
##  M8 - M0  -0.7466667 0.07874494 29  -9.482 <0.0001
##  M12 - M0 -0.9933333 0.08800906 29 -11.287 <0.0001
## 
## P value adjustment: holm method for 3 tests 
## 
## 18 Tren Polinomial RM
##  contrast   estimate        SE df t.ratio p.value
##  linear    -3.363333 0.2978653 29 -11.291 <0.0001
##  quadratic  0.116667 0.1058174 29   1.103  0.2793
##  cubic      0.156667 0.3223721 29   0.486  0.6306
## 
## 
## 19 Friedman
## # A tibble: 1 × 6
##   .y.           n statistic    df        p method       
## * <chr>     <int>     <dbl> <dbl>    <dbl> <chr>        
## 1 asam_urat    30      55.6     3 5.20e-12 Friedman test
## 
## 20 Kendall W
## # A tibble: 1 × 5
##   .y.           n effsize method    magnitude
## * <chr>     <int>   <dbl> <chr>     <ord>    
## 1 asam_urat    30   0.617 Kendall W large    
## 
## 21 Wilcoxon Berpasangan
## # A tibble: 6 × 9
##   .y.       group1 group2    n1    n2 statistic             p        p.adj p.adj.signif
## * <chr>     <chr>  <chr>  <int> <int>     <dbl>         <dbl>        <dbl> <chr>       
## 1 asam_urat M0     M4        30    30      413  0.0000558     0.000335     ***         
## 2 asam_urat M0     M8        30    30      462  0.00000000745 0.0000000447 ****        
## 3 asam_urat M0     M12       30    30      462  0.00000000931 0.0000000559 ****        
## 4 asam_urat M4     M8        30    30      390. 0.000587      0.00352      **          
## 5 asam_urat M4     M12       30    30      442. 0.00000114    0.00000686   ****        
## 6 asam_urat M8     M12       30    30      349  0.0147        0.0880       ns          
## 
## 22 Robust RM Trim20
## Call:
## WRS2::rmanova(y = d1$asam_urat, groups = d1$waktu, blocks = d1$id, 
##     tr = 0.2)
## 
## Test statistic: F = 23.6353 
## Degrees of freedom 1: 2.97 
## Degrees of freedom 2: 50.55 
## p-value: 0 
## 
## 
## 23 Outlier Mixed
## # A tibble: 10 × 9
##    kelompok waktu id     usia jk    asam_urat minggu is.outlier is.extreme
##    <fct>    <fct> <fct> <dbl> <chr>     <dbl>  <dbl> <lgl>      <lgl>     
##  1 Kontrol  M0    P013     63 L           8.9      0 TRUE       FALSE     
##  2 Kontrol  M8    P013     63 L           9.2      8 TRUE       FALSE     
##  3 Kontrol  M8    P014     50 P           3.6      8 TRUE       FALSE     
##  4 Kontrol  M12   P013     63 L           8.6     12 TRUE       FALSE     
##  5 Kontrol  M12   P020     41 L           9.2     12 TRUE       FALSE     
##  6 Kontrol  M12   P022     62 P           9.4     12 TRUE       TRUE      
##  7 Kontrol  M12   P029     41 L           8.3     12 TRUE       FALSE     
##  8 DASH     M4    P045     45 L           8.7      4 TRUE       FALSE     
##  9 DASH     M4    P046     57 L           8.9      4 TRUE       FALSE     
## 10 DASH     M4    P049     39 L           8.8      4 TRUE       FALSE     
## 
## 24 Shapiro Mixed
## # A tibble: 12 × 5
##    kelompok waktu variable  statistic       p
##    <fct>    <fct> <chr>         <dbl>   <dbl>
##  1 Kontrol  M0    asam_urat     0.960 0.309  
##  2 Kontrol  M4    asam_urat     0.980 0.825  
##  3 Kontrol  M8    asam_urat     0.969 0.524  
##  4 Kontrol  M12   asam_urat     0.896 0.00680
##  5 DASH     M0    asam_urat     0.973 0.624  
##  6 DASH     M4    asam_urat     0.929 0.0459 
##  7 DASH     M8    asam_urat     0.971 0.555  
##  8 DASH     M12   asam_urat     0.962 0.355  
##  9 DASH+AF  M0    asam_urat     0.986 0.956  
## 10 DASH+AF  M4    asam_urat     0.965 0.424  
## 11 DASH+AF  M8    asam_urat     0.973 0.612  
## 12 DASH+AF  M12   asam_urat     0.979 0.808

## 
## 25 Levene
## # A tibble: 4 × 5
##   waktu   df1   df2 statistic     p
##   <fct> <int> <int>     <dbl> <dbl>
## 1 M0        2    87   0.00953 0.991
## 2 M4        2    87   0.959   0.387
## 3 M8        2    87   0.505   0.605
## 4 M12       2    87   0.634   0.533
## 
## 26 Box M
## # A tibble: 1 × 4
##   statistic p.value parameter method                                             
##       <dbl>   <dbl>     <dbl> <chr>                                              
## 1      27.2   0.129        20 Box's M-test for Homogeneity of Covariance Matrices
## 
## 27 Mixed ANOVA
## Anova Table (Type 3 tests)
## 
## Response: asam_urat
##           Effect           df  MSE         F  ges  pes p.value
## 1       kelompok        2, 87 4.42      1.29 .026 .029    .280
## 2          waktu 2.42, 210.37 0.17 48.14 *** .044 .356   <.001
## 3 kelompok:waktu 4.84, 210.37 0.17 10.13 *** .019 .189   <.001
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG 
## 
## 28 Sferisitas dan Koreksi Mixed
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                 Sum Sq num Df Error SS den Df   F value    Pr(>F)    
## (Intercept)    15382.1      1   384.78     87 3477.9614 < 2.2e-16 ***
## kelompok          11.4      2   384.78     87    1.2903    0.2804    
## waktu             19.5      3    35.15    261   48.1420 < 2.2e-16 ***
## kelompok:waktu     8.2      6    35.15    261   10.1306 4.522e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                Test statistic    p-value
## waktu                 0.57481 4.5869e-09
## kelompok:waktu        0.57481 4.5869e-09
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                 GG eps Pr(>F[GG])    
## waktu          0.80601  < 2.2e-16 ***
## kelompok:waktu 0.80601   1.62e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                   HF eps   Pr(>F[HF])
## waktu          0.8306986 5.013127e-21
## kelompok:waktu 0.8306986 1.026115e-08
## 
## 29 Multivariat Mixed
## 
## Type III Repeated Measures MANOVA Tests: Pillai test statistic
##                Df test stat approx F num Df den Df    Pr(>F)    
## (Intercept)     1   0.97560   3478.0      1     87 < 2.2e-16 ***
## kelompok        2   0.02881      1.3      2     87    0.2804    
## waktu           1   0.76354     91.5      3     85 < 2.2e-16 ***
## kelompok:waktu  2   0.57739     11.6      6    172 6.387e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 30 Eta Kuadrat Mixed
## # Effect Size for ANOVA (Type III)
## 
## Parameter      | Eta2 (partial) |       95% CI
## ----------------------------------------------
## kelompok       |           0.03 | [0.00, 1.00]
## waktu          |           0.36 | [0.28, 1.00]
## kelompok:waktu |           0.19 | [0.11, 1.00]
## 
## - One-sided CIs: upper bound fixed at [1.00].
## Warning: Panel(s) show a mixed within-between-design.
## Error bars do not allow comparisons across all means.
## Suppress error bars with: error = "none"

## 
## Interval grafik mixed ANOVA
## Interval within-subject pada grafik afex berbeda dari interval kepercayaan rerata biasa pada grafik profil deskriptif. 
## 
## 31 Efek Waktu per Kelompok
## kelompok = Kontrol:
##  model term df1 df2 F.ratio p.value
##  waktu        3  87   1.110  0.3494
## 
## kelompok = DASH:
##  model term df1 df2 F.ratio p.value
##  waktu        3  87  47.894 <0.0001
## 
## kelompok = DASH+AF:
##  model term df1 df2 F.ratio p.value
##  waktu        3  87  82.977 <0.0001
## 
## 
## 32 Efek Kelompok per Waktu
## waktu = M0:
##  model term df1 df2 F.ratio p.value
##  kelompok     2  87   0.261  0.7708
## 
## waktu = M4:
##  model term df1 df2 F.ratio p.value
##  kelompok     2  87   0.639  0.5305
## 
## waktu = M8:
##  model term df1 df2 F.ratio p.value
##  kelompok     2  87   1.756  0.1787
## 
## waktu = M12:
##  model term df1 df2 F.ratio p.value
##  kelompok     2  87   5.378  0.0063
## 
## 
## 33 EMM Waktu per Kelompok
## kelompok = Kontrol:
##  waktu   emmean        SE df lower.CL upper.CL
##  M0    6.780000 0.1890870 87 6.404169 7.155831
##  M4    6.780000 0.2002897 87 6.381903 7.178097
##  M8    6.640000 0.2137857 87 6.215078 7.064922
##  M12   6.746667 0.1982858 87 6.352552 7.140781
## 
## kelompok = DASH:
##  waktu   emmean        SE df lower.CL upper.CL
##  M0    6.966667 0.1890870 87 6.590836 7.342498
##  M4    6.680000 0.2002897 87 6.281903 7.078097
##  M8    6.453333 0.2137857 87 6.028411 6.878256
##  M12   6.176667 0.1982858 87 5.782552 6.570781
## 
## kelompok = DASH+AF:
##  waktu   emmean        SE df lower.CL upper.CL
##  M0    6.830000 0.1890870 87 6.454169 7.205831
##  M4    6.466667 0.2002897 87 6.068569 6.864764
##  M8    6.083333 0.2137857 87 5.658411 6.508256
##  M12   5.836667 0.1982858 87 5.442552 6.230781
## 
## Confidence level used: 0.95 
## 
## 34 Waktu vs Baseline Holm
## kelompok = Kontrol:
##  contrast   estimate         SE df t.ratio p.value
##  M4 - M0   0.0000000 0.06943762 87   0.000  1.0000
##  M8 - M0  -0.1400000 0.07761121 87  -1.804  0.2241
##  M12 - M0 -0.0333333 0.08494382 87  -0.392  1.0000
## 
## kelompok = DASH:
##  contrast   estimate         SE df t.ratio p.value
##  M4 - M0  -0.2866667 0.06943762 87  -4.128 <0.0001
##  M8 - M0  -0.5133333 0.07761121 87  -6.614 <0.0001
##  M12 - M0 -0.7900000 0.08494382 87  -9.300 <0.0001
## 
## kelompok = DASH+AF:
##  contrast   estimate         SE df t.ratio p.value
##  M4 - M0  -0.3633333 0.06943762 87  -5.233 <0.0001
##  M8 - M0  -0.7466667 0.07761121 87  -9.621 <0.0001
##  M12 - M0 -0.9933333 0.08494382 87 -11.694 <0.0001
## 
## P value adjustment: holm method for 3 tests 
## 
## 35 Antarkelompok Tukey
## waktu = M0:
##  contrast              estimate        SE df t.ratio p.value
##  Kontrol - DASH      -0.1866667 0.2674094 87  -0.698  0.7653
##  Kontrol - (DASH+AF) -0.0500000 0.2674094 87  -0.187  0.9809
##  DASH - (DASH+AF)     0.1366667 0.2674094 87   0.511  0.8662
## 
## waktu = M4:
##  contrast              estimate        SE df t.ratio p.value
##  Kontrol - DASH       0.1000000 0.2832524 87   0.353  0.9337
##  Kontrol - (DASH+AF)  0.3133333 0.2832524 87   1.106  0.5129
##  DASH - (DASH+AF)     0.2133333 0.2832524 87   0.753  0.7325
## 
## waktu = M8:
##  contrast              estimate        SE df t.ratio p.value
##  Kontrol - DASH       0.1866667 0.3023387 87   0.617  0.8110
##  Kontrol - (DASH+AF)  0.5566667 0.3023387 87   1.841  0.1624
##  DASH - (DASH+AF)     0.3700000 0.3023387 87   1.224  0.4424
## 
## waktu = M12:
##  contrast              estimate        SE df t.ratio p.value
##  Kontrol - DASH       0.5700000 0.2804184 87   2.033  0.1105
##  Kontrol - (DASH+AF)  0.9100000 0.2804184 87   3.245  0.0047
##  DASH - (DASH+AF)     0.3400000 0.2804184 87   1.212  0.4491
## 
## P value adjustment: tukey method for comparing a family of 3 estimates 
## 
## 36 Kontras Perbedaan Perubahan
##  waktu_custom kelompok_pairwise    estimate        SE df t.ratio p.value
##  M12-M0       Kontrol - DASH      0.7566667 0.1201287 87   6.299 <0.0001
##  M12-M0       Kontrol - (DASH+AF) 0.9600000 0.1201287 87   7.991 <0.0001
##  M12-M0       DASH - (DASH+AF)    0.2033333 0.1201287 87   1.693  0.0941
## 
## P value adjustment: holm method for 3 tests 
## 
## 37 Kontras Tren Linear
##   waktu_poly   kelompok_pairwise  estimate        SE df  t.ratio      p.value       p.holm
## 1     linear      Kontrol - DASH 2.3566667 0.4004321 87 5.885309 7.260002e-08 1.452000e-07
## 4     linear Kontrol - (DASH+AF) 3.1233333 0.4004321 87 7.799908 1.259894e-11 3.779683e-11
## 7     linear    DASH - (DASH+AF) 0.7666667 0.4004321 87 1.914599 5.883019e-02 5.883019e-02
## 
## Koreksi perbandingan
## Holm untuk waktu versus baseline berlaku dalam tiap kelompok; Tukey berlaku dalam tiap waktu. Kontras perbedaan perubahan dan tren linear memakai Holm pada masing-masing keluarga kontras. 
## 
## 38 Tabel ANOVA GG
##           Effect           df  MSE         F  pes p.value
## 1       kelompok        2, 87 4.42      1.29 .029    .280
## 2          waktu 2.42, 210.37 0.17 48.14 *** .356   <.001
## 3 kelompok:waktu 4.84, 210.37 0.17 10.13 *** .189   <.001
## 
## Interpretasi interaksi
## Mixed ANOVA dengan koreksi Greenhouse-Geisser menghasilkan interaksi kelompok x waktu: F(4.84, 210.37) = 10.131; p < 0,001. Pola perubahan kadar asam urat berbeda secara statistik antar kelompok. Arah dan besarnya perbedaan dinilai dari rerata serta kontras perubahan M12-M0.
## boundary (singular) fit: see help('isSingular')
## 
## 39 LMM Intersep
## Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
## Formula: asam_urat ~ kelompok * waktu + (1 | id)
##    Data: dat_long
## Control: kontrol
## 
## REML criterion at convergence: 651.6
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.70490 -0.54912 -0.01823  0.52179  2.99938 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  id       (Intercept) 1.0720   1.035   
##  Residual             0.1347   0.367   
## Number of obs: 360, groups:  id, 90
## 
## Fixed effects:
##                    Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)        6.536667   0.110839  86.999996  58.974  < 2e-16 ***
## kelompok1          0.200000   0.156751  86.999996   1.276  0.20538    
## kelompok2          0.032500   0.156751  86.999996   0.207  0.83623    
## waktu1             0.322222   0.033500 261.000001   9.619  < 2e-16 ***
## waktu2             0.105556   0.033500 261.000001   3.151  0.00182 ** 
## waktu3            -0.144444   0.033500 261.000001  -4.312 2.30e-05 ***
## kelompok1:waktu1  -0.278889   0.047376 261.000001  -5.887 1.21e-08 ***
## kelompok2:waktu1   0.075278   0.047376 261.000001   1.589  0.11329    
## kelompok1:waktu2  -0.062222   0.047376 261.000001  -1.313  0.19021    
## kelompok2:waktu2   0.005278   0.047376 261.000001   0.111  0.91138    
## kelompok1:waktu3   0.047778   0.047376 261.000001   1.008  0.31416    
## kelompok2:waktu3   0.028611   0.047376 261.000001   0.604  0.54643    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) klmpk1 klmpk2 waktu1 waktu2 waktu3 klm1:1 klm2:1 klm1:2 klm2:2 klm1:3
## kelompok1    0.000                                                                      
## kelompok2    0.000 -0.500                                                               
## waktu1       0.000  0.000  0.000                                                        
## waktu2       0.000  0.000  0.000 -0.333                                                 
## waktu3       0.000  0.000  0.000 -0.333 -0.333                                          
## klmpk1:wkt1  0.000  0.000  0.000  0.000  0.000  0.000                                   
## klmpk2:wkt1  0.000  0.000  0.000  0.000  0.000  0.000 -0.500                            
## klmpk1:wkt2  0.000  0.000  0.000  0.000  0.000  0.000 -0.333  0.167                     
## klmpk2:wkt2  0.000  0.000  0.000  0.000  0.000  0.000  0.167 -0.333 -0.500              
## klmpk1:wkt3  0.000  0.000  0.000  0.000  0.000  0.000 -0.333  0.167 -0.333  0.167       
## klmpk2:wkt3  0.000  0.000  0.000  0.000  0.000  0.000  0.167 -0.333  0.167 -0.333 -0.500
## 
## 40 LMM Intersep Slope
## Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
## Formula: asam_urat ~ kelompok * waktu + (1 + minggu | id)
##    Data: dat_long
## Control: kontrol
## 
## REML criterion at convergence: 651.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.69257 -0.55505 -0.03363  0.51123  3.05558 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev. Corr 
##  id       (Intercept) 1.048e+00 1.023765      
##           minggu      3.757e-06 0.001938 1.00 
##  Residual             1.346e-01 0.366839      
## Number of obs: 360, groups:  id, 90
## 
## Fixed effects:
##                    Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)        6.536667   0.110839  86.999934  58.974  < 2e-16 ***
## kelompok1          0.200000   0.156751  86.999935   1.276  0.20538    
## kelompok2          0.032500   0.156751  86.999935   0.207  0.83623    
## waktu1             0.322222   0.033510 260.429159   9.616  < 2e-16 ***
## waktu2             0.105556   0.033490 261.064188   3.152  0.00181 ** 
## waktu3            -0.144444   0.033490 261.064188  -4.313 2.29e-05 ***
## kelompok1:waktu1  -0.278889   0.047390 260.429159  -5.885 1.22e-08 ***
## kelompok2:waktu1   0.075278   0.047390 260.429159   1.588  0.11340    
## kelompok1:waktu2  -0.062222   0.047362 261.064188  -1.314  0.19008    
## kelompok2:waktu2   0.005278   0.047362 261.064188   0.111  0.91136    
## kelompok1:waktu3   0.047778   0.047362 261.064188   1.009  0.31402    
## kelompok2:waktu3   0.028611   0.047362 261.064188   0.604  0.54631    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) klmpk1 klmpk2 waktu1 waktu2 waktu3 klm1:1 klm2:1 klm1:2 klm2:2 klm1:3
## kelompok1    0.000                                                                      
## kelompok2    0.000 -0.500                                                               
## waktu1      -0.036  0.000  0.000                                                        
## waktu2      -0.012  0.000  0.000 -0.333                                                 
## waktu3       0.012  0.000  0.000 -0.334 -0.333                                          
## klmpk1:wkt1  0.000 -0.036  0.018  0.000  0.000  0.000                                   
## klmpk2:wkt1  0.000  0.018 -0.036  0.000  0.000  0.000 -0.500                            
## klmpk1:wkt2  0.000 -0.012  0.006  0.000  0.000  0.000 -0.333  0.166                     
## klmpk2:wkt2  0.000  0.006 -0.012  0.000  0.000  0.000  0.166 -0.333 -0.500              
## klmpk1:wkt3  0.000  0.012 -0.006  0.000  0.000  0.000 -0.334  0.167 -0.333  0.167       
## klmpk2:wkt3  0.000 -0.006  0.012  0.000  0.000  0.000  0.167 -0.334  0.167 -0.333 -0.500
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
## 
## 
## 41 Perbandingan LMM REML
## Data: dat_long
## Models:
## lmm1: asam_urat ~ kelompok * waktu + (1 | id)
## lmm2: asam_urat ~ kelompok * waktu + (1 + minggu | id)
##      npar    AIC    BIC  logLik -2*log(L) Chisq Df Pr(>Chisq)
## lmm1   14 679.57 733.97 -325.78    651.57                    
## lmm2   16 683.38 745.55 -325.69    651.38 0.189  2     0.9098
## 
## Perbandingan model
## Kedua model mempunyai fixed effects yang sama. Perbandingan REML mengikuti materi; nilai p likelihood-ratio bersifat pendekatan karena varians acak diuji pada batas ruang parameter. 
## 
## 42 Singularitas LMM
##                model singular
## 1           Intersep    FALSE
## 2 Intersep dan slope     TRUE
## 
## 43 LMM Kenward Roger
## Type III Analysis of Variance Table with Kenward-Roger's method
##                 Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## kelompok        0.3473  0.1736     2  87.00  1.2903    0.2804    
## waktu          19.4072  6.4691     3 185.37 47.8514 < 2.2e-16 ***
## kelompok:waktu  8.1681  1.3614     6 206.40 10.0587 9.554e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 44 ICC
## # Intraclass Correlation Coefficient
## 
##     Adjusted ICC: 0.888
##   Unadjusted ICC: 0.815

## 
## 45 EMM LMM
## kelompok = Kontrol:
##  waktu   emmean        SE     df lower.CL upper.CL
##  M0    6.780000 0.1985502  93.20 6.385730 7.174270
##  M4    6.780000 0.1998832 102.10 6.383537 7.176463
##  M8    6.640000 0.2012174 101.88 6.240881 7.039119
##  M12   6.746667 0.2025527  92.95 6.344434 7.148899
## 
## kelompok = DASH:
##  waktu   emmean        SE     df lower.CL upper.CL
##  M0    6.966667 0.1985502  93.20 6.572397 7.360937
##  M4    6.680000 0.1998832 102.10 6.283537 7.076463
##  M8    6.453333 0.2012174 101.88 6.054214 6.852453
##  M12   6.176667 0.2025527  92.95 5.774434 6.578899
## 
## kelompok = DASH+AF:
##  waktu   emmean        SE     df lower.CL upper.CL
##  M0    6.830000 0.1985502  93.20 6.435730 7.224270
##  M4    6.466667 0.1998832 102.10 6.070204 6.863129
##  M8    6.083333 0.2012174 101.88 5.684214 6.482453
##  M12   5.836667 0.2025527  92.95 5.434434 6.238899
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## Demonstrasi data hilang
## Sebanyak 30 pengukuran pascabaseline dihapus secara acak hanya pada salinan demonstrasi. Analisis utama tetap menggunakan seluruh data yang dilampirkan; demonstrasi ini mengikuti bagian LMM data hilang dalam materi.
## boundary (singular) fit: see help('isSingular')
## 
## 46 LMM Data Hilang KR
## Type III Analysis of Variance Table with Kenward-Roger's method
##                 Sum Sq Mean Sq NumDF   DenDF F value    Pr(>F)    
## kelompok        0.3146  0.1573     2  87.001  1.2176    0.3009    
## waktu          18.4655  6.1552     3 167.832 47.4175 < 2.2e-16 ***
## kelompok:waktu  7.0931  1.1822     6 185.520  9.0966 1.007e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 47 Ringkasan Data Hilang
##   pengukuran_hilang peserta_terdampak peserta_lengkap pengukuran_dianalisis_LMM
## 1                30                25              65                       330
## 
## 48 Informasi Sesi
## R version 4.6.1 (2026-06-24 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 26200)
## 
## Matrix products: default
##   LAPACK version 3.12.1
## 
## locale:
## [1] LC_COLLATE=English_Indonesia.utf8  LC_CTYPE=English_Indonesia.utf8    LC_MONETARY=English_Indonesia.utf8
## [4] LC_NUMERIC=C                       LC_TIME=English_Indonesia.utf8    
## 
## time zone: Asia/Makassar
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggplot2_4.0.3 tidyr_1.3.2   dplyr_1.2.1  
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.6        xfun_0.60           bslib_0.12.0        bayestestR_0.19.0   insight_1.5.4      
##  [6] rstatix_1.1.0       lattice_0.22-9      numDeriv_2016.8-1.1 vctrs_0.7.3         tools_4.6.1        
## [11] Rdpack_2.6.6        generics_0.1.4      pbkrtest_0.5.5      datawizard_1.4.0    parallel_4.6.1     
## [16] tibble_3.3.1        pkgconfig_2.0.3     Matrix_1.7-5        WRS2_1.1-7          RColorBrewer_1.1-3 
## [21] S7_0.2.2            readxl_1.5.0        afex_1.5-1          lifecycle_1.0.5     compiler_4.6.1     
## [26] farver_2.1.2        stringr_1.6.0       lmerTest_3.2-1      carData_3.0-6       htmltools_0.5.9    
## [31] sass_0.4.10         yaml_2.3.12         Formula_1.2-6       ggpubr_1.0.0        pillar_1.11.1      
## [36] car_3.1-5           nloptr_2.2.1        jquerylib_0.1.4     MASS_7.3-65         cachem_1.1.0       
## [41] reformulas_0.4.4    boot_1.3-32         abind_1.4-8         nlme_3.1-169        tidyselect_1.2.1   
## [46] digest_0.6.39       performance_0.18.2  mvtnorm_1.4-2       stringi_1.8.9       reshape2_1.4.5     
## [51] purrr_1.2.2         labeling_0.4.3      splines_4.6.1       fastmap_1.2.0       grid_4.6.1         
## [56] cli_3.6.6           magrittr_2.0.5      base64enc_0.1-6     utf8_1.2.6          broom_1.0.13       
## [61] withr_3.0.3         scales_1.4.0        backports_1.5.1     estimability_2.0.0  rmarkdown_2.31     
## [66] emmeans_2.0.4       lme4_2.0-6          ggsignif_0.6.4      cellranger_1.1.0    evaluate_1.0.5     
## [71] knitr_1.51          parameters_0.29.3   rbibutils_2.4.1     rlang_1.3.0         Rcpp_1.1.2         
## [76] glue_1.8.1          reshape_0.8.10      rstudioapi_0.19.0   minqa_1.2.8         jsonlite_2.0.0     
## [81] effectsize_1.0.3    R6_2.6.1            plyr_1.8.9         
## 
## Hasil analisis: E:\Tarmizi new\Hasil_Analisis_Asam_Urat