<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rumen Iliev on Medium]]></title>
        <description><![CDATA[Stories by Rumen Iliev on Medium]]></description>
        <link>https://medium.com/@rumen.i.iliev?source=rss-33be5d3e528d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZsPY9TH5H2ze0w6Q</url>
            <title>Stories by Rumen Iliev on Medium</title>
            <link>https://medium.com/@rumen.i.iliev?source=rss-33be5d3e528d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:53:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rumen.i.iliev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Quick Comparison of Causal-Inference Estimates]]></title>
            <link>https://medium.com/data-science/a-quick-comparison-of-causal-inference-estimates-d7995592025?source=rss-33be5d3e528d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7995592025</guid>
            <category><![CDATA[front-doors]]></category>
            <category><![CDATA[backdoor]]></category>
            <category><![CDATA[instrumental-variable]]></category>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[causality]]></category>
            <dc:creator><![CDATA[Rumen Iliev]]></dc:creator>
            <pubDate>Tue, 28 Apr 2020 06:00:08 GMT</pubDate>
            <atom:updated>2020-04-29T05:19:51.151Z</atom:updated>
            <content:encoded><![CDATA[<h4>There are many ways to estimate the magnitude of a causal effect, and here we use a minimally complex causal structure to check if those estimates agree.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GEZcLUda_eFBwnOM" /><figcaption>source: <a href="https://www.shutterstock.com/g/Fascinadora">Fascinadora</a> via <a href="https://www.shutterstock.com/">shutterstock</a> (SL)</figcaption></figure><p><strong>1. Introduction</strong></p><p>As an experimental behavioral scientist, I always thought that understanding the causal directionality of statistical relationships is at the heart of empirical science. I was trained in classical experimental design, where the researcher is assumed to have full control over the environment and whose main worry is how to position different experimental conditions in time or space (e.g. <a href="https://www.york.ac.uk/depts/maths/histstat/images/latin_square.gif">Latin Square Design</a>). Once you leave the safety of the controlled lab experiments, however, inferring causality becomes a major problem which easily jeopardizes the internal validity of your conclusions. Luckily, in the last few decades, there has been tremendous progress in research on statistical causality, both in theory and methods, and now causal inference is becoming a rather common tool in the toolbox of a data scientist. To catch up with current methods I did a quick review and I was somewhat surprised by the plethora of ways for estimating causal effects. In this project I will list the most common methods I found in the literature, apply them to a simplified causal problem, and compare the observed estimates. This comparison is intended as a brief high-level overview and not as a tutorial on causal inferences. For a brief introduction on the topic I recommend Pearl et al. (2016), and for an in-depth coverage an interested reader can check Pearl (2009), Morgan and Winship (2015) or Prof. Jason Roy’s online class (Roy, 2020).</p><p><strong>2. An Example Causal Model</strong></p><p>When using statistical methods to infer causality, typically we are interested in the magnitude of the effect of cause X on an outcome Y. When we are only observing those variables, or if there are challenges with the randomization (e.g. selection bias), we will typically need to account for a broader set of variables. In Figure 1 I present a causal graph for a hypothetical example. The example includes the three main types of additional variables which help us to get an unbiased estimate: backdoor, front door and instrument variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*ZV4AAVDeftgprE2Q" /></figure><p><em>Figure 1. A hypothetical graphical causal model of cause X influencing outcome Y in the presence of other variables. The causal effect of X on Y can be estimated if we measure any of these three sets: {X, Y, BD}, {X, Y, IV}, or {X, Y, FD}</em></p><p>Suppose that X is a binary variable indicating the effect of exercising at least weekly (x = 1 if exercising; x = 0 otherwise) and Y is life expectancy measured on a continuous scale. The effect of X on Y is fully mediated by a variable FD (<a href="http://marcfbellemare.com/wordpress/wp-content/uploads/2019/08/BellemareBloemFDCAugust2019.pdf">front door criterion</a>), which in our example might be a body mass index. Further, both Y and X are influenced by variable BD (<a href="https://ftp.cs.ucla.edu/pub/stat_ser/R195-SS.pdf">back door criterion</a><strong>)</strong>, which in our case could be some set of genetic factors, which do not affect FD directly. Last, X is also influenced by IV (<a href="https://en.wikipedia.org/wiki/Instrumental_variables_estimation">instrumental variables</a>), which for our illustration could be proximity to a sport facility.</p><p>We can instantiate this causal graph with the following model:</p><p>IV = U</p><p>BD = U</p><p>X = { 0, if IV — BD + U &lt;= 0</p><p>1, if IV — BD + U &gt; 0}</p><p>FD = X + U</p><p>Y = 65 + FD + BD + U</p><p><em>Model 1: Structural Causal Model instantiating the graphical model in Figure 1. The U components are normally distributed error terms (or inputs from exogenous variables) with mean 0 and SD = 2.</em></p><p>For the purpose of the current simulation, I randomly generated 10,000 instances from Model 1 and in the next part, I will estimate the causal effect of X on Y using different statistical approaches.</p><p>Here is the relevant code:</p><pre>generate_df &lt;- function(n = 1000, path_weights) {<br> #generate data frame from path_weights<br> a &lt;- path_weights<br> sd_noise = 2<br> iv &lt;- rnorm(n, sd = sd_noise)<br> bd &lt;- rnorm(n, sd = sd_noise)<br> x &lt;- rnorm(n) + a[1]*iv + a[2]*bd<br> x &lt;- ifelse(x&lt;=median(x), 0, 1)<br> lm(x~iv + bd) %&gt;% summary<br> fd &lt;- (rnorm(n, sd = sd_noise) + a[3]*x ) <br> lm(fd ~ x) %&gt;% summary()<br> y &lt;- (65 + rnorm(n, sd = sd_noise) + a[4]*fd + a[5]*bd ) <br> lm(y ~ fd + bd) %&gt;% summary()<br> id &lt;- rnorm(n)<br> df &lt;- data.frame(<br>  id = id, x = x, y = y, iv = iv, fd = fd, bd = bd)<br> return(df)<br>}<br>path_weights &lt;- c(1,-1,1,1,1)<br>df &lt;- generate_df(n = 10000, path_weights)</pre><p><strong>3. Naive estimate (Observing X and Y)</strong></p><p>A naive estimate of the causal effect of X on Y could simply be obtained from the regression coefficient of X predicting Y. In this example, the causal effect is b_naive = -0.97, surprisingly suggesting that exercise shortens life expectancy by almost one year.</p><pre>naive_fit &lt;- lm(y~x, data = df)<br>summary(naive_fit)</pre><p>A naive estimate is useful when a researcher is convinced that there are no BD variables which need to be accounted for (e.g. when X is randomly assigned or as-if randomly assigned). With most observational studies and quasi-experimental designs, however, naive estimates are often not very useful.</p><p><strong>4. Back-door variable adjustment (Observing X, Y and BD)</strong></p><p>If in addition to X and Y you can also measure BD, you can compute an unbiased estimate of the causal effect of X on Y, avoiding the problems that naive estimates have. Here BD is just a single variable, but it could be a set of variables which satisfy the back-door criteria. When reviewing the literature I found the following five methods to estimate causal effects while adjusting for backdoor variables:</p><p><strong>4.1 Covariates</strong></p><p>One way to estimate the causal effect of X on Y is to run a regression model, predicting Y from X and including BD as a covariate. For most researchers who have training in linear regression but not in causal inferences, this is often the most intuitive approach.</p><pre>covariates_fit &lt;- lm(y~x+bd, data = df)<br>summary(covariates_fit)</pre><p>Applying this method to the data from our simulation we find that the causal effect of X on Y is b_covariates = 1.01. Based on this analysis, if you exercise you will live one year longer. Notice that this estimate is not only different than the naive estimate, the two estimates actually have opposite signs and lead to conflicting conclusions (check <a href="https://en.wikipedia.org/wiki/Simpson%27s_paradox">Simpson’s Paradox</a>)</p><p><strong>4.2 Direct Matching</strong></p><p>The covariates adjustment from above can also be accomplished by directly matching treatment and control participants on their BD scores. The main idea is that the matching procedure will remove the influence of BD on the causal estimate by only comparing control and treatment subjects who are already similar on their BD scores:</p><pre>greedymatch &lt;- Matching::Match(Tr = df$x, M = 1, X = df[,”bd”])<br>matched &lt;- df[unlist(greedymatch[c(“index.treated”, “index.control”)]),]<br>t.test(matched$y[matched$x == 1],matched$y[matched$x == 0], paired = TRUE)</pre><p>When using this method we get b_direct_match = 1.05, which is very close to what we observed when using the covariates method.</p><p><strong>4.3 Propensity Score Matching</strong></p><p>If you have multiple BD variables you need to account for, it might be very challenging to find good matches (check the <a href="https://en.wikipedia.org/wiki/Curse_of_dimensionality">curse of dimensionality</a>). Instead, you can use propensity score matching, where you first compute the probability for being in the treatment group (a.k.a propensity score, check <a href="https://www.tandfonline.com/doi/abs/10.1080/00273171.2011.568786">this</a> paper or <a href="http://freerangestats.info/blog/2017/04/09/propensity-v-regression">this</a> blog post), and then match participants based on those probabilities.</p><pre>ps_fit &lt;- glm(x~bd, data = df, family = “binomial”)<br>df$ps_score &lt;- ps_fit$fitted.values<br>logit &lt;- stats::qlogis # rename the function for clarity<br>greedymatch &lt;- Match(Tr = df$x, M = 1, X = logit(df[,”ps_score”]), caliper = .2)<br>matched &lt;- df[unlist(greedymatch[c(“index.treated”, “index.control”)]),]<br>t.test(matched$y[matched$x == 1],matched$y[matched$x == 0], paired = TRUE)</pre><p>The causal effect is estimated to be b_ps_match = 1.05 which is virtually the same as the previous adjusting methods.</p><p><strong>4.4 Inverse Probability of Treatment Weighting</strong></p><p>You can also use weighted regression, where the weights are based on the probability of treatment. Control participants with high propensity scores and treatment participants with low propensity scores receive higher weights, adjusting for the treatment/control imbalance due to the BD variable(s).</p><pre>df$weight &lt;- ifelse(df$x == 1, 1/df$ps_score, 1/(1-df$ps_score))<br>iptw_fit &lt;- lm(y ~ x, data = df, weights = weight)<br>summary(iptw_fit)</pre><p>The estimate for the simulated data was b_iptw = 0.92, very close to the previous estimates.</p><p><strong>4.5 Doubly-Robust Estimates</strong></p><p>This is a more advanced method which allows more room for misspecification of the model. To get an unbiased estimate of the causal effect it is enough to correctly specify either the propensity score model or the outcome regression model.</p><pre>dr_fit &lt;- drgee::drgee(oformula=y~bd,<br> eformula=x~bd,<br> iaformula=~bd, olink=”identity”, elink=”identity”,<br> estimation.method=”dr”,<br> data=df)<br>summary(dr_fit)</pre><p>The causal effect is b_doubly_robust = 1.01, again very similar to the previous other adjustment methods.</p><p><strong>5. Instrumental variable (Observing X, Y and IV)</strong></p><p>What if you know that BD exists, but you cannot measure it? If you can measure variable IV instead, you still can estimate the causal effect of X on Y. This approach is known as the Instrumental Variable method, where the effect of the instrument IV on Y is mediated by X and can be used to estimate the effect of X on Y. A common method to run this analysis is called two-stage regression, where at the first stage we regress X on the instrument IV, and on the second stage, we regress the outcome Y on the residuals from the first stage.</p><pre>stage1_fit &lt;- stats::lm(x~iv, data = df)<br>df$stage1_predict &lt;- predict(stage1_fit, type = “response”)<br>stage2_fit &lt;- stats::lm(y~stage1_predict, data = df)<br>summary(stage2_fit)</pre><p>In our example, the instrumental variable method estimates the causal effect of X on Y to be b_iv = 0.96, very close to the BD adjustment methods.</p><p><strong>6. Front-door adjustment (Observing X, Y and FD)</strong></p><p>Even if we can measure neither IV nor BD, it is still possible to compute an unbiased estimate of the causal effect of X on Y. The front-door adjustment allows us to achieve this by measuring the effect of X on FD and FD on Y.</p><pre>x_fd_fit &lt;- lm(fd~x, data = df)<br>fd_y_fit &lt;- lm(y~fd + x, data = df) # here x is included to block back-door effects<br>x_fd_fit$coefficients[2]*fd_y_fit$coefficients[2]</pre><p>Using front-door adjustment we estimate the causal effect of X on Y to be b_fd = 1.03.</p><p><strong>7. Cross-method agreement</strong></p><p>While I understand why some of the methods should return equivalent or very close estimates, I still find it both striking and somewhat perplexing that the causal effect of X and Y can be estimated in so many ways. To examine the agreement of the different methods I ran a series of simulations based on the causal graph from Figure 1. I used the same types of relations as the ones outlined in Model 1, but for each simulation, I randomly assigned a random regression coefficient, with absolute values ranging from 0.3 to 3. For reference, for the weaker relationship (coefficients set to 0.3) FD and BD together were explaining 8% of the variance in Y, and the stronger relationship (coefficients set to 3) they were explaining 68% of the variance (based on R²).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9zX2KII4b93aHL17" /></figure><p><em>Figure 2. Correlations between the causal effect estimates from the eight causal inference methods discussed here.</em></p><p>I ran 2000 simulations, with 2000 rows each. For each simulation I computed eight different estimates of the causal effect of X on Y, using the methods listed above. Figure 2 depicts the agreement between the different methods. As can be seen in the figure, there is substantial agreement between the methods, with Pearson’s correlations well above 0.9. The naive estimate is also positively correlated with the other methods, yet it often underestimates or overestimates the true causal effect.</p><p><strong>8. Caveats and further observations</strong></p><p>The goal of the current project was to provide a quick overarching example for the main methods for estimating causal effects and to demonstrate that those methods largely agree in their results. In its brevity, however, this example brushed over many important details, some of which I will need to mention explicitly:</p><ul><li>Here I treated causal effects as an unitary concept, yet there are different types of causal effects. Instrumental variables, for example, estimate Local Average Treatment Effect, while the other methods, as applied here, estimate (Marginal) Average Treatment Effect. Those two effects are not necessarily equal.</li><li>While the causal graph in Figure 1 and the subsequent model are based on various theoretical principles and assumptions, I only provided external references and did not discuss them here.</li><li>The different methods here largely agreed in their estimates, but this is partially due to the simple model I used to generate the data. For example, I did not include <a href="https://egap.org/methods-guides/10-things-heterogeneous-treatment-effects">heterogeneous treatment effects</a>, unbalanced groups or skewed distributions, all of which would have decreased the consensus across methods.</li><li>Matching methods are sensitive to the particular algorithms used and to the strength of the relationship between X and BD.</li><li>While experimenting with the magnitude of the causal relations, I noticed that weaker causal effects are associated with a substantial drop in agreement across methods. Instrumental variables estimates were particularly affected by the weak statistical relationships (check Bound, Jaeger, &amp; Baker, 1995)</li></ul><p><strong>9. Conclusion</strong></p><p>I found catching up with the field of causal inferences to be both challenging and exciting. To a novice, the field can seem fragmented, inconsistent and often focused on abstract theories rather than on applications. Yet beyond these initial impressions, it was fascinating to discover that both theories and methods gradually converge and provide researchers with a plethora of creative tools to use in their search for causality. Putting the most common of these tools together helped me to see the convergence of theories and methods and I hope it might be of help to other fellow researchers and data scientists.</p><p><strong>References</strong></p><p>Austin, P. C. (2011). An introduction to propensity score methods for reducing the effects of confounding in observational studies. <em>Multivariate behavioral research</em>, 46(3), 399–424.</p><p>Bellemare, M. F., &amp; Bloem, J. R. (2019). The Paper of How: Estimating Treatment Effects Using the Front-Door Criterion.</p><p>Bound, J., Jaeger, D. A., &amp; Baker, R. M. (1995). Problems with instrumental variables estimation when the correlation between the instruments and the endogenous explanatory variable is weak. <em>Journal of the American statistical association</em>, 90(430), 443–450.</p><p>Bound, J., Jaeger, D. A., &amp; Baker, R. M. (1995). Problems with instrumental variables estimation when the correlation between the instruments and the endogenous explanatory variable is weak. <em>Journal of the American statistical association</em>, 90(430), 443–450.</p><p>Morgan, S. L., &amp; Winship, C. (2015). <em>Counterfactuals and causal inference</em>. Cambridge University Press.</p><p>Pearl, J. (1993). Bayesian analysis in expert systems: comment: graphical models, causality and intervention.<em> Statistical Science</em>, 8(3), 266–269.</p><p>Pearl, J. (2009). Causality. Cambridge university press.</p><p>Pearl, J., Glymour, M., &amp; Jewell, N. P. (2016). <em>Causal inference in statistics: A primer.</em> John Wiley &amp; Sons.</p><p>Roy, J. (retrieved 2020, April 23) A Crash Course in Causality: Inferring Causal Effects from Observational Data. <em>coursera.org</em>, url: <a href="https://www.coursera.org/learn/crash-course-in-causality">https://www.coursera.org/learn/crash-course-in-causality</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7995592025" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-quick-comparison-of-causal-inference-estimates-d7995592025">A Quick Comparison of Causal-Inference Estimates</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do Good Predictors Predict Well?]]></title>
            <link>https://medium.com/data-science/do-good-predictors-predict-well-6f237e7e757e?source=rss-33be5d3e528d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f237e7e757e</guid>
            <dc:creator><![CDATA[Rumen Iliev]]></dc:creator>
            <pubDate>Thu, 12 Mar 2020 20:56:59 GMT</pubDate>
            <atom:updated>2020-04-25T15:31:32.487Z</atom:updated>
            <content:encoded><![CDATA[<h3>On the similarities and differences between hypothesis testing and classification performance.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TA9CAssqqVow4tHXRwyL-g.jpeg" /><figcaption>source: <a href="https://www.shutterstock.com/g/lassedesignen">lassedesignen</a> via <a href="https://www.shutterstock.com/">shutterstock</a> (SL)</figcaption></figure><p>Not long ago I was building a text classifier using SVM and I was quite happy to see 98.5% initial accuracy. After some quick checks, however, I noticed that my non-target category prevalence was about 99%. Had I predicted “non-target” for all cases, I would have actually observed a higher accuracy than my sophisticated model! I inspected the most predictive features extracted from the SVM, and they certainly passed a quick sanity check: the classifier was definitely getting a valuable signal and not just noise. How can I have a working classifier, yet its performance was no better than chance? Part of my confusion was coming from my background in experimentation, where computing an effect size and estimating statistical significance was often the ultimate goal of a quantitative analysis. I was familiar with a few other measures of performance which are appropriate for unbalanced groups, but I did not have good intuition about the relationship between statistical significance/effect size and classifier performance.To get some basic understanding about this relationship, I simulated a few examples, which I found quite informative and I hope the results will be helpful to other fellow data scientists struggling with the same question.</p><p><strong>Hypothesis testing versus classification tasks</strong></p><p>For those who have entered data science through the experimentation door, statistical inferences, and more specifically hypothesis testing were probably the main focus of applied statistics. When teaching Introduction to Statistics classes instructors often call independent variables “predictors”, and describe significant predictors as those variables that improve our best guess for the dependent variable. A common intuitive explanation of a regression model, for example, is that if we have no significant predictors, our best guess for the value of the dependent variable is its mean, while if we have a set of significant predictors, we should adjust our prediction depending on the values of those predictors. While this terminology is certainly useful in many contexts (sometimes reviewers in academic journals specifically advise to avoid causal language), it can lead to the false expectation that strong predictors (with large effect sizes and corresponding high statistical significance when sample size is constant) will necessarily improve our best guess about the outcome.</p><p>More specifically, in the simple case of two variables (an outcome and a predictor), both significance testing and classification tasks are based on the joint probability distribution of the two variables. If the the outcome and the predictor variables are independent, e.g. P(Target|Predictor) = P(Target) for all values of the Predictor, then any statistical tests will be non-significant and classification performance will not be better than chance. Despite this shared reliance on the joint probability distribution, however, statistical inference and classification tasks are answering inherently different questions. A hypothesis testing is about comparing the predictor’s probability distributions for the two different levels of the outcome. A prediction, on the other hand, is about choosing outcome value taking into account (or not) the value of the predictor. Lo et al. (<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4653162/">2015</a>) show how these two goals can diverge in the general case; here we will explore only the most obvious ones: unbalanced groups (Examples 1 and 2), and non-linear relationships (Example 3).</p><h4>Example 1: Binary predictors and the asymmetry of prediction</h4><p>Imagine that you are studying the relationship between lung cancer and smoking, and you are given a contingency table (Table 1) with the joint distribution for these two variables.</p><figure><img alt="Table 1. Hypothetical frequencies of lung cancer and smoking." src="https://cdn-images-1.medium.com/max/335/1*ZpMy2iPZXBUVBrEFkaJKEw.png" /><figcaption>Table 1. Hypothetical frequencies of lung cancer and smoking.</figcaption></figure><p>Clearly, there is a strong relationship between smoking and lung cancer, χ²(1, n = 100) = 30.72, p &lt; 10e-7, and the effect size is phi = 0.58, which in Social and Behavioral Sciences is considered large. Will this relationship be helpful for predicting the value of one of the variables based on the value of the other? Let us first try predicting if someone is a smoker based on their lung cancer status. If for every smoker we predict the presence of lung cancer, and for everyone non-smoker we predict no lung cancer, we will be correct in 75% of all cases (recall what a <a href="https://towardsdatascience.com/understanding-confusion-matrix-a9ad42dcfd62"><strong>confusion matrix</strong></a> is). This is much better than the base rate of lung cancer (50%), so taking into account smoking status helps us to improve our prediction. But what about the other way around? Does the knowledge about lung cancer status improve our predictions about smoking? Predicting smoking status based on lung cancer again leads to 75% correct predictions, but this is not different from the base rate of smoking. If we predict “smoker” for everyone, without taking into account any other information, we will still be correct in 75% of cases. A careful reader has probably already noticed that the discrepancy comes from the differences in the prevalence rates. Improving the accuracy of our predictions for balanced groups is much easier than for unbalanced groups.¹</p><h4>Example 2: Continuous predictors</h4><p>In this example we will still use a binary outcome variable, but this time the predictor will be continuous. It will be loosely based on the Signal Detection Theory framework. Imagine that you want to predict if a target is present (T) based on the value of a continuous signal (S). When the target is present the Signal is normally distributed N(M0, σ²) and when the target is absent the signal is<strong> </strong>N(M1, σ²). If we want to predict if a target is present or not, we can set a signal threshold, and if an observation is below it, we predict “no target” and if it is above it, we will predict “target” (see Figure 1). In some cases we will observe a signal that is below the threshold when the target is not present (True Negatives), yet in other cases we will make wrong predictions since the signal could be below the threshold even when the target is present (False Negatives). If we increase the threshold and change it from 1 to 2, we will increase the number of TNs (desirable) but also inevitably we will have more FNs (undesirable).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xo-N_HSIWEIO0CVMPa8aOA.png" /><figcaption>Figure 1. A basic Signal detection setting, where we choose a cut-off point for predicting presence and absence of targets. In this setting TP and TN are correct predictions, while FP and FN are incorrect predictions.</figcaption></figure><p>Note that in hypothesis testing we are interested if these two distributions are the same. In classification, we choose a cut-off point which maximizes a given performance metrics, such as accuracy. The greater the difference between M0 and M1, the more likely we are to reject the null hypothesis, and the more accurate the classifier is. Similarly to Example 1, however, in the case of highly unbalanced groups, we still can have poor predictions even when the two means are far apart (and therefore highly significantly different by t-test, for example). We will illustrate this point with a series of simulations presented in Figure 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LLvnBJny7daDIrWgAG1h5g.png" /><figcaption>Figure 2. Relationship between accuracy and effect size for binary outcome and a continuous predictor. The curves represent idealized (smoothed) histograms. Horizontally we vary the prevalence of the non-target group. Vertically we vary the distance between the group means (in standard deviations). The r is point-biserial correlation coefficient and can be used as a measure of effect size. Acc. is the maximum accuracy, which is achieved when using the red dotted line as a decision threshold.</figcaption></figure><p>The key message in Figure 2 is that the greater the disbalance between the two groups is, the less useful is the predictor variable for classification. For example, a correlation of ≈ 0.3 boosts accuracy for balanced groups (row 2, column 1) yet it does not increase accuracy for unbalanced groups (row 3, column 3). While both effect sizes and significance are affected by group disbalance, improvement in prediction accuracy is affected even more.</p><h4>Example 3: Same means but improved accuracy</h4><p>While the previous two examples demonstrated how accuracy of predictions might not increase even when there is a strong association between an outcome and a predictor, in this example I will demonstrate the opposite: having improvement in accuracy in the absence of significant association between variables.</p><p>Imagine that you are again presented with a binary outcome (target and non-target) and a continuous signal, as depicted in Figure 3. You check the correlation and it is 0, you run a t-test, and there is no significant difference between the two group means. You can easily dismiss the signal and erroneously conclude that the signal cannot help us predicting the outcome. In fact, in this particular setting, there is an optimal threshold which will lead to 58% accuracy, which is a substantial improvement over the original prevalence rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nt-00kXcS5c801jPRgMC5g.png" /><figcaption><em>Figure 3.</em> Idealized histograms for target and non-target groups. The means of the two distributions are the same, but the standard deviation of the target distribution is twice smaller than of the non-target group. The correlation between the two variables is 0, yet we can find a decision threshold which can improve the accuracy of the predictions beyond the prevalence.</figcaption></figure><p>This example reveals another important difference between statistical inference and classification tasks. In statistical inferences, we typically test for a particular type of dependency between two variables. Most frequently, for differences in means, proportions or the magnitude of correlation coefficients. Of course, we can also test for equality of variances, for whether two variables come from the same distribution, or for higher order relationships (quadratic would be particularly appropriate for the current example). In most cases, however, when working with large datasets or under time pressure, correlations and t-test are the main tool for significance testing. A classification model, on the other hand, will be less concerned with a particular type of relationship, and most likely will explore multiple thresholds/relationships. For example, if instead of using a single threshold, as in Signal Detection Theory, we run a decision tree, we will get two thresholds instead of one, which will get even higher accuracy.</p><h4>Conclusion</h4><p>The key message of this post is to present a series of simple examples demonstrating that statistical inferences and prediction tasks in classification should be treated very differently. You can have a strong statistical relation combined with poor classification performance. You can also have a good performance associated with a weak statistical relationship (for a particular hypothesis).</p><p>What we did not address here is how to evaluate the usefulness of a classifier which is based on a set of significant predictors but its accuracy is not better than the prevalence rate. When this happens one can use alternative performance metrics, which differentiate between different types of correct and incorrect predictions. In fact, the point-biserial correlation we used in Example 2 is also used as a performance metric for classifiers and it is referred to as Matthew’s coefficient. The stronger relationship between outcome and predictor might not be improving accuracy but it brings improvement over some particular cells in the confusion matrix. If some types of errors are more costly than others, you might be better off by using the predictor even if it hurts the overall accuracy. This, however, is beyond the scope of this post, and there are great academic papers (<a href="https://www.biostat.wisc.edu/~page/rocpr.pdf">Davis &amp; Goadrich, 2006</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S0167865508002687">Ferri et al., 2009</a>) and excellent posts on the topic (<a href="https://www.svds.com/learning-imbalanced-classes/">Fawcett, 2016</a>) for the interested reader.</p><h4>Key Points</h4><ul><li>Both statistical inference and classification are based on the joint probability distribution, but they answer different questions.</li><li>Larger effect sizes do not guarantee good predictions, as evident from Examples 1 and 2.</li><li>Small/zero effect sizes do not preclude a good classification performance, as evident from Example 3.</li><li>All other things being equal, a strong predictor (large effect size) will lead to a better classifier than a weaker predictor, yet this might not be directly captured by increased accuracy. The significant predictor could be improving other performance metrics, which you might or might not care about.</li></ul><p><strong>References:</strong></p><p>[1] Davis, J., &amp; Goadrich, M. The relationship between Precision-Recall and ROC curves (2006, June), <em>Proceedings of the 23rd international conference on Machine learning</em> (pp. 233–240).</p><p>[2] Ferri, C., Hernández-Orallo, J., &amp; Modroiu, R. An experimental comparison of performance measures for classification (2009), <em>Pattern Recognition Letters</em>, <em>30</em>(1), 27–38.</p><p>[3] Lo, A., Chernoff, H., Zheng, T., &amp; Lo, S. H. Why significant variables aren’t automatically good predictors (2015), <em>Proceedings of the National Academy of Sciences</em>, <em>112</em>(45), 13892–13897.</p><p><strong>Footnotes:</strong></p><p>1. Experts in machine learning will probably have noticed that here I am using the most simple performance metric called accuracy. Accuracy is the proportion of correct predictions and assumes that all correct and all incorrect predictions are weighted the same. Choice of metrics is a huge topic in the field of ML and I will not discuss it here, although, admittedly, using accuracy as a metric exacerbates the divergence between statistical inference and classification performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f237e7e757e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/do-good-predictors-predict-well-6f237e7e757e">Do Good Predictors Predict Well?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>