發表文章

Why probability probably doesn’t exist (but it is useful to act like it does) 24

https://rdcu.be/d41qA David Spiegelhalter Life is uncertain. None of us know what is going to happen. We know little of what has happened in the past, or is happening now outside our immediate experience. Uncertainty has been called ‘the consciousness of ignorance’ – be it of the weather tomorrow, the next Premier League champions, the climate in 2100 or the identity of our ancient ancestors. In daily life, we generally say an event “could”, “might” or “is likely to” happen (or have happened). But uncertain words can be treacherous. When, in 1961, the newly elected US president John F. Kennedy was informed about a CIA-sponsored plan to invade communist Cuba, he commissioned an appraisal from his military top brass. They concluded that the mission had a 30% chance of success – that is, a 70% chance of failure. In the report that reached the president, this was rendered as “a fair chance”. The Bay of Pigs invasion went ahead, and was a fiasco. There are now established scales for convert...

觀察性研究的因果分析

解釋性線性回歸:y= b0 + b1x1 +…+ bixi + e, xi 是 x1 之外的干擾變項(影響暴露 x1 和結局 y 的因子), e 誤差(殘差), 只要看 b1 的 p 值是否 < 0.05 和 95% 信賴區間是否不包含 0(不要看 bi) 線性回歸的假設 https://www.facebook.com/share/1E3KxEtXfZ/?mibextid=wwXIfr 不要用逐步回歸:固定 x1,用 p 值或 AIC, BIC 逐步選擇變項。缺點是忽略領域專業知識、變項選擇的隨機性增加不穩定性、多重比較增加第一型錯誤(假陽性)率、忽略非線性、忽略交互作用、忽略共線性、p 值被低估、95% 信賴區間被低估、過度擬合 overfitting(模型在訓練數據上表現良好,卻在新數據上表現不佳) 機器學習: • 用交叉驗證(把數據分成 n 份,由 n-1 份訓練模型 mi,在剩下的一份驗證 mi,如此重複進行)選擇最佳的 m,用拔靴法(由數據做有放回的重複抽樣,在每次的抽樣中估計平均值)估計該 m 的 95% 信賴區間 • 能改善非線性(隨機森林)、交互作用(隨機森林)、共線性(ridge 回歸、隨機森林)、干擾因子選擇(LASSO) • 假設跟 y 的關係:b1 是線性、bi 可能是線性或是非線性 雙重機器學習:減少單純機器學習的偏誤 https://poe.com/preview/in8Sair3cp3FQubrqZPt • 治療模型:D=m0(Z)+V, E(V|Z)=0 • 結局模型:y=Dθ0+g0(Z)+U, E(U|Z, D)=0 • D: 治療,θ0:平均治療效果,Z: 干擾因子,E: 期望值(平均值), hat: 估計值 • 把數據分成二份 • 樣本 0 用機器學習訓練 m0hat⁰(Z)來估計 D 的條件期望值 mo(Z),並用機器學習訓練 g0hat⁰(Z) 來估計 Y 的條件期望值 g0(Z) • 在樣本 1 計算殘差 Vhat⁰= D-m0hat⁰(Z)= 與控制變數 Z 無關的 D 變異部分 • 在樣本 1 計算殘差 Uhat⁰=y-g0hat⁰(Z)= 與控制變數 Z 無關的 Y 變異部分 • 線性回歸得到 θ0hat⁰:Uhat⁰=θ0hat⁰.Vhat⁰ +e, E(e|Vhat⁰)=0 • 在樣本 1 用機器學習訓...

不同 p值時,虛無假設與對立假設下的密度分布

https://poe.com/preview/9or7DmjGwEEGW6nZWcA1 import React, { useState } from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts'; const PValueDistribution = () => {     const [power, setPower] = useState(0.8);     const [alpha, setAlpha] = useState(0.05);          const data = [];     const lambda = -Math.log(1 - power) / alpha;          for (let x = 0; x <= 1; x += 0.01) {         data.push({             pValue: x,             null: 1,             alt: Math.exp(-x * lambda) * lambda / (1 - Math.exp(-lambda))         });     }     return (         <div className="p-4 max-w-4xl mx-auto">             <div className="text-center mb-6">     ...

lnRR vs. SMD 在統合分析中的選擇

