Logistic regression and Causal Effect Estimation.

Hiro_macchan
2015/2/21

Motivation

予測のためのロジスティック回帰

ロジスティックのもう一つの側面:因果推論

Today I'll talk about

  • Categorical Outcome and Logistic regression
  • Causal Effect estimation and Confounders
  • Collapsibility and Estimand

こんなテーマでお話しします。

Who am I?

  • Matsui Hiroki (RPT, MPH)
  • Major in
    Rehabilitation Medicine, Clinical Epidemiology and Health Economics.
  • Working at
    The University of Tokyo.
  • Interested in
    Outcome Research for Health services

Agenda

  • Categorical Outcome
  • Logistic regression
  • Causal Effect estimation
  • Confounders
  • Collapsibility
  • Estimand

Categorical Outcome

  • Dichotomous (or multiple choice) variable Outcome
  • Familiar with
    • Death (1 = death)
    • Readmission (1 = readmission)
    • mRS (ADL Score, 1~5 category)
  • In Other fields
    • Registration (1 = registration)
    • Withdrawal (1 = Withdrawal)

Agenda

  • Categorical Outcome
  • Logistic regression
  • Causal Effect estimation
  • Confounders
  • Collapsibility
  • Estimand

Using OLS for Categorical Outcome

multivariate regression (Ordinary Least Square) \[ Y = \beta_0 + \beta_1x_1 + \eta \] \[ Y = \{y|0,1\} \]

summary(lm(y~x_1))

Call:
lm(formula = y ~ x_1)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.71711 -0.18350  0.00627  0.18907  0.67767 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 0.494726   0.008252   59.95   <2e-16 ***
x_1         0.073624   0.001424   51.72   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.2609 on 998 degrees of freedom
Multiple R-squared:  0.7282,    Adjusted R-squared:  0.728 
F-statistic:  2674 on 1 and 998 DF,  p-value: < 2.2e-16

Using multivariate regression model for Categorical Outcome

plot of chunk unnamed-chunk-3

  • Y should take two values; \( \{0,1\} \),however, there are other values.

plot of chunk unnamed-chunk-4

  • Residual does not distribute Uniformly.

logistic regression

  • Logistic regression NOT Estimate Y BUT Risk (proportion)

plot of chunk unnamed-chunk-5

logistic regression

  • Logistic regression NOT Estimate Y BUT Risk (proportion)
    • \( P=f(z)=\frac{1}{1+e^{-z}} \)
    • \( f(z) \) ; Logistic Function
  • Logistic function is very similar with the Risk for X. plot of chunk unnamed-chunk-6

logistic regression

Logistic Function & Logistic regression

  • \( P=f(z)=\frac{1}{1+e^{-z}} \) has a parameter \( z \)
  • たとえば年齢が高いとリスクが高いという状況は、「\( z \)はAGEが高いほど大きくなる」とあらわせる。
    \( z = \beta_0+\beta_1x_1 + \beta_2x_2 + \cdots+\beta_kx_k \)
    \( f(z) = \frac{1}{1+e^{-z}} \)
    \( f(z) = \frac{1}{1+e^{-(\beta_0+\beta_1x_1 + \beta_2x_2 + \cdots+\beta_kx_k)}} \)
  • あらわされる関数(\( f(z) \))が実際のデータから算出されるPをうまくあらわすように\( \beta_0 \cdots \beta_k \) を設定してあげる。
  • 設定の仕方(最尤推定)はソフトウェアに任せる。
  • 一般線形モデルを一般化した線形モデルなので一般化線形モデルなどと呼ばれる

Using logistic regression

Prediction of Outcome

  • 従属変数を所与として、それぞれの症例のアウトカムが生じる確率を知りたい。
  • 見たいパラメータ: \( P \)

e.g.

  • リウマチ症例において、症状が寛解するかどうかを各種予後因子から予測したい。
  • 消費者の特性からサービス脱退を予測したい。
