Using Text Embeddings for Causal Inference

  • 2019-05-29 21:29:37
  • Victor Veitch, Dhanya Sridhar, David M. Blei
  • 21

Abstract

We address causal inference with text documents. For example, does adding atheorem to a paper affect its chance of acceptance? Does reporting the genderof a forum post author affect the popularity of the post? We estimate theseeffects from observational data, where they may be confounded by features ofthe text such as the subject or writing quality. Although the text suffices forcausal adjustment, it is prohibitively high-dimensional. The challenge is tofind a low-dimensional text representation that can be used in causalinference. A key insight is that causal adjustment requires only the aspects oftext that are predictive of both the treatment and outcome. Our proposed methodadapts deep language models to learn low-dimensional embeddings from text thatpredict these values well; these embeddings suffice for causal adjustment. Weestablish theoretical properties of this method. We study it empirically onsemi-simulated and real data on paper acceptance and forum post popularity.Code is available at https://github.com/blei-lab/causal-text-embeddings.

 

Quick Read (beta)

Using Text Embeddings for Causal Inference

Victor Veitch Equal contribution. Department of Statistics, Columbia University Dhanya Sridhar footnotemark: Department of Computer Science, Columbia University David M. Blei
Abstract

We address causal inference with text documents. For example, does adding a theorem to a paper affect its chance of acceptance? Does reporting the gender of a forum post author affect the popularity of the post? We estimate these effects from observational data, where they may be confounded by features of the text such as the subject or writing quality. Although the text suffices for causal adjustment, it is prohibitively high-dimensional. The challenge is to find a low-dimensional text representation that can be used in causal inference. A key insight is that causal adjustment requires only the aspects of text that are predictive of both the treatment and outcome. Our proposed method adapts deep language models to learn low-dimensional embeddings from text that predict these values well; these embeddings suffice for causal adjustment. We establish theoretical properties of this method. We study it empirically on semi-simulated and real data on paper acceptance and forum post popularity. Code is available at github.com/blei-lab/causal-text-embeddings.

\fvset

