← All posts

Internal Validation with Bootstrap, kNN Imputation, and Fractional Polynomial Models [Thai]

Clinical Epidemiology ResearchUniqcret doctor knowledgesMethodology and Research DesignDiagnosis [Methodology]Prognosis [Methodology]
On this page

(กรณี kNN imputation หลายชุด + Fractional Polynomial + Bootstrap)

บทนำ: เรากำลังพยายามตอบคำถามอะไร?

ในการพัฒนา prediction model คำถามสำคัญไม่ใช่แค่ว่า

“โมเดล fit กับข้อมูลเราได้ดีแค่ไหน?”

แต่คือ

“โมเดลนี้ overfit แค่ไหนและถ้าเอาไปใช้กับคนใหม่ประสิทธิภาพจะลดลงเท่าไร?”

การตอบคำถามนี้เรียกว่า Internal Validation


บริบทของงานนี้ (Your exact problem)

งานนี้มีความซับซ้อน 3 ชั้นพร้อมกัน:

  1. Missing data จำนวนมาก→ ใช้ Boostrap before kNN single imputation ซ้ำหลายครั้ง→ ได้ imputed datasets = 500ชุด (imp_id 1–500)
  2. Continuous predictors มี non-linearity → ใช้ Multivariable Fractional Polynomial (MFP)→ เลือก FP powers ตอน development
  3. ต้องประเมิน performance ของโมเดลสุดท้าย → AUC→ Calibration slope→ Calibration-in-the-large (CITL)

แนวคิดหลักที่ต้องเข้าใจก่อน (หัวใจของ internal validation)

🔑 Internal validation ไม่ใช่การดูว่า “model เปลี่ยนหรือไม่”

แต่คือการดูว่า

โมเดลสุดท้ายที่เราจะ deploy มี optimism (ความลำเอียงจาก overfitting) เท่าไร

ดังนั้น:

ต้อง validate “model เดียวกัน” เสมอ


“Model เดียวกัน” แปลว่าอะไร?

คำว่า model เดียวกัน หมายถึง

📌 ไม่ได้หมายความว่า


แยก 2 ขั้นตอนให้ชัด (Development vs Validation)

1️⃣ Model Development (อนุญาตให้ใช้ MFP)

คำถามที่ตอบ:

“ควรใช้ตัวแปรอะไรและความสัมพันธ์ควรโค้งแบบไหน?”

สิ่งที่ทำ:

ผลลัพธ์:👉 Final model specificationเช่น

หลังจากนี้👉 ห้ามเปลี่ยน powers อีก

2️⃣ Internal Validation (ห้ามเลือก model ใหม่)

คำถามที่ตอบ:

“โมเดลนี้ overfit แค่ไหน?”

สิ่งที่ ห้ามทำ:

สิ่งที่ ทำได้:


ทำไม “bootstrap ต้องไม่ rerun MFP”

อาจารย์มักพูดว่า:

“bootstrap แต่ละครั้งข้อมูลไม่เหมือนกันถ้าไม่ rerun MFP model จะไม่เปลี่ยน”

คำตอบที่ถูกต้องคือ:

เพราะ internal validation ต้องการเปรียบเทียบ

performance ของ model เดียวกันระหว่างข้อมูลที่เห็น vs ข้อมูลใหม่

ถ้า rerun MFP:

แล้วเอาไป test

❗ เท่ากับ train model A แต่ test model B→ calibration, slope, optimism ตีความไม่ได้


แล้ว imputation หลาย dataset ล่ะ?

คำถาม:

“แต่ละ imputed dataset ไม่เหมือนกันทำไมไม่ rerun MFP?”

คำตอบ:

แม้ข้อมูลจะต่าง👉 เรายังต้อง validate model เดียวกัน

ไม่งั้น:


Bootstrap before kNN imputation ไม่เพียงพอ

ทำไมต้อง Bootstrap หลังจากได้ 500 data set มาแล้ว If your final model specification is derived from all 500 imputed datasets, then the bootstrap used to generate those datasets does NOT estimate model optimism. ตอนทำ Final model ทำจาก 500 dataset นั้น ถ้าไม่ bootstrap มันอีกมันก็จะไม่ช่วย evaluate model optimism


ประเด็นลึก: Fractional Polynomial กับ re-centering

FP power = ตัวตนของ model

centering constant = parameterization

สมการ:

β [ ( X 10 ) 2 c ] = β ( X 10 ) 2 β c

c ทำอะไร?

📌 ความชันจึงเท่ากันทุกจุด 📌 ความโค้งเลยเท่ากัน β ทำอะไร?

เหมือนคุณเอารูปวาดไปซูมเข้า–ออก

📌 ความชันไม่เท่ากัน แต่รูปร่างเหมือน 📌 ซูม ≠ เปลี่ยนรูป แปลว่า:

📌 re-centering ไม่ได้เปลี่ยน model

ความโค้งมาจากฟังก์ชันที่ขึ้นกับ X vars

ค่าคงที่แค่เลื่อนเส้นขึ้น–ลง

เลยไม่เปลี่ยนความโค้ง


ทำไม “fix centering constant” ถึงผิด

ถ้าคุณเอา constant จาก dataset หนึ่งไปใช้กับอีก dataset:

ดังนั้น:

centering ต้อง recompute ตาม sample

Rule:

ทั้งหมดนี้ = TRIPOD-correct internal validation


ขั้นตอน Internal Validation

Example ระดับ imputation (m = 1…140)

A) Apparent performance (Aₘ)

B) Bootstrap test performance

C) Optimism

Optimismₘ = Aₘ -  T̄ₘ

Correctedₘ = Aₘ - Optimismₘ  T̄ₘ = Correctedₘ

รวมทุก imputation


สรุปประเด็นสำคัญ

ประเด็นคำตอบ
rerun MFP ใน bootstrap❌ ไม่ควร
FP powers ต้อง fix✅ ใช่
re-center FP ใหม่✅ ถูก
copy constant ข้าม dataset❌ ผิด
internal validation ยัง valid✅ แน่นอน

 Re-centering is not a new model

“Internal validation ต้องใช้ functional form เดิมไม่ใช่ numeric parameterization เดิมการ re-centering FP เป็นเพียงการเขียนสมการใหม่ซึ่งไม่เปลี่ยน model และไม่ละเมิด internal validation”


0
Message for International and Thai ReadersUnderstanding My Medical Context in ThailandRead more →Message for International and Thai ReadersUnderstanding My Broader Content Beyond MedicineRead more →

Comments

No comments yet. Be the first to share your thoughts.

Sign in to comment