res <- glm(y~x1+x2+x3, family = binomial(logit))
summary(res)
predict(res,newdata = new.df)

Using logistic regression

Logistic regression is NOT ONLY a method for predicting outcome.

Agenda

  • Categorical Outcome
  • Logistic regression
  • Causal Effect estimation
  • Confounders
  • Collapsibility
  • Estimand

Using logistic regression

Estimate Causal Effect

  • 独立変数対する従属変数の影響度合を知りたい。
  • 見たいパラメータ: \( \beta \)

例えば

  • リウマチ症例において、特定の因子(治療や患者背景)が症状の寛解と関連しているか調べたい。
  • 特定消費者へのキャンペーンが購買行動に与える影響を調べたい。

Odds Ratio

割合の比較

x col1 col2
row1 a b
row2 c d
  • リスク
    \( Risk = \frac{a}{a+b} \)
  • オッズ
    \( Odds = \frac{a/a+b}{b/a+b} = \frac{a}{b} \)
  • リスク差 \[ \hat{RD} = \frac{a}{a+b} - \frac{c}{c+d} \]
  • リスク比 \[ \hat{RR} = \frac{a}{a+b} / \frac{c}{c+d} \]
  • オッズ比 \[ \hat{OR} = \frac{a}{b} / \frac{c}{d} \]

Odds Ratio

Logistic regression とOdds Ratio

  • \( P=f(z)=\frac{1}{1+e^{-z}} \)をzについて解く \( z = log(\frac{p}{1-p}) \)
  • \( \frac{p}{1-p} \) はOddsをあらわす。

Odds Ratio

  • 例えば、男性のz を\( z_m \) 女性のz を\( z_f \)とすると、\( z = \beta_0+\beta_1Sex + \beta_2Age \) の\( \beta_1 \)が示すものは\( log(OR) \)となる。

\( \beta_1 = \frac{z_m-z_f}{1-0} \)
\( =log(\frac{p_m}{1-p_m})-log(\frac{p_f}{1-p_f}) \)
\( = log(\frac{p_m}{1-p_m}/\frac{p_f}{1-p_f}) \)
\( OR = \frac{p_m}{1-p_m}/\frac{p_f}{1-p_f}= e^{\beta_1} \)

年齢(連続変数)の場合年齢が1単位増加した場合のオッズ比を算出できる。
\( \beta \)の信頼区間の出し方などはソフトウェアに任せましょう。

Adjusted Odds Ratio

\[ z = logit(p) =log(\frac{p}{1-p}) = \beta_0+\beta_1Sex + \beta_2Age + \beta_3Treat \]

\( exp(beta_3) \);
性別と年齢を補正したうえでの Treatment odds ratio

Deference between Prediction model and Causal effect estimation

Prediction of Outcome

  • 従属変数を所与として、結果が生じる確率を知りたい。
  • 見たいパラメータ: \( P \)
  • 必要な予測因子を共変量に含んで居るか。
  • クロスバリデーションやBootstrap AICなどで変数選択・モデル妥当性の確認が可能

Causal Effect Estimation

  • 独立変数対する従属変数の影響度合を知りたい。
  • 見たいパラメータ: \( \beta \)
  • 交絡因子(Confounders)を全て共変量に含んで居るか。
  • 周辺知識を統合してBack Door Criteriaを満たすモデルを作成する必要がある。

Deeper in Causal effect estimation

Confounders??

Back Door Criteria??

Agenda

  • Categorical Outcome
  • Logistic regression
  • Causal Effect estimation
  • Bias and Confounders
  • Collapsibility
  • Estimand

Causal Effect estimation

  • Causal Effect Counterfactual

Causal Effect estimation

  • Donald B. Rubin
    missing value

  • Judia Pearl
    Causal Diagram

    Directed Acyclic Graphs (DAG)

Bias and Confounders -Thinking with directed acyclic graphs

#install.packages("dagR")
library(dagR)

