Skip to main content

首页 / Posts

[NCA] Beginner Guide from R Code to Interpreting Necessary Condition Analysis

A full Necessary Condition Analysis tutorial from theory to R code, showing how to identify bottleneck conditions, interpret effect size and p values, and add a rigorous necessity perspective to research.

Rosetears·
··1658 words·8 mins

Have you ever been stuck with the question “without X, can Y ever happen?” but only had regression results saying that X and Y are probably positively correlated?

Welcome to Necessary Condition Analysis (NCA).

NCA is not just another statistical wheel. It is an analytical paradigm based on necessity causality. Traditional regression and machine learning mostly follow sufficiency logic: they estimate how the average level of Y changes when X increases. NCA goes in the opposite direction. It looks for bottleneck conditions with veto power: if condition X does not reach a threshold, the desired outcome Y cannot occur no matter how strong the other conditions are.

NCA is therefore good at questions such as: What is the minimum resource level required? and Where is the bottom line for success?

As Jan Dul (2016) explains, a necessary condition can be viewed as a bottleneck that must be overcome or as an enabler that must exist before the outcome can occur. If the condition is absent at a given level, the outcome cannot happen regardless of other conditions.

Air is necessary for human survival, but more air will not make you taller. NCA finds this kind of “air” in data.

Core definitions

  • Necessary condition: X must exist before Y can appear, but X alone does not guarantee Y.
  • Effect size d: the proportion of the observable space occupied by the empty zone above the ceiling line; 0 <= d <= 1.
  • Statistical significance: permutation tests assess whether the empty zone could be random; 10,000 repetitions are common for publishable p-value precision.

1. Why your research may need NCA
#

1.1 Necessity versus sufficiency
#

Suppose your study explains “high performance”.

  • Regression / machine learning says that, on average, cohesion, R&D investment, and market sensitivity increase the likelihood of high performance. It draws a trend line through the center of the data.
  • NCA says that, regardless of other factors, high performance is impossible if customer trust stays below a threshold. It draws a ceiling line above the data.

1.2 NCA versus fsQCA
#

fsQCA can also analyze necessary conditions, but it mainly gives necessity judgments in kind: for example, institutional trust is necessary for civic cooperation. It calibrates variables into set membership and checks whether one set is a superset of another.

NCA can analyze necessity in degree: for example, institutional trust must reach at least 0.7 before 0.8-level civic cooperation is possible. NCA uses continuous information more fully and provides more actionable bottleneck levels. fsQCA finds the core recipes for success; NCA marks the minimum dose required for each ingredient.


2. R workflow from theory to code
#

The script in this post provides a production-style NCA workflow: package installation, data import, variable definition, core analysis, result output, and visualization. Use an RStudio project instead of hard-coded setwd("D:/...") paths, so the code remains portable.

Define one outcome variable Y and several condition variables X1 to X7. The script validates whether all specified columns exist before analysis. nca_analysis() then calculates effect sizes, p values, bottleneck tables, and ceiling-line plots. test.rep = 10000 is recommended for publication-level permutation tests.

The flip.x and flip.y parameters let you test alternative theoretical directions, such as whether low X is necessary for high Y.


3. Interpreting NCA results in three steps
#

Step 1: understand the tools
#

  • Ceiling line: defines the boundary of possibility. The empty zone above the line is where data should not appear. Larger empty zones indicate stronger necessity.
  • CE-FDH: a step-shaped ceiling line that hugs the data; useful for discrete variables or irregular boundaries.
  • CR-FDH: a smooth regression ceiling line; more robust for continuous variables and many observations.
  • Effect size d: measures constraint strength. Dul’s common benchmarks are small below 0.1, medium from 0.1 to 0.3, large from 0.3 to 0.5, and very large above 0.5.
  • c-accuracy: the share of data points that stay below the ceiling line. A reliable ceiling usually needs more than 95% accuracy.
  • p-value: permutation-test evidence against chance; p < 0.05 is the usual threshold.

Step 2: set screening criteria
#

A strong necessary condition normally satisfies all three:

  1. d > 0.1
  2. c-accuracy > 95%
  3. p < 0.05

