ML

Causal Forest vs Causal impact

sapziling 2022. 7. 18. 18:48

- causal forest vs causal impact

causal impact는 시계열 예측 모델로, T=1 인 예측값과 T=0인 예측값 차이 구하여 estimation

causal forest는 random forest 사용해서 HTE 구하기


- causal forest doubly

3. 
fold 1 --> train, X: A, y : pi hat(P(T=1))
fold 2 --> predict, fold1 모델 이용해서 fold2 예측 --> 예측 prob

4. 
fold 1 --> train, X: A, y : Y(1,0)
fold 2 --> predict, fold1 모델 이용해서 fold2 예측 --> 예측값 1,0

part4 번에서 T=0, T=1 인지로 yhat estimate구함.

위 방법론과 아래 방법론이 있는데, 위에는   doubly robust estimation described by Hernan 방법론

아래는 generalized rf이고, 그 이외에는 아래 링크에 여러가지 방법론 존재하는 듯.

https://arxiv.org/pdf/1902.07409.pdf

 

causal forest는 , optimization 목표가 prediction error를 줄이는게 아니라, (class impurity 줄이는 것),

covariate과 Y의 CATE 최대화 목표. terminal node에서 untreated vs treated observation 비교하여 최대 difference of outcome 나오도록.

- HTE vs. ATE

HTE : average Treatment Effect랑 다르게 개별 variable 단위의 효과가 아니라, 여러 variable 조합으로 different subgroups에서의 효과를 알 수 있음. 예를 들어 인종, sex 그룹별로 효과를 보고 싶을때. 
물론 linear regression에서 interaction term을 이용할 수 있지만, interaction term이 점점 복잡해진다. 그래서 random forest를 사용한다.

- random forest vs causal forest

1) split critierion(training)

전자 : 불순도 작은 방향으로 split

후자 : treatment effect가 가장 차이가 나는 방향. 예를 들어 age 라고 하면 age = 40, age =20 중 age=20 이 age를 넣었을때의 treatment effect가 가장 차이날때로 쪼갠다.

 

2) 평가방법(test)

전자 : 실제 정답지랑 비교해서 mean accuary 구하는것 가능

후자 : treament 라는게 답지가 없으니까,  splitting subsample 과 estimating subsample로 나눈다

trained tree에다가, sample들을 예를 들어 (i, ii 중 어떤 건지 모르겠음) 

i. ( Y=1일때 age > 20 인 애들이 도달한 terminal node outcome  ) - ( Y=0일때 age > 20 인 애들이 도달한 terminal node outcome  ) 

ii. ( Y=1일때 age > 20 인 애들이 도달한 terminal node outcome  ) - ( Y=1일때 age < 20 인 애들이 도달한 terminal node outcome  

 

논문 원본 출처는 이거인듯  : http://faculty.ist.psu.edu/vhonavar/Courses/causality/GRF.pdf

 

the difference in the average outcomes 

 between the treated and the untreated observations in a terminal node.

the biggest difference in treatment effects across leaves, but still give us an accurate estimate of the treatment effect

 

library : https://lost-stats.github.io/Machine_Learning/causal_forest.html

explanation : https://www.markhw.com/blog/causalforestintro

수식 출처 : http://www.personal.ceu.hu/staff/Robert_Lieli/cate.pdf

next to do : https://www.youtube.com/watch?v=fNjToAQ9v3g 

https://towardsdatascience.com/beyond-a-b-testing-primer-on-causal-inference-d8e462d90a0b << 이거 먼저

https://www.statworx.com/en/content-hub/blog/machine-learning-goes-causal-ii-meet-the-random-forests-causal-brother/ << causal forest 설명 좋은듯. 

Bayesian time series : https://towardsdatascience.com/a-bayesian-approach-to-time-series-forecasting-d97dd4168cb7

Gibbs: https://towardsdatascience.com/gibbs-sampling-8e4844560ae5

causl impact 간단 명료 설명 : https://hweejin.tistory.com/m/entry/Causal-Impact-%EC%A2%80-%EB%8D%94-%EC%A0%95%ED%99%95%ED%95%9C-%ED%9A%A8%EA%B3%BC-%EC%B8%A1%EC%A0%95%EC%9D%84-%EC%9C%84%ED%95%9C-%EB%B0%A9%EB%B2%95%EB%A1%A0

next to do causal impact : https://pypi.org/project/tfcausalimpact/