Suppose that one is interested to compare the effect of biological age versus "cognitive age" on a variety of outcomes. Cognitive age is measured by testing intelligence. The outcomes are a variety of variables such as psychological well-being, amount of social interaction, income and so on.

One is interested to see in which outcomes for which the effect of biological age versus cognitive age are different (for example, both "ages" significant with a different direction or only one age significant).

A simple approach that seemed reasonable to me, is to use linear regression outcome ~ age + cognitive age. If many outcome variables are tested, then the p-values of both age and cognitive age can be corrected for multiple comparisons. Initially (and perhaps naively) it seemed that such a regression would give the effect of cognitive age at each level of biological age, and the effect of biological age holding the cognitive age constant, solving the problem.

Now, the crux of the problem. The cognitive age is affected strongly degree by the biological age. The DAG diagram of this relationship is shown below:

enter image description here

It seems to me that comparing directly the effect of the biological age to the cognitive age is problematic in such a case. That is because the cognitive age is (at least partially) a mediator for biological age.

As an extreme example (just to make the point), suppose that all of the participants in the study suffer from Alzheimer, which is affected almost exclusively by age. In such a case, if we measure the effect of Alzheimer on memory-function, and compare it to the effect of biological age on memory-function, we will see that the effect of Alzheimer is much stronger. This can lead us to falsely conclude that age does not affect memory-function (and that Alzheimer does so much strongly). This is very untrue, since age is precisely the factor (at least in this example) which causes Alzheimer, so stating that it does not cause memory-function loss is stating the opposite of the truth. Stating that Alzheimer causes memory-function loss much stronger than biological age does is also very misleading.

My question is how the effect of the biological age versus that of the cognitive age, on the outcome, can even be estimated in such a case?

If one should use causality theory for that, what sub-field of it is relevant?

  • 2
    $\begingroup$ Putting on my psychometrician hat, "cognitive age" has been abandoned as a construct for many years. It's really pretty meaningless and implies a linear development of intelligence over time, which is pretty silly. A 10 year old is not twice as smart as a 5 year old and half as smart as a 20 year old. $\endgroup$
    – Peter Flom
    Commented Jun 19 at 11:59
  • 2
    $\begingroup$ Also, I would certainly not posit linear effects of either chronological age or intelligence on pretty much anything. The relationships may not even be monotonic. Are you using splines? $\endgroup$
    – Peter Flom
    Commented Jun 19 at 12:01
  • 1
    $\begingroup$ I agree with @PeterFlom that this may not be the ideal way of modeling this. I outline in my answer how you can deal with this in Method 1 in other cases of mediation (which can be estimated simply by using mediation analysis), but also note in Method 2 that GAMs are another option if you want a flexible spline approach. $\endgroup$ Commented Jun 19 at 12:51
  • $\begingroup$ @PeterFlom This is an example similar only conceptually to my actual data, I am not really working with the construct of cognitive age. $\endgroup$
    – Sam
    Commented Jun 19 at 12:57
  • $\begingroup$ @Sam Then please correct your question with the right variables. It can make a difference. $\endgroup$
    – Peter Flom
    Commented Jun 19 at 16:31

1 Answer 1


Method 1

My answer only addresses the statistical part of your question (Peter notes some issues with your model from a theoretical perspective, which is equally important). If you have a strong a priori belief that such a relationship exists, it seems straight-forward to simply estimate this with a standard mediation analysis.

Mediation analysis decomposes the regression paths so the direct path, $c$ is defined as the following equation (where $\beta$ denotes a coefficient):

$$ Y = \beta_0 + \beta_1X + \epsilon $$

Which estimates the direct effect of $X$ on $Y$ as well as it's leftover error. If we have a mediator $M$, then we have technically two paths running from $X$ to $Y$ that we must account for via $M$, via Path $a$ and Path $b$ below, with coefficients $\gamma$ and $\eta$ and errors $\delta$ and $\xi$:

$$ M = \gamma_0 + \gamma_1 X + \delta \\ Y = \eta_0 + \eta_1 M + \xi $$

These paths directly and indirectly to $Y$ can be visualized as so:

enter image description here

This tells us the direct path for each relationship, but this doesn't really tell us 1) the indirect effect of $X$ on $Y$, and 2) the total effect of $X$ both directly to $Y$ and through $M$. After obtaining the regression paths from above, one can estimate these effects as:

$$ \text{Indirect Effect} = a*b \\ \text{Total Effect} = c + (a*b) $$

Simulating and fitting such a model may make this more clear.


