I try to run a Mediation analyses. Unfortunately PROCESS by Hayes doesn't allow dichotomous variables.

How can I solve the Problem? How can I calculate for direct and indirect effects?

My variables are:

x: Softness (categorial: soft, middle, hard)

y:sample size, metric

Mediator: study design (dichotomous: experiment vs. quasi-experiment)

Softness of the discipline is the predictor (Smith et al. 2000 found out that some (psychological) disciplines are rated as softer than others e.g. educational Psychology is "softer" than Neuroscience). This should directly effect the sample Size (Marszalek et al.2011 found out that different subdisciplines varies in size of sample collection per study). Marszalek 2011 guess this direct effect could be mediated by study design, as "harder disciplines" run more experiments than softer disciplines (they probably Use more quasi-experimental designs) and the study design should effect the sample size e.g. experiments need a smaller sample to detect an effect, because standard error is usually smaller than in quasi experimental designs and confounders are smaller or easier to controll compared to quasi-experimental Designs.

  • $\begingroup$ Please say more about the underlying relationship you envision. What you seem to be saying that is softness (X) is a predictor of an outcome sample size (Y), perhaps mediated by an effect of softness on study design which in turn affects sample size. It's not clear, for example, just what softness means in this case or how you expect it to affect either of study design or `sample size. Please provide that information by editing the question, as comments are easy to overlook and can be deleted. $\endgroup$
    – EdM
    Commented Feb 16, 2022 at 21:46
  • $\begingroup$ Thanks, I specified my variables. $\endgroup$
    – Nicole
    Commented Feb 17, 2022 at 8:17

2 Answers 2


Dawn Iacobucci* suggests a general approach for mediation analysis involving combinations of categorical and continuous variables. Use ordinary least squares (OLS) or logistic regression (LR) as appropriate for each of the individual regressions. Although the coefficients are in different types of scales, if you standardize each coefficient by its estimated standard error and the estimates are close enough to normally distributed, then the coefficients can be combined as needed to evaluate whether mediation is significant. The suggested steps are:

First, to estimate the strength of the "direct path" from predictor(s) $X$ to outcome $Y$, model:

$$\hat Y = b_{01} + c X.$$

That would be OLS in your situation with an effectively continuous outcome.

Then for the influence of $X$ on $M$, fit:

$$\hat M = b_{02} + a X.$$

With binary mediator $M$ that would be logistic regression.

For the model with both $M$ and $X$ as predictors of $Y$

$$\hat Y = b_{03} + c' X + b M$$

you would use OLS in your situation.

Standardize the coefficient estimates $\hat a$ and $\hat b$ by their corresponding standard errors $\hat s_a$ and $\hat s_b$: $z_a = \hat a/\hat s_a$ and $z_b = \hat b/\hat s_b$. The standard error of the product $z_a z_b$, assuming normality, is $\hat \sigma_{z_{ab}}=\sqrt{z_a^2 + z_b^2 +1}$.

The test for mediation is then comparing

$$z_{\text{mediation}} = \frac{z_a z_b}{\hat \sigma_{z_{ab}}}$$

against a standard normal.

Two warnings. First, I haven't tried this myself, so read the paper to make sure that this approach will work in your situation. Second, you will have to consider how to handle the 2 coefficients associated with your 3-level predictor $X$ in each of the regressions. The simplest would be comparisons of each of middle and hard against soft, as they correspond to the reported coefficients if soft is the reference level. You might consider coding it as an ordinal rather than a nominal predictor, or find that the differences between successive levels of $X$ are close enough to linearly spaced with respect to outcomes that you can code it as continuous.

*Mediation analysis and categorical variables: The final frontier, Journal of Consumer Psychology 22: 582-594, 2012.


Look at the medflex package in R and its associated literature. They describe how to address multicategory focal predictors in section 4.1 of the vignette. The types of variables for the mediator and outcome do not matter and varying types are easily handled by the software. This relies on a more nuanced understanding of mediation than is described in most articles by Hayes and Preacher, which tend to be focused on the use of mediation in psychology with continuous variables.


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.