在統合分析(meta-analysis)中,選擇適當的效應量指標至關重要。本篇比較 對數反應比(log response ratio, lnRR) 與 標準化均數差(standardized mean difference, SMD),並根據統計特性與適用情境探討其優缺點。 一、統計特性比較 1. 尺度無關性與解釋直觀性 lnRR(對數反應比) • 基於比例尺度(ratio scale),直接反映兩組均值的相對變化(如實驗組均值為對照組的1.2倍)。 • 自然對數轉換 使效應量對稱化,避免原始比例的偏態問題。解讀時可轉換為百分比變化(如:e^0.182 ≈ 20%增加),適合生物醫學與生態學研究中的自然測量(如體重、存活率、細胞計數)。 • 適用於數據無負值、具自然零點的變數。 SMD(標準化均數差) • 依賴標準差標準化,易受標準化方法不一致影響,例如使用變化分數標準差(change score SD)而非基線標準差(baseline SD),可能導致效應量高估或異質性增加。 • 跨研究的標準差變異可能引入人工異質性,影響分析的穩健性。 • 適用於無比例概念的數據,如心理測驗分數、問卷量表等。 2. 偏誤與異質性控制 SMD 的潛在問題 • 標準化標準差的選擇影響效應量: • 使用變化分數 SD:可能高估效應,例如某研究 SMD = 1.03。 • 改用基線 SD:修正後 SMD = 0.37,顯示標準化方式對結果影響顯著。 • 不同研究間的標準差變異會導致人工異質性,增加統合分析的不確定性。 lnRR 的穩健性 • 無需標準化,避免因標準差選擇不當引入的偏誤。 • 對乘性變化具有線性特性,可應用於不同單位的測量(如公分 vs. 英吋)。 • 對技術誤差較為穩健,特別適用於測量誤差可能影響標準差的研究場景。 二、適用情境與限制 1. lnRR 適用情境 ✅ 適合比例尺度數據:當變數具自然零點且關心相對變化時,如: • 體重變化 • 代謝速率 • 細胞增殖率 • 存活時間 ✅ 適用於跨研究單位不一致的情況,如不同研究測量單位不同但需合併分析(如公克與毫克)。 ✅ 適合避免標準化偏誤,特別是在基線標準差難以準確估計或存在重複測量(如交...

臨床試驗貝氏分析的結果

以下為使用 OR 為 0.9、95% 信賴區間 (95% Confidence Interval) 為 (0.78, 1.04) 時,依據程式碼計算出的各項結果(數值皆為近似值): 1. 似然分布參數 (Likelihood Parameters) • 點估計值 (Point Estimate):0.9 • 對數轉換 (Log Transformation) • ln(OR) = ln(0.9) ≈ –0.1054 • 標準誤 (Standard Error, SE): 根據上限信賴區間計算: • ln(上限) = ln(1.04) ≈ 0.0392 • SE = (ln(1.04) – ln(0.9)) / 1.96 ≈ (0.0392 – (–0.1054)) / 1.96 ≈ 0.0739 因此,似然分布參數為: • mean ≈ –0.1054 • sd ≈ 0.0739 2. 先驗分布參數 (Prior Parameters) 程式碼中預設先驗參數為: • Prior Mean:1.0(轉換至對數尺度 ln(1.0) = 0) • Prior Standard Deviation (Prior SD):0.42 • targetValue:0.9(用於計算後驗機率) • Credible Interval:0.95 3. 後驗分布參數 (Posterior Parameters) 依據 Bayesian 計算,結合先驗與似然資訊,計算步驟如下: • 先驗精度 (Prior Precision) = 1 / (0.42²) ≈ 5.67 • 似然精度 (Likelihood Precision) = 1 / (0.0739²) ≈ 183.2 • 後驗精度 (Posterior Precision) = 5.67 + 183.2 ≈ 188.87 • 後驗均值 (Posterior Mean, on log scale): = [ (ln(Prior Mean) × Prior Precision) + (ln(OR) × Likelihood Precision) ] / Posterior Precision = [ (0 × ...

Webapp: 臨床試驗的貝氏分析

import React, { useState, useCallback, useMemo } from 'react'; import { Tab } from '@headlessui/react'; import { LineChart, Line, XAxis, YAxis, Tooltip, Legend, ResponsiveContainer } from 'recharts'; import { HelpCircle } from 'lucide-react'; const BayesianAnalysis = () => {       // Core state       const [studyType, setStudyType] = useState('hazardRatio');       const [pointEstimate, setPointEstimate] = useState(0.76);       const [confidenceInterval, setConfidenceInterval] = useState({ lower: 0.55, upper: 1.02 });       const [events, setEvents] = useState({           treatment: { events: 34, total: 100 },           control: { events: 43, total: 100 }       });            // Added user-defined MCID and value of interest       const [mcid, setMcid] = useState(0.8);       const [valueOf...