模糊定性比较分析

时间:2014-07-10 19:29:29

标签: r fuzzy-logic truthtable

假设我有以下数据框:

mydata <- data.frame(cond1=c(0.9,0.6,0.9,0.5,0.2,0.2,0.9,0.7,0.1,0.1,0.6),
                     cond2=c(0.7,0.7,0.2,0.9,0.9,0.2,0.2,0.9,0.3,0.4,0.9),
                     cond3=c(0.8,0.9,1,0.3,0.6,0.2,0.3,0.1,0.9,0.1,1),
                     outcome=c(1,0.9,0.8,0.5,0.9,0.5,0.3,0.6,0.4,0.3,0.2))

我加载QCA libray进行模糊定性比较分析:

library(QCA)

然后我构建了真值表:

TT <- truthTable(mydata, outcome = "outcome", incl.cut1 = 0.85,
                    show.cases = TRUE, sort.by = c("incl", "n"))

没问题,但是当我尝试使用以下代码获得复杂解决方案的布尔最小化时:

SC <- eqmcc(TT,details = T, show.cases = T)

我总是收到错误消息:

Error in `[.data.frame`(data, , outcome) : undefined columns selected

我做错了什么?

感谢。

2 个答案:

答案 0 :(得分:1)

该功能似乎存在错误。在某些时候,似乎将结果名称转换为全部大写。因此,如果您将data.frame中的列名称和您在truthTable中使用的列更改为大写&#34; OUTCOME&#34;,它似乎可以正常工作

library(QCA)
mydata <- data.frame(cond1=c(0.9,0.6,0.9,0.5,0.2,0.2,0.9,0.7,0.1,0.1,0.6),
                     cond2=c(0.7,0.7,0.2,0.9,0.9,0.2,0.2,0.9,0.3,0.4,0.9),
                     cond3=c(0.8,0.9,1,0.3,0.6,0.2,0.3,0.1,0.9,0.1,1),
                     OUTCOME=c(1,0.9,0.8,0.5,0.9,0.5,0.3,0.6,0.4,0.3,0.2))


TT <- truthTable(mydata, outcome = "OUTCOME", incl.cut1 = 0.85,
                    show.cases = TRUE, sort.by = c("incl", "n"))

eqmcc(TT,details = T, show.cases = T)

产生

n OUT = 1/0/C: 7/3/0 
  Total      : 10 

Number of multiple-covered cases: 3 

M1: COND3 + COND1*COND2 => OUTCOME

                incl   cov.r  cov.u  cases 
---------------------------------------------------- 
1  COND3        0.758  0.734  0.281  3; 5; 1,2,11; 9 
2  COND1*COND2  0.878  0.562  0.109  8; 1,2,11 
---------------------------------------------------- 
   M1           0.771  0.844 

答案 1 :(得分:0)

在联系软件包开发人员后,他告诉我这是bug,并且已经在QCA的最新版本中得到修复:

https://r-forge.r-project.org/R/?group_id=885

然后我尝试了最新版本,现在它就像一个魅力。