ABSTRACT Objective To estimate the causal effect of executive functioning on the remission of depression and anxiety symptoms in an observational dataset from a vocational rehabilitation program. It is also an aim to promote a method from the causal inference literature and to illustrate its value in this setting. Method With longitudinal (four-time points over 13 months) data from four independent sites, we compiled a dataset with 390 participants. At each time point, participants were tested on executive function and self-reported symptoms of anxiety and depression. We used g-estimation to evaluate whether objectively tested cognitive flexibility affected depressive/anxious symptoms and tested for moderation. Multiple imputations were used to handle missing data. Results The g-estimation showed a strong causal effect of cognitive inflexibility reducing depression and anxiety and modified by education level. In a counterfactual framework, a hypothetical intervention that could lower cognitive flexibility seemed to cause improvement in mental distress at the subsequent time-point (negative sign) for low education. The less flexibility, the larger improvement. For high education, the same but weaker effect was found, with a change in sign, negative during the intervention and positive during follow-up. Discussion An unexpected and strong effect was found from cognitive inflexibility on symptom improvement. This study demonstrates how to estimate causal psychological effects with standard software in an observational dataset with substantial missing and shows the value of such methods.