fontsize= \crefnamelemmalemmalemmas \CrefnamelemmaLemmaLemmas \crefnamethmtheoremtheorems \CrefnamethmTheoremTheorems \crefnameproppropositionpropositions \CrefnamepropPropositionPropositions \crefnameassumptionassumptionassumptions \crefnameassumptionAssumptionAssumptions \newbibmacro*journal \addbibresourcebibs/language,bibs/causality \crefformatequation(#2#1#3) \crefformatfigureFigure #2#1#3 \crefnameexampleExampleExamples \crefnamelemmaLemmaLemmas \crefnamecorCorollaryCorollaries \crefnametheoremTheoremTheorems \crefnameassumptionAssumptionAssumptions

1 Introduction

We develop a method for causal inference from observed text documents. We consider a binary treatment, an outcome of interest, and a document of text. We assume that the text carries sufficient information to identify the causal effect; it is either an observed confounder or an observed mediator.

Example 1.1.

Consider a corpus of scientific papers submitted to a conference. Some have theorems; others do not. We want to infer the causal effect of including a theorem on paper acceptance. The effect is confounded by the subject of the paper—more technical topics demand theorems, but may have different rates of acceptance. The data does not explicitly list the subject, but it does include each paper’s abstract. We want to use the text to adjust for the subject and estimate the causal effect.

Example 1.2.

Consider comments from Reddit.com, an online forum. Each post has a popularity score and the author of the post may (optionally) list their gender. We want to know the direct effect of a ‘male’ label on the score of the post. However, the author’s gender may affect the text of the post, e.g., through tone, style, or topic choices, which also affects its score. Again, we want to use the text to accurately estimate the causal effect.

In these two examples, we assume that the text carries sufficient information to identify the causal effect. In theory, we can use classical methods of causal inference to adjust for the text of the document. But in practice we have finite data and the text is high dimensional, prohibiting efficient and accurate causal inference. The challenge is to reduce the text to a low-dimensional representation that both suffices for causal identification and that allows effective estimation with finite data.

Our strategy is to draw on text embedding methods to reduce the dimension of the text \citep[e.g.,][]Mikolov:Chen:Corrado:Dean:2013,Mikolov:Sutskever:Chen:Corrado:2013,Devlin:Chang:Lee:Toutanova:2018,Peters:Neumann:Iyyer:Gardner:Clark:Lee:Zettlemoyer:2018. Informally, a text embedding method distills the text of each document to a real-valued vector, and these embeddings can be used as features for prediction problems. Black-box embedding methods are state-of-the-art for a range of natural language understanding tasks [Devlin:Chang:Lee:Toutanova:2018, Peters:Neumann:Iyyer:Gardner:Clark:Lee:Zettlemoyer:2018]. Here, we will adapt embedding methods in the service of causal inference.

The key insight is that to adjust for variables in causal inference, it suffices to use only the information relevant to the prediction of the treatment and outcome. Thus we harness modern embedding methods—BERT [Devlin:Chang:Lee:Toutanova:2018], in particular—to extract the information from the text required for this prediction problem . The learned embeddings capture information sufficient for causal identification and provide the necessary ingredients for various causal estimators.

Contribution.  The main contribution of this paper is a method for adapting off-the-shelf text embedding methods to estimate treatment effects. We show that the method is theoretically sound, demonstrate its utility on semi-synthetic data, and apply it to real datasets for estimating causal effects of the properties of papers on acceptance and gender label on popularity.

2 Related work.

This paper connects to several areas of related work.

The first area is causal inference for text. \citetroberts2018adjusting also discuss how to estimate effects of treatments applied to text documents. They rely (in part) on topic modeling to reduce the dimension of the text. This strategy is reasonable if the learned topics reflect the confounding aspects of the text. In contrast, we replace the assumption that the topics capture confounding with the assumption that an embedding method can effectively extract predictive information. We compare to a topic-model based approach in creftype 5.

In other work, \citetegami2018make reduce raw text to interpretable outcomes; \citetwood2018challenges estimate treatment effects when confounders are observed, but missing or noisy treatments are inferred from text. In contrast, we are concerned with text as the confounder.

A second area of related work addresses causal inference with unobserved confounding when there is an observed proxy for the confounder [Kuroki:Miyakawa:1999, Pearl:2012, Kuroki:Pearl:2014, Miao:Geng:TchetgenTchetgen:2018, kallus2018causal]. This work usually assumes that the observed proxy variables are noisy realizations of the unobserved confounder, and then derives conditions under which causal identification is possible. One view of our problem is that each unit has a latent attribute (e.g., topic) such that observing it would suffice for causal identification, and the text is a proxy for this attribute. Unlike the proxy variable approach, however, we assume the text fully captures confounding. Our interest is in methods for finite-sample estimation rather than infinite-data identification.

\citet

Louizos:Shalit:Mooij:Sontag:Zemel:Welling:2017 also work with proxy variables, and consider the estimation problem. They fit a variational autoencoder using observed data and assume that it exactly recovers the true data generating distribution (including the latent confounder). We require weaker assumptions than the full recovery of the data generating distribution.

Work on causal inference with hidden confounding and many treatments is in the same vein [Wang:Blei:2018, Ranganath:Perotte:2018, damour:2019]. The idea is to use the treatments to infer the latent confounders. In contrast, we assume that the text suffices to adjust for confounding .

Finally, \citetVeitch:Wang:Blei:2019 also use the reduction of causal estimation to prediction. In their case, to address unobserved confounding in the presence of network data.

3 Background

Figure 1: Models for the ATE (left) and NDE (right).

We begin by fixing notation and recalling some ideas from the estimation of causal effects. Each statistical unit is a document represented as a tuple Oi=(Yi,Ti,𝐖i), where Yi is the outcome, Ti is the treatment, and 𝐖i is the sequence of words. The observed dataset consists of n observations drawn independently and identically at random from some distribution, OiP.

We review estimation of the average treatment effect and the natural direct effect. For both, we assume that the words are sufficient for adjustment.

Average treatment effect.  The average treatment effect (ATE) is defined as

ψ=𝔼[Y|do(T=1)]-𝔼[Y|do(T=0)].

The use of Pearl’s do notation indicates that the effect of interest is causal: what happens if we intervene by adding a theorem to a paper? We assume that the words 𝐖i carry sufficient information to adjust for confounding (common causes) between Ti and Yi. creftypecap 1 on the left depicts this assumption. We define Zi=f(𝐖i) to be the part of 𝐖i which blocks all ‘backdoor paths’ between Yi and Ti. The causal effect is then identifiable from observational data as:

ψ=𝔼[𝔼[Y|Z,T=1]-𝔼[Y|Z,T=0]]. (3.1)

Our task is to estimate the ATE ψ from a finite data sample. Define Q(t,z)=𝔼[Y|t,z] to be the conditional expected outcome and Q^ to be an estimate for Q. Following 3.1, a natural estimator is:

ψ^Q=1ni[Q^(1,zi)-Q^(0,zi)]. (3.2)

That is, ψ is estimated by a two-stage procedure: First produce an estimate for Q^ through a predictive model; then plug Q^ into a pre-determined statistic to compute the estimate of the ATE.

The estimator creftype 3.2 is not the only possible choice. In principle, it is possible to do better by using estimators that also incorporate estimates g^ of the propensity scores g(z)=P(T=1|z) \citep[e.g.,][]Robins:2000,vanderLaan:Rose:2011,Robins:Rotnitzky:Zhao:1994,Chernozhukov:Chetverikov:Demirer:Duflo:Hansen:Newey:Robins:2017. The general approach is a two-stage procedure. First fit a model for propensity scores and conditional outcomes; then plug the fitted model into a downstream estimator. What is important is that these estimators depend on zi only through g^(zi) and Q^(t,zi).

Natural direct effect.  The direct effect is the expected change in outcome if we apply the treatment while holding fixed any mediating variables that are affected by the treatment and that affect the outcome. creftypecap 1 on the right depicts the text as mediator of the treatment and outcome. For the estimation of the direct effect, we take Z=f(𝐖) to be the parts of 𝐖i that mediate T and Y. The natural direct effect of treatment β is average difference in outcome induced by giving each unit the treatment, if the distribution of Z had been as though each unit received treatment. That is,

β=𝔼P(Z|T=1)[𝔼[Y|Z,do(T=1)]-𝔼[Y|Z,do(T=0)]].

In the gender example, this is the expected difference in score between a post labeled as written by a man versus labeled as written by a woman, where the expectation is taken over the distribution of posts written by men.

Under minimal conditions, this quantity may be estimated from observational data [Pearl:2014]. The natural estimator is \citep[][Ch. 8]vanderLaan:Rose:2011

β^plugin=1ni[Q^(1,zi)-Q^(0,zi)]g^(zi)/(1niti).

As with the ATE, there are also more sophisticated estimators \citep[e.g.,][Ch. 8]vanderLaan:Rose:2011. Again, all such estimators rely on Z only through the estimated conditional outcomes and propensity scores.

4 Causal text embeddings

We first focus on estimation of the average treatment effect. Following the previous section, we want to produce estimates of the propensity score g(zi) and the conditional expected outcome Q(ti,zi). We assume that some property zi=f(𝐰i) of the text suffices for identification. The obstacle motivating this paper is that we do not directly observe the confounding features zi. Instead, we must work with the raw text.

A simple approach is to abandon zi altogether and learn models for the propensities and conditional outcomes directly from the words 𝐰i. Since 𝐰i contains all information about zi, the direct adjustment will also render the causal effect identifiable. Indeed, in an infinite-data setting this would be a sound approach. However, the dimensionality of the problem is prohibitive.

We require a reduction of the words 𝐰i to a feature zi that both contains sufficient information to render the causal effect identifiable, and that will allow us to effectively learn the propensity scores and conditional outcomes with a finite data sample. A key insight follows from \citep[][Thm. 3]Rosenbaum:Rubin:1983. Recall Q(t,z)=𝔼[Y|t,z] and g(z)=P(T=1|z).

Theorem 4.1.

Suppose λ(w) is some function of the words such that at least one of the following is λ(W)-measurable:

  1. 1.

    (Q(1,𝐖),Q(1,𝐖)),

  2. 2.

    g(𝐖),

  3. 3.

    g((Q(1,𝐖),Q(1,𝐖))) or (Q(1,g(𝐖)),Q(1,g(𝐖))).

If adjusting for W suffices to render the average treatment effect identifiable then adjusting for only λ(W) also suffices. That is, ψ=E[E[Y|λ(W),T=1]-E[Y|λ(W),T=0]].

In words: the random variable λ(𝐖) carries the information about 𝐖 relevant to the prediction of both the propensity score and the conditional expected outcome. While λ(𝐖) will typically throw away much of the information in the words, creftype 4.1 says that adjusting for it suffices to estimate causal effects. Item 3 says that this holds even if we throw away information relevant to Y, so long as this information is not also relevant to T (and vice versa). The utility of creftype 4.1 is that if we can find features of 𝐰 that suffice for the prediction problem, then adjusting for these features also suffices for the causal estimation problem.

Our strategy is to use the words of each document to produce an embedding vector λ(𝐰) that captures the confounding aspects of the text. These embeddings are satisfactory if we can use them to estimate the propensities and conditional outcomes required by the downstream effect estimator.

We will use embedding-based prediction models from the natural language processing literature. For our purposes, these models may viewed as black-boxes that take in words 𝐰i and produce a tuple (λi,Q~(ti,λi),g~(λi)), which contains an embedding λi and estimates of g and Q that use that embedding. The idea is that such models provide an effective black-box tool for both distilling the words into the information relevant to prediction problems, and for solving those prediction problems.

Finally, to estimate the average treatment effect, we follow the general strategy of creftype 3. First, we fit the embedding-based prediction model to produce estimated embeddings λ^i, propensity scores g~(λ^i) and conditional outcomes Q~(ti,λ^i). We then plug these values into a downstream estimator. We will see an explicit example below.

Validity.  The next result gives conditions for this procedure to be valid.

Theorem 4.2.

Let η(z)=(E[Y|T=0,z],E[Y|T=1,z],P[T=1|z)) be the conditional outcomes and propensities given z. Suppose that ψ^({(ti,yi,zi)};η)=1niϕ(ti,yi,η(zi))+op(1) is some consistent estimator for the average treatment effect ψ. Further suppose that there is some function λ of the words such that

  1. 1.

    (identification) λ satisfies the condition of creftype 4.1.

  2. 2.

    (consistency) η(λ(𝐖i))-η~(λ^i)P,20 as n, where η~ is the estimated conditional outcome and propensity model.

  3. 3.

    (well-behaved estimator) ηϕ(t,y,η)2C for some constant C+,

then, ψ~({(ti,yi,λ^i)};η~)𝑝ψ.

Remark 4.3.

The requirement that the estimator ψ^ behaves asymptotically as a sample mean is not an important restriction; most commonly used estimators have this property [Kennedy:2016]. The third condition is a technical requirement on the estimator. In the cases we consider, it suffices that the range of Y and Q are bounded and that g is bounded away from 0 and 1. This later requirement is the common ‘overlap’ condition, and is anyway required for the estimation of the causal effects.

Proof.

By creftype 4.1 and assumption 1, ψ^({(ti,yi,λ(𝐰i))};η)𝑝ψ.

For brevity, we write λi=λ(𝐰i). By Taylor’s theorem,

1niϕ(ti,yi,η~(λ^i))=1niϕ(ti,yi,η(λi))+1niηϕ(ti,yi,ηi*)(η~(λ^i)-η(λi)),

for some {ηi*}. By continuous mapping, it suffices to show that the second term goes to 0 in probability. By Cauchy-Schwarz and assumption 3,

1niηϕ(ti,yi,ηi*)(η~(λ^i)-η(λi))C1niη~(λ^i)-η(λi)22.

By Markov’s inequality, P(1niη~(λ^i)-η(λi)22>ε)η(λi)-η~(λ^i)P,22/ε, for all ε>0. The result follows by assumption 2. ∎

As with all causal inference, the validity of the procedure relies on uncheckable assumptions that the practitioner must assess on a case-by-case basis. Particularly, we require that:

  1. 1.

    (properties z of) the document text renders the effect identifiable,

  2. 2.

    the embedding method extracts text information relevant to the prediction of both t and y,

  3. 3.

    the conditional outcome and propensity score models are consistent.

Only the second assumption is non-standard. In practice, we use the best possible embedding method and take the strong performance on (predictive) natural language tasks in many contexts as evidence that the method effectively extracts information relevant to prediction tasks. Implicitly, we are assuming that features that are useful for language understanding tasks are also useful for eliminating confounding. This is reasonable in settings where we expect the confounding to be aspects such as topic, writing quality, or sentiment. Informally, assumption 2 is satisfied if we use a good natural-language model, so we satisfy it by using the best available model.

Causal BERT.  We modify BERT, a state-of-the-art language model \citepDevlin:Chang:Lee:Toutanova:2018. Each input to BERT is the document text, a sequence of word-piece tokens 𝐰i=(wi1,,wil). The model is tasked with producing three kinds of outputs: 1) document-level embeddings, 2) a map from the embeddings to treatment probability, 3) a map from the embeddings to expected outcomes for the treated and untreated.