Step 3: read the bottleneck table
#

The bottleneck table answers the practical question: to reach a given level of Y, how high must X be? Values are percentages of the variable range. NN means Not Necessary at that outcome level.


4. Practical interpretation
#

From the example output, Contractual detail passes the criteria under both CE-FDH and CR-FDH. Goodwill trust and Competence trust show large effect sizes under CE-FDH but do not pass the stricter CR-FDH accuracy threshold. The final diagnosis is that Contractual detail is the most robust necessary condition for Innovation in this example.

In the bottleneck table, no condition is necessary below 70% Innovation. From 70% upward, the variables become gatekeepers. To reach at least 80% Innovation, Contractual detail must reach 77.9% of its range, Goodwill trust must reach 98.1%, and Competence trust must reach 100%, making it the harshest bottleneck at high outcome levels.


5. Method complementarity and future directions
#

NCA does not replace traditional methods. It complements them. NCA + fsQCA is a strong pair: NCA identifies must-have elements and minimum thresholds, while fsQCA explores recipes that combine these elements with other conditions. If both are used together, the NCA data should usually be the fsQCA-calibrated data.

NCA also pairs well with regression or PLS-SEM. Regression finds factors that matter on average; NCA identifies foundations that cannot be missing. Together they provide a fuller causal picture.

6. Eight points for high-quality NCA research
#

  1. Start with theory: explain why X is necessary for Y.
  2. Use meaningful and reliable data.
  3. Show scatter plots and inspect them visually.
  4. Choose and justify the ceiling line.
  5. Report and interpret effect size.
  6. Report statistical tests.
  7. Use bottleneck analysis for practical recommendations.
  8. Describe NCA accurately as a method with theory, data analysis, and statistical testing.

Use NCA to add bottom-line thinking to your analytical toolkit. When you must answer the minimum level required, NCA gives a sharper answer than regression.


References
#

The original post lists NCA methodological references by Dul and collaborators, Vis and Dul, and a Chinese management-world application paper. See the source reference list for DOI links.

Appendix 1: download links#

  1. QCA-NCA-Toolbox (highly recommended): QCA-NCA-Toolbox
  2. Code and literature package: https://pan.quark.cn/s/ffa49729f84d?pwd=mTFg, extraction code mTFg
  3. Toolbox standalone package: https://pan.quark.cn/s/0a93bd1309b9?pwd=MTSf, extraction code MTSf

Appendix 2: complete runnable script
#

NCA code
The full R script is preserved below from the original article.

Preserved command, configuration, and prompt blocks
#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
> install.packages("NCA")
> library(NCA)
> data(nca.example2)
> write.csv(nca.example2, file = "nca_example2.csv", row.names = FALSE)
> ```

```R
# 封装一个函数,用于检查、安装和加载指定的R包。
# 这种方式让脚本在任何环境下都能自动准备依赖,无需手动操作。
install_and_load <- function(pkg) {
  # 检查包是否已被安装
  if (!requireNamespace(pkg, quietly = TRUE)) {
    message(sprintf("包 <%s> 未安装,正在从 CRAN 仓库自动安装,请稍候...", pkg))
    # 若未安装,则进行安装(同时安装依赖包)
    install.packages(pkg, dependencies = TRUE)
  }
  # 加载包,并抑制加载时产生的启动信息,保持控制台输出整洁。
  suppressPackageStartupMessages(library(pkg, character.only = TRUE))
}

# 加载 NCA 包
install_and_load("NCA")

# (可选) 设置随机数种子,如果不想设置随机种子,选中他,按“Ctrl + Shift + C”注释掉就可以了
# 为了保证研究的可复现性
# 设置一个固定的种子可以确保每次运行脚本得到完全相同的 p 值。
set.seed(123)
1
setwd("YOUR/PROJECT/FOLDER/PATH")
1
2
3
4

#### 变量定义

这是整个脚本唯一需要你**亲自修改**的地方。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ---------------------------------------------------------------------------------------
# 步骤 3: 结果解读、导出与可视化 (Results, Export & Visualization)
# ---------------------------------------------------------------------------------------