There are various ways of doing this, but I prefer to run this in lavaan in R. Some simulated data for a mediation relationship is found below. We first load the libraries in R, set a random seed for replication, and estimate our $X$, $M$, and $Y$ with varying coefficient terms and normal errors. We merge this data into df. In this model, I simulate $Y$ as being strongly associated with $M$, $X$ having a moderate association with $M$, and $X$ having essentially no relationship with $Y$.

#### Load Libraries and Set Seed ####

#### Simulate Data ####
n <- 1000
X <- rnorm(n)
M <- 0.20*X + rnorm(n)
Y <- 0.85*M + rnorm(n)

#### Create Dataframe ####
df <- data.frame(X = X, Y = Y, M = M)

One can write the model to estimate the direct effect of $X$ on $Y$, the mediation relationship of the regression paths between $X$, $M$, and $Y$, and the indirect and total effects as prescribed earlier in the following syntax, labeled in hash comments:

#### Write Model ####
model <- '
# direct effect
Y ~ c*X

# mediator
M ~ a*X
Y ~ b*M

# indirect effect (a*b)
ab := a*b

# total effect
total := c + (a*b)

Fitting the model is then straightforward from here. One fits the model with sem() with the data and model, and can summarize from there the effects.

#### Fit Model ####
fit <- sem(model, data = df)

One can see the regression paths and indirect/direct/total effects as simulated. Notice that the slopes are where the Estimate column is, which mirror how we simulated the coefficients:

lavaan 0.6-18 ended normally after 1 iteration

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         5

  Number of observations                          1000

Model Test User Model:
  Test statistic                                 0.000
  Degrees of freedom                                 0

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

                   Estimate  Std.Err  z-value  P(>|z|)
  Y ~                                                 
    X          (c)   -0.027    0.032   -0.833    0.405
  M ~                                                 
    X          (a)    0.288    0.032    8.980    0.000
  Y ~                                                 
    M          (b)    0.878    0.031   28.547    0.000

                   Estimate  Std.Err  z-value  P(>|z|)
   .Y                 0.955    0.043   22.361    0.000
   .M                 1.011    0.045   22.361    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    ab                0.253    0.030    8.566    0.000
    total             0.226    0.042    5.375    0.000

As shown in the summary, the direct effect of $X$ on $Y$ is close to zero ($\beta = -.02$), the indirect effect (ab) is equal to $.253$, and the total effect is $.226$. The model form, without the estimated paths, is shown below:

#### Plot Model ####
  layout = "tree",
  rotation = 2,
  edge.label.cex = 2,
  sizeMan = 7,
  what = "est"

The plotted model looks like this, where the green paths indicate a positive association and reds are negative associations (here the relationship between $X$ and $Y$ is essentially nil, so semPaths by default draws basically a blank line):

enter image description here

And that is the basic mediation model in a nutshell, which you would use in a case like yours. There is obviously more to such models, and I recommend Rex Kline's book on structural equation modeling, which details how to estimate mediation analyses if you are interested in learning more.

Method 2

Now as Peter noted, anything involving age has a strong tendency to be nonlinear, particularly with a wide span of ages. If what he says is true about cognitive age, then we could simply omit cognitive age and estimate biological age with a spline or other nonlinear tool. I prefer GAMs (which use penalized splines) for their flexibility, which I detail in brief here. Since that answer has a theoretical and simulated discussion, I leave OP to read that answer separately.

  • $\begingroup$ The coefficients of Y~X and of Y~M, are calculated to be exactly the same coefficients by sem as by lm(Y~X+M). I think it means my initial idea that a mediation analysis must be used in this case is wrong. $\endgroup$
    – Sam
    Commented Jun 20 at 10:58
  • $\begingroup$ @Sam that is only partly true. The regression coefficients can sometimes be the same (depending on how it is modeled), but the standard errors and associated $p$ values of those paths won't always be. For example, this framework allows you to estimate the indirect and total effects like mentioned earlier, which includes their inferential estimates that are not calculated by typical regressions. By default, lavaan calculates them using the Sobel method, but usually nowadays people use bootstrapped SEs from the lavaan model. $\endgroup$ Commented Jun 20 at 12:31
  • 1
    $\begingroup$ You can see for example that the "Defined parameters" section includes output for the indirect/total effects that includes these estimates. Estimating these using separate equations is mistake that was originally proposed by mediation modelers and is now considered bad practice. You might appreciate this paper on the topic. $\endgroup$ Commented Jun 20 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.