The model assigns an embedding ξw to each word-piece w. It then produces a document-level embedding for document text 𝐰i as λi=f((ξwi1,,ξwil),γU) for a particular function f. The embeddings and global parameter γU are trained by minimizing an unsupervised objective, denoted as LU(𝐰i;ξ,γU). Informally, random word-piece tokens are censored from each document and the model is tasked with predicting their identities.11 1 BERT also considers a ‘next sentence’ prediction task, which we do not use.

Following \citetDevlin:Chang:Lee:Toutanova:2018, we use a fine-tuning approach to solve the prediction problem. We add a logit-linear layer mapping λig~(λi;γg) and a 2-hidden layer neural net for each of λiQ~(0,λi;γQ0) and λiQ~(1,λi;γQ1). We learn the parameters for the embedding model and the prediction model jointly. Intuitively, this adapts the embeddings to be useful for the downstream prediction task, i.e., for causal inference.

We write γ for the full collection of global parameters. The final model is trained as:

λ^i =f((ξ^n,wi1,,ξ^n,wil),γ^U)
ξ^,γ^ =argminξ,γ1niL(𝐰i;ξ,γ),

where the objective is designed to predict both the treatment and outcome. It is

L(𝐰i;ξ,γ)=(yi-Q~(ti,λi;γ))2+𝖢𝗋𝗈𝗌𝗌𝖤𝗇𝗍(ti,g~(λi;γ))+LU(𝐰i;ξ,γ).

