發表文章

目前顯示的是 4月, 2024的文章

Bayes factors

BF10 <- function(estimate, lower, upper, null = 0, priormean = null, priorsd = 2) {se <- (log(upper) - log(lower)) / 3.92;bf <- dnorm(x = log(estimate), mean = ifelse(is.null(priormean), null, priormean), sd = sqrt(se^2 + priorsd^2))/dnorm(x = log(estimate), mean = null, sd = se);return(bf)} # Savage-Dickey density ratio BF10 <- function(estimate, lower, upper, n1, n2){se <- (log(upper) - log(lower)) / 3.92;library(BayesFactor);BF <- exp(ttest.tstat(t = log(estimate)/se, n1 = n1, n2=n2, nullInterval = c(-Inf, 0), rscale = "medium")$bf);return(BF)} # marginal likelihood # Savage-Dickey density ratio is better if informative priors, small sample size, post dist is available, marginal likelihood is difficult to compute in complex models. Assumptions: continuous parameters, point null, conjugate priors, proper priors, nested models, 

Bayesian reanalysis of Apolipoprotein A1 Infusions

Apolipoprotein A1 Infusions and Cardiovascular Outcomes after Acute Myocardial Infarction 24 https://www.nejm.org/doi/full/10.1056/NEJMoa2400969 P(θ | D) = (P(D | θ) * P(θ)) / P(D) marginal likelihood P(D) = ∫ P(D | θ) * P(θ) dθ Likelihood: P(D | θ) ~ N(μ_l, σ_l^2) Likelihood ratio: (P(D | θ1))/(P(D | θ2)*) Bayes factor: (P(D | θ1)* P(θ1))/(P(D | θ2)* P(θ2)) Prior: P(θ) ~ N(μ_p, σ_p^2) P(θ | D) ∝ P(D | θ) * P(θ) When we normalize the product of the two PDFs by dividing by the marginal likelihood p(D), the constant term cancels out, and we are left with a normal distribution with mean μ_new and variance σ_new^2. Prior mean 0, sd 0.5 log(HR) = log(0.93) = -0.0726 SE = (log(1.05) - log(0.81)) / (2 * 1.96) = 0.0644 Prior precision = 1 / (0.35^2) = 8.16 Likelihood precision = 1 / (0.0644^2) = 241.18 Posterior precision = 8.16 + 241.18 = 249.34 Posterior mean = (8.16 * 0 + 241.18 * -0.0726) / 249.34 = -0.0701 Posterior SD = sqrt(1 / 249.34) = 0.0634 Posterior 95% credible interval for the lo...