dag.dat <-
    dag.init(outcome = NULL, exposure = NULL, covs = c(1),
            arcs = c(0,-1,1,0, 1,-1),
             assocs = c(0,0), xgap = 0.04, ygap = 0.05, len = 0.1,
             x.name = "Hospital admission",
             cov.names = c("Confounder; Patient Age"),
             y.name = "Death"
             )

junk <- dag.draw(dag.dat)

Bias and Confounders -Thinking with directed acyclic graphs

plot of chunk unnamed-chunk-10 X -> C -> Y ; Back Door, Open Path

plot of chunk unnamed-chunk-11 Stratify with C, Multivariable regression include C
Close Back Door

Bias and Confounders -Thinking with directed acyclic graphs

Quiz

plot of chunk unnamed-chunk-14 1:None
2:C1
3:C2
4:C1,C2

plot of chunk unnamed-chunk-15 1:C1
2:C2
3:C3
4:None

Quiz

Quiz

plot of chunk unnamed-chunk-18

1:None, 2:C1, 3:C2, 4:C1,C2

Quiz

Deference between Prediction model and Causal effect estimation

Prediction of Outcome

  • 従属変数を所与として、結果が生じる確率を知りたい。
  • 見たいパラメータ: \( P \)
  • 必要な予測因子を共変量に含んで居るか。
  • クロスバリデーションやBootstrap AICなどで変数選択・モデル妥当性の確認が可能
  • 予測力の多寡で機械的な共変量選択が可能。

Causal Effect Estimation

  • 独立変数対する従属変数の影響度合を知りたい。
  • 見たいパラメータ: \( \beta \)
  • 交絡因子を全て共変量に含んで居るか。
  • 周辺知識を統合してBack Door Criteriaを満たすモデルを作成する必要がある。
  • 機械的な共変量選択があまり意味をなさない。

Private Opinion

因果関係推察する分析するときに、予測力の多寡でモデルの良し悪し語るな。

Additional themes

  • memo
    ここから先の内容は時間があったら話す。

Agenda

  • Categorical Outcome
  • Logistic regression
  • Causal Effect estimation
  • Bias and Confounders
  • Collapsibility
  • Estimand

Quiz

plot of chunk unnamed-chunk-20

1:C1, 2:C2, 3:C1,C2, 4:None

Test

plot of chunk unnamed-chunk-21

Collapsibility

Odds Ratio に着目する場合、Predictor を補正しないとOdds Ratio が0方向にバイアスされる。

Non-collapsibility と呼ばれる性質

Agenda

  • Categorical Outcome
  • Logistic regression
  • Causal Effect estimation
  • Bias and Confounders
  • Collapsibility
  • Estimand

Estimand

=Estimate + Demand

推定したいもの?

Non-collapsibility を回避するなら、Estimand をOdds Ratio から切り替える。

Average Partial Effect(APE)

APE とはロジスティックモデルの結果を利用した仮想的なRisk Differnce にあたる。
2値変数x のAPEを求める場合、すべての症例がx=1 であった場合の推計イベント割合から、すべての症例がx=0 であった場合の推計イベント割合を引いて算出される。
具体的には以下の式による[2]。

\( g(z) = \frac{1}{1+exp(-z)} \)

\( APE = \hat{\beta_K}(N^{-1}\sum_{i=1}^{N}{g(x_i\hat{\beta})}) \cdots x_K がcontinuous \)

\( APE = N^{-1}\sum_{i=1}^{N}{[g(\hat{\beta_1}+\hat{\beta_2}x_{i2}+\cdots+\hat{\beta_{K-1}}x_{i,K-1}+\hat{\beta_{K}})-g(\hat{\beta_1}+\hat{\beta_2}x_{i2}+\cdots+\hat{\beta_{K-1}}x_{i,K-1})]} \cdots x_K がbinary \)

Average Partial Effect(APE)

plot of chunk unnamed-chunk-22

Private Opinion

因果関係推察する分析するときに、予測力の多寡でモデルの良し悪し語るな。

因果の大きさを見るときには、Estimand に気を付けろ。

Reference