Effect estimation.  Computing causal effect estimates simply requires plugging in the propensity scores and expected outcomes that the trained model predicts on the held-out units. For example, using the plug-in estimator creftype 3.2,

ψ^Q:=1niQ~(1,λ^n,i;γ^nQ)-Q~(0,λ^n,i;γ^nQ). (4.1)

The same procedure applies to other estimators as well.

Natural direct effect.  We now discuss the analogous development for the natural direct effect. In this setting, the text serve as mediators between the treatment and the outcome. We are interested in understanding the causal effect of the treatment that does not go through the text.

The key result is the analogue of creftype 4.1. Namely, suppose λ is some function of the words such that λ(𝐖) carries all information relevant to both the prediction of the treatment and outcome. Then the natural direct effect is equal to

β=𝔼P(λ(𝐖)|T=1)[𝔼[Y|λ(𝐖),do(T=1)]-𝔼[Y|λ(𝐖),do(T=0)]]. (4.2)

That is, adjusting for λ(𝐖) suffices to adjust for any mediating effect in the words. This result is essentially by definition: any mediator must be predictive of both the treatment and outcome, so it suffices to adjust only for the parts of 𝐰 that are predictive of both treatment and outcome.

The remaining development is identical to the average treatment effect case. We estimate embeddings, propensities, and conditional expected outcomes using Causal BERT, and then plug these estimates into a downstream direct effect estimator. For example,

