高校数学の質問スレ(医者・東大卒専用) Part438 (901レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
811: 132人目の素数さん [sage] 2025/04/30(水) 08:12:32.33 ID:wedVH8wl options(warn = -1) alpha <- 0.05 sim_chisq <- function(N = 100) { # Function to simulate data for three groups and perform Chi-squared test (without Yates' correction). # N: Total sample size. # Determine sample sizes for each of the three groups. A <- sample(1:(N - 2), 1) # Randomly select a size for group A, ensuring space for B and C. remaining <- N - A if (remaining > 1) { B <- sample(1:(remaining - 1), 1) # Randomly select a size for group B, ensuring space for C. C <- N - A - B # Calculate the size for group C. ABC <- c(A, B, C) # Vector containing the sample sizes of the three groups. # Randomly generate the number of successes for each group (must be between 0 and the group size). abc <- sapply(ABC, function(x) if (x > 0) sample(0:x, 1) else 0) x <- abc # Vector containing the number of successes for each group. n <- ABC # Vector containing the total number of trials for each group. # Create a contingency table for the overall Chi-squared test. contig_all <- rbind(s = x, f = n - x) # Rows: successes (s), failures (f); Columns: groups. chisq_pg <- chisq.test(contig_all, correct = FALSE)$p.value # Perform Chi-squared test (no correction) and get the p-value. # Perform pairwise proportion tests with Bonferroni correction. pairwise_prop_p_values <- as.vector( pairwise.prop.test(x, n, correct = FALSE, p.adj = "bon")$p.value ) # Perform pairwise proportion tests (no correction) and get Bonferroni-adjusted p-values. min_pairwise_p_bonf <- min(pairwise_prop_p_values, na.rm = TRUE) # Get the minimum of the adjusted pairwise p-values. # Return a list containing the overall p-value, the minimum Bonferroni-corrected pairwise p-value, successes, and total trials. list(chisq_pg = chisq_pg, min_pairwise_p_bonf = min_pairwise_p_bonf, x = x, n = n) } else { return(NULL) # Return NULL if the group sizes are invalid. } } http://rio2016.5ch.net/test/read.cgi/math/1723152147/811
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 90 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.007s