高校数学の質問スレ(医者・東大卒専用) Part438 (899レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
837: 132人目の素数さん [sage] 2025/05/16(金) 16:37:03.25 ID:s89ybxV8 イベント発生が人数比で 臨床試験1で 旧薬 vs プラセボで 5/201 vs 19/202 臨床試験2で 新薬 vs 旧薬 で 9/203 vs 5/204 であったとき (1) 新薬がプラセボより劣る確率を計算せよ。 (2) 新薬はプラセボより有意差をもって有効といえるか? 計算に必要な条件は適宜設定してよい。 例:イベント発生は独立事象である library(rjags) library(coda) worth_than_placebo <- function(r0, n0, r1, n1, r2, n2, r3, n3){ model_string <- ' model { # 試験 (旧薬 vs 偽薬) r1 ~ dbin(p1, n1) p1 ~ dbeta(1, 1) r0 ~ dbin(p0, n0) p0 ~ dbeta(1, 1) # 試験 (新薬 vs 旧薬) r2 ~ dbin(p2, n2) p2 ~ dbeta(1, 1) r3 ~ dbin(p3, n3) p3 ~ dbeta(1, 1) # parameters p2_est <- p2 p0_est <- p0 p2_worse_than_p0 <- step(p2_est - p0_est) } ' data <- list(r1=r1 , n1=n1 , r0=r0 ,n0=n0, r2=r2 , n2=n2 , r3=r3 , n3=n3) jags_model <- jags.model(file=textConnection(model_string), data=data, n.chains=3, n.adapt=3000, quiet = TRUE) update(jags_model, n.iter=2000) jags_samples <- coda.samples(jags_model, variable.names=c("p2_est", "p0_est", "p2_worse_than_p0"), n.iter=10000, thin=1) summary(jags_samples) js <- as.data.frame(as.matrix(jags_samples)) names(js) source("plotpost.R") layout(matrix(c(1,2,3,3), 2, 2, byrow=TRUE)) plotpost(js$p2_est, col='lightcoral',xlab="新薬",cex.lab=1.5,main="") plotpost(js$p0_est, col='lightgray', xlab="プラセボ",cex.lab=1.5,main="") plotpost(js$p0_est - js$p2_est, compVal = 0, col=c('lightcoral', 'lightgray'), xlab="プラセボ - 新薬", main="",cex.lab=1.5) HDInterval::hdi(js$p0_est - js$p2_est) |> print() mean(js$p2_worse_than_p0) } result <- worth_than_placebo(r0=19, n0=202, r1=5, n1=201, r2=9, n2=203, r3=5, n3=204) print(paste("新薬がプラセボより劣る確率:", result)) http://rio2016.5ch.net/test/read.cgi/math/1723152147/837
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.026s