β^plugin=1ni[Q~(1,λ^i)-Q~(0,λ^i)]g~(λ^i)/(1niti). (4.3)

The proof of validity is the same as creftype 4.2.

5 Experiments

We now empirically study the quality of Causal BERT embeddings for causal estimation. The questions of interest are: 1) do the learned embeddings identify causal effects in realistic simulations? 2) what happens in the presence of unobserved confounding exogenous to the text? Additionally, we apply the proposed method to the two motivating examples in the introduction. We estimate causal effects on paper acceptance and post popularity on Reddit.com.22 2 Software and data at github.com/blei-lab/causal-text-embeddings.

We find: 1) The method is able to effectively adjust for confounding. And, 2) it is robust to exogenous confounding. Our application suggests that much of the apparent effect of the treatments we study is attributable to confounding in the text.

5.1 Setup

PeerRead.  PeerRead is a corpus of computer-science papers [Kang:Ammar:Dalvi:vanZuylen:Kohlmeier:Hovy:Schwartz:2018]. We consider a subset of the corpus consisting of papers posted to the arXiv under cs.cl, cs.lg, or cs.ai between 2007 and 2017 inclusive. The data only includes papers which are not cross listed with any non-cs categories and are within a month of the submission deadline for a target conferences. The conferences are: ACL, EMNLP, NAACL, EACL, TACL, NeurIPS, ICML, ICLR and AAAI. A paper is marked as accepted if it appeared in one of the target venues. Otherwise, the paper is marked as rejected. The dataset includes 11,778 papers, of which 2,891 are accepted.

