사용자 정의 결과 함수를 사용해 추정치 반박하기

A Simple Example on Creating a Custom Refutation Using User-Defined Outcome Functions

본 글은 Refute 방법론을 사용하는 코드 레퍼런스를 남기는 목적으로 작성되었습니다. 그렇기에 Refute에 대한 학습이 필요하신 경우 DOWHY KEY CONCEPTS의 추정치를 검증하는 방법 을 참고하시길 바랍니다.

본 실험에서는 선형데이터(linear dataset)를 구축하였고, 선형 회귀를 estimator로 사용합니다.

Refute의 방법으로는 outcome을 대체하는 dummy outcome refuter 방법을 사용하여 진행합니다.

1. Insert Dependencies

from dowhy import CausalModel
import dowhy.datasets
import pandas as pd 
import numpy as np 
# Config dict to set the logging level
import logging.config
DEFAULT_LOGGING = {
    'version': 1,
    'disable_existing_loggers':False,
    'loggers': {
        '': {
            'level': 'WARN',
        },
    }
}

logging.config.dictConfig(DEFAULT_LOGGING)

2. Create the dataset

Hyper parameter의 값을 바꾸며 effect의 변화를 확인할 수 있습니다.

Variable Name
Data Type
Interpretation

Zi

float

도구변수(Instrument Variable)

Wi

float

교란변수(Confounder)

V0

float

처치변수(Treatment)

Y

float

결과변수(Outcome)

Z0
W0
W1
V0
y

0

1.0

0.112689

-0.501474

8.076574

80.106461

1

0.0

0.645347

-0.072829

-0.219279

-0.092377

2

0.0

0.323480

0.989825

0.365947

6.900517

3

0.0

0.030437

1.334423

1.740524

20.319910

4

1.0

1.377841

0.628397

11.938058

125.523936

3. Creating the Causal Model

아래의 그림은 처치변수(treatment), 결과변수(outcome), 교란변수(confounders), 도구변수(instrument variable)의 관계를 살펴볼 수 있습니다.

W0, W1 : 교란변수(confounders)

Z0 : 도구변수(instrument variable)

V0: 처치변수(treatment)

Y: 결과변수(outcome)

변수들의 관계

4. Identify the Estimand

5. Estimating the Effect

6. Refuting the Estimate

1) Using a Randomly Generated Outcome

2) Using a Function that Generates the Outcome from the Confounders

아래와 같이 새로운 Y를 생성하기 위해 교란변수를 사용한 선형식을 정의합니다.

ynew=β0W0+β1W1+γ0y_{new} = \beta_0W_0 + \beta_1W_1 + \gamma_0

where, β0=1,β1=2,γ0=3\beta_0 = 1, \beta_1 = 2, \gamma_0 = 3

Last updated