cat("===================================================================\n")
cat("模型已成功生成!下面将展示详细结果与散点图。\n")
cat("===================================================================\n\n")

# --- 3.1 详细分析结果表 ---
# 这是NCA最重要的结果,包含了效应量(d)、置信区间和p值。
# 效应量(d) 表示必要性的程度 (0 < d < 1),p值检验其是否显著。
# 使用 nca_output() 函数获取格式化的结果。
cat("--- (A) 主要分析结果 (效应量与显著性检验) ---\n")
nca_results_table <- nca_output(model, test = TRUE, summaries = TRUE, bottlenecks = FALSE, plots = FALSE)
cat("\n")


# --- 3.2 瓶颈分析表 ---
# 瓶颈分析 (Bottleneck Analysis) 指出在给定的Y水平上,X需要达到的最低水平。
# 默认展示 CR-FDH (Ceiling Regression - Free Disposal Hull) 的结果。
cat("--- (B) 瓶颈分析表 (CR-FDH) ---\n")
print(model$bottlenecks$cr_fdh)
cat("\n")
# 如果您也需要查看 CE-FDH (Ceiling Envelopment - Free Disposal Hull) 的结果,请取消下面一行代码的注释。
# print(model$bottlenecks$ce_fdh)


# --- 3.3 可视化:散点图与天花板线 ---
# 生成每个条件变量(X)与结果变量(Y)的散点图,并绘制天花板线。
# 这是NCA分析的核心可视化部分。
cat("--- (C) 生成散点图... ---\n")
nca_output(model, plots = TRUE, summaries = FALSE, test = FALSE, bottlenecks = FALSE)

# 在 RStudio 的 "Plots" 面板中,您可以点击箭头来逐一查看每个图表。
cat("散点图已在 RStudio 的 'Plots' 窗口中生成。\n")
cat("请在 Plots 面板中手动使用“Export”按钮保存您需要的图表。\n\n")
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--------------------------------------------------------------------------------
NCA Parameters : Contractual detail - Innovation
--------------------------------------------------------------------------------

Number of observations 48
Scope                  15.40
Xmin                    1.86
Xmax                    5.71
Ymin                    1.00
Ymax                    5.00

                  ce_fdh cr_fdh
Ceiling zone       3.654  2.893
Effect size        0.237  0.188
# above            0      2
c-accuracy       100%    95.8%
Fit              100%    79.2%
p-value            0.008  0.009
p-accuracy         0.002  0.002

Slope                     0.544
Intercept                 2.214
Abs. ineff.       10.690  9.614
Rel. ineff.       69.416 62.428
Condition ineff.  22.078 15.298
Outcome ineff.    60.750 55.642


--------------------------------------------------------------------------------
NCA Parameters : Goodwill trust - Innovation
--------------------------------------------------------------------------------

Number of observations 48
Scope                  10.28
Xmin                    2.43
Xmax                    5.00
Ymin                    1.00
Ymax                    5.00

                  ce_fdh cr_fdh
Ceiling zone       3.152  2.623
Effect size        0.307  0.255
# above            0      4
c-accuracy       100%    91.7%
Fit              100%    83.2%
p-value            0.002  0.004
p-accuracy         0.000  0.001

Slope                     0.472
Intercept                 2.227
Abs. ineff.        6.676  6.099
Rel. ineff.       64.946 59.332
Condition ineff.   1.946  0.000
Outcome ineff.    64.250 59.332


--------------------------------------------------------------------------------
NCA Parameters : Competence trust - Innovation
--------------------------------------------------------------------------------

Number of observations 48
Scope                   8
Xmin                    3
Xmax                    5
Ymin                    1
Ymax                    5

                  ce_fdh cr_fdh
Ceiling zone       2.570  1.713
Effect size        0.321  0.214
# above            0      3
c-accuracy       100%    93.8%
Fit              100%    66.7%
p-value            0.002  0.008
p-accuracy         0.000  0.002

Slope                     0.715
Intercept                 1.283
Abs. ineff.        5.140  4.857
Rel. ineff.       64.250 60.708
Condition ineff.   0.000  0.000
Outcome ineff.    64.250 60.708

Related