For each paper, we consider the text of abstract, the accept/reject decision, and two attributes:

  1. 1.

    buzzy: the title contains any of ‘deep’, ‘neural’, ‘embed’, or ‘adversarial net’.

  2. 2.

    theorem: the word ‘Theorem’ appears in the paper.

These attributes can be predicted from the abstract text.

Reddit.  Reddit is an online forum divided into topic-specific subforums called ‘subreddits’. We consider three subreddits: keto, okcupid, and childfree. In these subreddits, we identify users whose username flair includes a gender label (usually ‘M’ or ‘F’). We collect all top-level comments from these users in 2018. We use each comment’s text and score, the number of likes minus dislikes from other users. The dataset includes 90k comments in the selected subreddits. We consider the direct effect of the labeled gender on posts’ scores.

Estimator.  We use Causal BERT, explained in creftype 4. We truncate PeerRead abstracts to 250 word-piece tokens, and Reddit posts to 128 word-piece tokens. We begin with a BERT model pre-trained on a general English language corpus. We further pre-train a BERT model on each dataset, running training on the unsupervised objective until convergence. In all cases, we use a logit-linear layer to predict treatment from embeddings, and a 2 hidden layer neural network for the expected outcome predictor.

For each experiment, we consider two downstream estimators: The simple estimators creftypeplural 4.3\crefpairconjunction4.1, and ‘one-step’ TMLE estimators [vanderLaan:Gruber:2016]. The latter are more sophisticated estimators that combine estimated conditional outcomes and propensities to achieve asymptotic robustness and efficiency properties. For all estimators, we exclude units that have a predicted propensity score greater than 0.97 or less than 0.03.

5.2 Results

Estimator Evaluation

Table 1: Embedding adjustment recovers the NDE on Reddit. This persists even with high confounding and high noise. Table entries are estimated NDE. Columns are labeled by confounding level. Low, Med., and High correspond to β1=1.0,10.0 and 100.0.
Noise: σ=1.0 σ=4.0

Confounding:
Low Med. High 30.0pt Low Med. High
Ground truth 1.00 1.00 1.00 1.00 1.00 1.00
Unadjusted 1.03 1.24 3.48 0.99 1.22 3.51
Words β^plugin 1.01 1.17 2.69 1.04 1.16 2.63
Words β^TMLE 1.02 1.18 2.71 1.04 1.17 2.65
LDA β^plugin 1.01 1.20 2.95 1.02 1.19 2.91
LDA β^TMLE 1.01 1.20 2.96 1.02 1.19 2.91
β^plugin 0.96 1.05 1.24 0.83 0.63 1.31
β^TMLE 0.98 1.05 1.58 0.95 1.00 1.51
Table 2: Embedding adjustment recovers the ATE on PeerRead. This persists even with high confounding. Table entries are estimated ATE. Columns are labeled by confounding level. Low, Med., and High correspond to β1=1.0,5.0 and 25.0.
Confounding: Low Med. High
Ground truth 0.06 0.05 0.03
Unadjusted 0.08 0.15 0.16
Words ψ^Q 0.07 0.13 0.15
Words ψ^TMLE 0.07 0.13 0.15
LDA ψ^Q 0.06 0.06 0.06
LDA ψ^TMLE 0.06 0.06 0.06
ψ^Q 0.07 0.06 -0.01
ψ^TMLE 0.06 0.07 0.04

