Skip to content

Conversation

Funbucket
Copy link
Contributor

@Funbucket Funbucket commented Sep 20, 2025

구현 내용

  • Propensity Score Estimation
  • Matching – ATT
  • Balance Check - ATT
  • Matching – ATC
  • Balance Check - ATC
  • ATE

참고 자료

"2 0.648586 -1.310927 0.224077 -0.426757 \n",
"3 0.648586 -1.310927 0.224077 -0.426757 \n",
"4 0.648586 -1.310927 0.224077 -0.426757 "
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

각 변수에 대한 간략한 설명은 없어도 될까요?

저도 같은 데이터셋을 사용해서 해창님 부분에 각 컬럼에 대한 설명이 있으면 이 데이터셋을 처음 보는 사람들이 결과를 해석하기 더 편할 듯 합니다!

"metadata": {},
"source": [
"- **replace=True**: 후보군 부족으로 복원 매칭 허용\n",
" - 매칭 실패 시 caliper 완화, 복원 매칭, k:1 매칭 확대로 대응"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

복원 매칭 허용된다는 뜻은 Propensity Score의 수렴 여부와는 상관이 없는 개념이 맞을까요?
만약 매칭 단계에서의 복원추출 허용이라고 한다면 하나의 변수가 과도하게 많은 매칭에 사용되는 등의 문제가 있을 듯 한데, 이런 문제가 발생했는지 여부를 어떤 방식으로 확인할 수 있는지 궁금합니다!

Copy link
Contributor Author

@Funbucket Funbucket Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. replace와 PS 수렴
    맞습니다! caliper, replace, ratio는 PS를 이미 추정한 뒤 매칭 단계에서 사용하는 파라미터이고, PS 모형의 수렴 여부와는 무관합니다.

  2. 복원 매칭 시 과도한 재사용 진단
    말씀해주신 대로 항상 bias–variance trade-off를 고려해야 할 것 같습니다. 아래 두가지 방법이 가능할 것 같습니다!

    • 단순 확인: 대조군별 매칭 횟수 체크
    • 정량 확인: ESS/원표본 비율 평가 → 비율이 줄면 소수 유닛 과도하게 의존하는 것으로 해석
  3. 추가 답변
    가장 신뢰할 수 있는 평가는 신뢰구간인 것 같은데요, R의 Matching 패키지에는 Abadie–Imbens 표준오차 추정이 구현돼 있지만, Python에서는 부트스트랩이 유효하지 않아 관련 구현이 부족한 상황이라 향후 과제로 보입니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생많으셨습니다! 다음 주 작업도 파이팅입니다 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 감사합니다!

"school_urbanicity_2 0.19 (0.39) 0.20 (0.40) 0.0350 0.19 (0.39) \n",
"school_urbanicity_3 0.15 (0.36) 0.13 (0.34) -0.0472 0.15 (0.36) \n",
"school_urbanicity_4 0.34 (0.48) 0.36 (0.48) 0.0267 0.34 (0.47) \n",
"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매칭 이후에 n값이 변하는 것과 관련해 질문이 있습니다!
해당 데이터에는 매칭 이후에 n값이 변함이 거의 없지만, 만약 매칭 이후에 기존 n값에 비해 크게 감소하는 경우도 있을 듯 합니다.
만약 매칭 이전엔 n값이 총 10000개였다가 매칭 이후에 3000개정도로 줄어든다면 3000개 자체는 n값으로 충분하겠지만, 매칭 이전보다 70%가 줄어들었기 때문에 원래 데이터가 가지고 있던 정보를 많이 잃어버리게 되는 문제가 생길 것 같습니다.
혹시 이에 대해 매칭 이후에 n값이 최소한 어느 정도는 되어야 한다 라는 기준(?)이 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 질문 감사합니다!

매칭 이후 표본 수가 “몇 개 이상이어야 한다”는 보편적인 기준은 없는 거로 알고 있습니다.

n이 많다고 무조건 좋은 게 아니라, 비슷하지 않은 샘플까지 억지로 매칭하면 오히려 bias가 커질 수 있기 때문입니다. 그래서 표본 수 자체보다는 유효표본크기(ESS, Effective Sample Size) 를 보는 게 더 중요합니다.

보통 ESS가 원래 표본의 절반 이하(≈50% 미만)로 떨어지면 샘플 손실이 크다고 보고, 매칭 설계를 다시 점검하곤 합니다. caliper, ratio, replacement 등을 조정해 ESS를 높일 수 있지만, 이 역시 매칭의 구조적 한계에서 오는 trade-off가 있기 때문에 표본 손실이 없는 IPW(가중치 기반 추정) 같은 방법을 대안으로 고려해야 할 것 같습니다!

"source": [
"p_t = float(df[\"intervention\"].mean())\n",
"ATE = ATT * p_t + ATC * (1 - p_t)\n",
"print(\"ATE:\", round(ATE, 4))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 구현 깔끔하게 정리해주셔서 감사드립니다!

코드 구현 후에 결과에 대한 짤막한 해석이 있으면 더욱 좋을 듯 합니다!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 꼼꼼하게 해주셔서 감사합니다! 해석 부분 좀 더 신경 쓰도록 하겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번 한 주도 고생 많으셨습니다!

덕분에 매칭 관련 공부 잘 하고 있어요 👍

@Funbucket Funbucket changed the title Update psm feat: add PSM example — ATT/ATC/ATE Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

awesome-causal-inference-python/main/ate/propensity_score_and_dml

2 participants