Empirical evaluation of causal estimation procedures requires semi-synthetic data because ground truth causal effects are usually not available for real-world data. For such evaluations to be compelling, the semi-synthetic model must be reflective of real-world data. This is challenging for text data: there are no realistic generative models of text, so it is not possible to generate a confounder and then generate the text, treatment, and outcome on the basis of this confounder.

To circumvent this, we use real metadata—subreddit and title buzziness—as the confounders z~ for the simulation. We simulate only the outcomes, using the treatment and the confounder. We compute the true propensity score π(z~) as the proportion of units with ti=1 in each strata of z~. Then, Yi is simulated from the model:

Yi=ti+β1(π(zi~)-0.5)+εi  εiN(0,σ).

Or, for binary outcomes,

YiBernoulli(sigmoid(0.25ti+b1(π(z~i)-0.2)))

The parameter b1 controls the level of confounding; e.g., the bias of the unadjusted difference 𝔼[Y|T=1]-𝔼[Y|T=0] increases with b1. For PeerRead, we report estimates of the ATE for binary simulated outcomes. For Reddit, we compute the NDE for simulated real-valued outcomes.

Additionally, we compare against two baselines. The first is a two-stage procedure that uses LDA to estimate document-topic proportions z^ and linear/logistic regression for Q^(z^) and g^(z^). The second fits linear/logistic regression for the expected outcomes and treatments using word counts directly without dimensionality reduction.

Results are summarized in creftypeplural 2\crefpairconjunction1. Compared to the unadjusted estimate, all methods for adjustment reduce confounding. However, causal BERT does substantially better for moderate to high confounding. This is even in a simulation setting favorable to LDA (the true confounding is topic, and has a simple relation to outcome). The benefits of dimensionality reduction on text are clear in PeerRead, where adjustment based on LDA is much better than using the words alone.

The effect of exogeneity.

Figure 2: The method improves the unadjusted estimator even with exogeneous mediatiors. Plot shows estimates of NDE from simulated data based on Reddit. Ground truth is 1.

We assume that the text carries all information about the confounding (or mediation) necessary to identify the causal effect. In many situations, this assumption may not be fully realistic. For example, in the simulations just discussed, it may not be possible to exactly recover the confounding from the text. We study the effect of violating this assumption by simulating both treatment and outcome from a confounder that consists of a part that can be fully inferred from the text and part that is wholly exogenous.

The challenge is finding a realistic confounder that can be exactly inferred from the text. Our approach is to (i) train BERT to predict the actual treatment of interest, producing propensity scores g^i for each i, and (ii) use g^i as the inferrable part of the confounding. Precisely, we simulate propensity scores as logitgsim=(1-p)logitg^i+pξi, with ξiiidN(0,1). The outcome is simulated as above. When p=0, the simulation is fully-inferrable and closely matches real data. Increasing p allows us to study the effect of exogeneity; see creftype 2. As expected, the adjustment quality decays. Remarkably, the adjustment improves the naive estimate at all levels of exogeneity—the method is robust to violations of the theoretical assumptions.

Table 3: Embedding adjustment reduces estimated treatment effects in PeerRead. Entries are estimated treatment effect and 10-fold bootstrap standard deviation.
buzzy theorem
Unadjusted 0.08±0.01 0.21±0.01
ψ^Q 0.01±0.03 0.03±0.03
ψ^TMLE 0.06±0.04 0.10±0.03
Table 4: Embedding adjustment reduces estimated direct effects in Reddit. Entries are estimated treatment effect and 10-fold bootstrap standard deviation.
okcupid childfree keto
Unadjusted -0.18±0.01 -0.19±0.01 -0.00±0.00
β^plugin -0.10±0.04 -0.10±0.04 -0.03±0.02
β^TMLE -0.15±0.05 -0.16±0.05 -0.01±0.00

Application  We apply causal BERT to estimate the treatment effect of buzzy and theorem, and the effect of gender on log-score in each subreddit; see creftypeplural 4\crefpairconjunction3. Although unadjusted estimates suggest strong effects, our results show this is in large part explainable by confounding or mediating. On PeerRead, the TMLE estimate ψ^TMLE suggests a positive effect from including a theorem on paper acceptance, but the Q-only estimator does not. On Reddit, both estimates suggest a positive effect from labeling a post as female on its score in okcupid and childfree.

\printbibliography