Re: [QCA] Data coercion issue

85 views
Skip to first unread message
Message has been deleted

Adrian Dușa

unread,
Jun 30, 2021, 6:28:18 AM6/30/21
to Wuraola, QCA with R
Dear Wuraola,

Thank you for this message, but as stated in this working group description, to solve a particular problem needs a so-called MRE - minimal reproducible example.
Copy/paste-ing from the group description:

--------------------
Whenever you have a question about how to use a specific function or package, please construct a MRE (minimal reproducible example) that would include:
- a minimal dataset on which to apply your commands
- a minimal code that you have tried and did not yield the expected results
- the nature of the problem

Sometimes, issues might appear for different operating systems, versions of R and versions of the installed packages. When reporting an error, please test your example using the latest development version of the package from my website. If still reporting an error, please include the results from the following two R commands:
print(version)
sessionInfo()

Feel free to attach whatever you believe is relevant (.csv files, or R script files etc) all of your questions and answers will contribute to constructing an archive of potential topics that future users might be interested in.
--------------------

Best wishes,
Adrian

On Wed, 30 Jun 2021 at 13:16, Wuraola <sayhito...@gmail.com> wrote:

Dear Professor Adrian,

Thank you for your work on the QCA package.

I have been trying to use the QCA package but met with an issue. I have converted my data into fuzzy numbers but when I tried to run either the necessary or sufficiency analysis, I got a message that list cannot be coreced into type double. I read this QCA book written by you https://bookdown.org/dusadrian/QCAbook/Rbasics.html#data-coercion and realized you talked about issues like this and that it pertains to how R works. Based on the instruction in the book, I have ascertained that my data is in numeric form, but I am still facing this issue. I am wondering if you have an idea if this has to do with the QCA pacakge. Below are the codes that I used, the error screenshot and screenshot that shows that my data is in numeric form. I am just wondering if you have an idea of why this is happening with the QCA package despite the fact that my data is in numeric form.

By the way, I read that for other fsqca software, the number of conditions to use in a model is determined by the number of cases due to the difficulty with logical minimization, I wonder if that same rule applies to using QCA package for fsqca.

attach(Article1SecondBatchDataset)
Article1SecondBatchDataset$FF1Fuzzy <- calibrate(FF1, method = "TFR")
Article1SecondBatchDataset$FF2Fuzzy <- calibrate(FF2, method = "TFR")
Article1SecondBatchDataset$FF3Fuzzy <- calibrate(FF3, method = "TFR")
Article1SecondBatchDataset$FF4Fuzzy <- calibrate(FF4, method = "TFR")
Article1SecondBatchDataset$FF5Fuzzy <- calibrate(FF5, method = "TFR")
Article1SecondBatchDataset$FF6Fuzzy <- calibrate(FF6, method = "TFR")
Article1SecondBatchDataset$FF7Fuzzy <- calibrate(FF7, method = "TFR")
Article1SecondBatchDataset$FF8Fuzzy <- calibrate(FF8, method = "TFR")
Article1SecondBatchDataset$FF9Fuzzy <- calibrate(FF9, method = "TFR")
Article1SecondBatchDataset$FF10Fuzzy <- calibrate(FF10, method = "TFR")
Article1SecondBatchDataset$FF11Fuzzy <- calibrate(FF11, method = "TFR")
Article1SecondBatchDataset$FF12Fuzzy <- calibrate(FF12, method = "TFR")
Article1SecondBatchDataset$FF13Fuzzy <- calibrate(FF13, method = "TFR")
Article1SecondBatchDataset$FF14Fuzzy <- calibrate(FF14, method = "TFR")
Article1SecondBatchDataset$FF15Fuzzy <- calibrate(FF15, method = "TFR")
Article1SecondBatchDataset$FF16Fuzzy <- calibrate(FF16, method = "TFR")
Article1SecondBatchDataset$FF17Fuzzy <- calibrate(FF17, method = "TFR")
Article1SecondBatchDataset$FF18Fuzzy <- calibrate(FF18, method = "TFR")
Article1SecondBatchDataset$FF19Fuzzy <- calibrate(FF19, method = "TFR")
Article1SecondBatchDataset$FF20Fuzzy <- calibrate(FF20, method = "TFR")
Article1SecondBatchDataset$FF21Fuzzy <- calibrate(FF21, method = "TFR")
Article1SecondBatchDataset$FF22Fuzzy <- calibrate(FF22, method = "TFR")
Article1SecondBatchDataset$FF23Fuzzy <- calibrate(FF23, method = "TFR")
Article1SecondBatchDataset$ExtensionEffectFuzzy <- calibrate(ExtensionEffect, method = "TFR")

Fuzzy1 <- subset(Article1SecondBatchDataset, select = c("FF1Fuzzy", "FF2Fuzzy", "FF3Fuzzy", "FF4Fuzzy", "FF5Fuzzy", "FF6Fuzzy", "FF7Fuzzy",
                                                        "FF8Fuzzy", "FF9Fuzzy", "FF10Fuzzy", "FF11Fuzzy", "FF12Fuzzy", "FF13Fuzzy",
                                                        "FF14Fuzzy", "FF15Fuzzy", "FF16Fuzzy", "FF17Fuzzy", "FF18Fuzzy", "FF19Fuzzy",
                                                        "FF20Fuzzy", "FF21Fuzzy", "FF22Fuzzy", "FF23Fuzzy", "ExtensionEffectFuzzy"))

sufficiency <- superSubset(Fuzzy1, outcome = "ExtensionEffectFuzzy", neg.out = FALSE,
                           conditions = names(Fuzzy1)[1:23], relation = "sufficiency",
                           incl.cut = 0.10, cov.cut = 0)
Error.PNG


Numeric.PNG

Best Regards.

--
You received this message because you are subscribed to the Google Groups "QCA with R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qcawithr+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qcawithr/c959c308-6fdc-49e8-a85f-a0a1ade3c6b0n%40googlegroups.com.


--
Adrian Dusa
University of Bucharest
Romanian Social Data Archive
Soseaua Panduri nr. 90-92
050663 Bucharest sector 5
Romania
Message has been deleted
Message has been deleted

Adrian Dușa

unread,
Jul 7, 2021, 7:56:41 AM7/7/21
to Wuraola, QCA with R
Dear Wuraola,

I am sorry but still unable to reproduce your problem.
A "minimal" example (50 dplyr commands is anything but minimal) is needed, and most importantly it should be "reproducible".
From your code I read that you import your data from an Excel file: since I do not have access to that particular file, it is impossible for me to reproduce your problem.

Please:
- try to reduce your problem to the simplest possible form
- if many commands are similar, eliminate all but one
- if your (now minimal) example does not produce the error, find that particular command that does produce it, and use (only) that in your example
- do provide a (minimal) dataset: either generate a random one (in which case it should be produced by some R commands), or eliminate any unnecessary rows/columns that would still yield that error

The RStudio version is not useful, the group description mentions the output from the following commands:
print(version)
sessionInfo()



On Wed, 7 Jul 2021 at 13:02, Wuraola <sayhito...@gmail.com> wrote:
I forgot to include my RStudio version: 1.4.1717

On Wednesday, July 7, 2021 at 12:46:34 PM UTC+3 Wuraola wrote:
Dear Professor Adrian,

I used reprex to create the below MRE but it doesn't show like it normally does on stackoverflow, so if its not working, please kindly let me know and I can figure out what to do to send a useable MRE. I have been able to do sufficiency analysis but anytime I try to do necessary analysis, R just shut down. I got this message: "R Session Aborted. R encountered a fatal error. The session was terminated." The main issue now is the solution computation (complex, intermediate and parsimonious). It says that "conditions  do not match the set names from "snames" argument". I posted the whole code here as I don't know if the error is from other parts of the analysis. My QCA version is 3.12 and admisc 0.16. I used Windows 10, version 10.0.19041 and R version 4.1.0 (2021-05-18).I have also attached part of my dataset to this message.  Thanks you so much.

```
#FSQCA
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#>     filter, lag
#> The following objects are masked from 'package:base':
#>
#>     intersect, setdiff, setequal, union
library(readxl)
FSQCATestData <- read_excel("FSQCATestData2.xlsx")
#> Error: `path` does not exist: 'FSQCATestData2.xlsx'
View(FSQCATestData)
#> Error in as.data.frame(x): object 'FSQCATestData' not found

#Convert columns CP and PD to Dummy Variables
attach(FSQCATestData)
#> Error in attach(FSQCATestData): object 'FSQCATestData' not found
FSQCATestData$Xcp <- ifelse(CP == "A", 1, 0)
#> Error in ifelse(CP == "A", 1, 0): object 'CP' not found
FSQCATestData$Xm <- ifelse(PD == "M", 1, 0)
#> Error in ifelse(PD == "M", 1, 0): object 'PD' not found
FSQCATestData$Xt <- ifelse(PD == "T", 1, 0)
#> Error in ifelse(PD == "T", 1, 0): object 'PD' not found
FSQCATestData$Xn <- ifelse(PD == "N", 1, 0)
#> Error in ifelse(PD == "N", 1, 0): object 'PD' not found

#Duplicate FSQCATestData DataFrame
FSQCATestDataNoCPPDcolumns <- data.frame(FSQCATestData)
#> Error in data.frame(FSQCATestData): object 'FSQCATestData' not found
tracemem(FSQCATestDataNoCPPDcolumns)==tracemem(FSQCATestData)
#> Error in eval(expr, envir, enclos): object 'FSQCATestDataNoCPPDcolumns' not found

#Delete CP AND PD Columns from FSQCATestDataNoCPPDcolumns
FSQCATestDataNoCPPDcolumns <- FSQCATestDataNoCPPDcolumns[ , !(names(FSQCATestDataNoCPPDcolumns) %in% c("CP", "PD"))]
#> Error in eval(expr, envir, enclos): object 'FSQCATestDataNoCPPDcolumns' not found

#Convert columns Xcp, Xm, Xt and Xn to integers
library(dplyr)
FSQCATestDataNoCPPDcolumns <- FSQCATestDataNoCPPDcolumns %>%
  mutate_at(vars(Xcp, Xm, Xt, Xn), ~as.integer(as.numeric(.)))
#> Error in tbl_vars_dispatch(x): object 'FSQCATestDataNoCPPDcolumns' not found

#Calibration
library(dplyr)
library(QCA)
#> Loading required package: admisc
#>
#> Attaching package: 'admisc'
#> The following objects are masked from 'package:dplyr':
#>
#>     compute, recode
#>
#> To cite package QCA in publications, please use:
#>   Dusa, Adrian (2019) QCA with R. A Comprehensive Resource.
#>   Springer International Publishing.
#>
#> To run the graphical user interface, use: runGUI()

FSQCATestDataNoCPPDcolumns <- mutate(FSQCATestDataNoCPPDcolumns, FF1Fuzzy = calibrate(FF1, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF2Fuzzy = calibrate(FF2, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF3Fuzzy = calibrate(FF3, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF4Fuzzy = calibrate(FF4, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF5Fuzzy = calibrate(FF5, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF6Fuzzy = calibrate(FF6, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF7Fuzzy = calibrate(FF7, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF8Fuzzy = calibrate(FF8, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF9Fuzzy = calibrate(FF9, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF10Fuzzy = calibrate(FF10, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF11Fuzzy = calibrate(FF11, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF12Fuzzy = calibrate(FF12, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF13Fuzzy = calibrate(FF13, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF14Fuzzy = calibrate(FF14, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF15Fuzzy = calibrate(FF15, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF16Fuzzy = calibrate(FF16, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF17Fuzzy = calibrate(FF17, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF18Fuzzy = calibrate(FF18, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF19Fuzzy = calibrate(FF19, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF20Fuzzy = calibrate(FF20, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF21Fuzzy = calibrate(FF21, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF22Fuzzy = calibrate(FF22, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, FF23Fuzzy = calibrate(FF23, type = "fuzzy", thresholds = "e=4, c=7, i=10", logistic = FALSE, ecdf = TRUE),
                                     FSQCATestDataNoCPPDcolumns, EFFuzzy = calibrate(EF, type = "fuzzy", thresholds = "e=2, c=4, i=6", logistic = FALSE, ecdf = TRUE))
#> Error in mutate(FSQCATestDataNoCPPDcolumns, FF1Fuzzy = calibrate(FF1, : object 'FSQCATestDataNoCPPDcolumns' not found
                                     
                                                                                       

#Extract the needed data from FSQCATestDataNoCPPDcolumns
attach(FSQCATestDataNoCPPDcolumns)
#> Error in attach(FSQCATestDataNoCPPDcolumns): object 'FSQCATestDataNoCPPDcolumns' not found
Fuzzy1 <- subset(FSQCATestDataNoCPPDcolumns, select = c("Xcp", "Xm", "Xt", "Xn", "FF1Fuzzy", "FF2Fuzzy", "FF3Fuzzy", "FF4Fuzzy", "FF5Fuzzy", "FF6Fuzzy", "FF7Fuzzy", "FF8Fuzzy",
                                                        "FF9Fuzzy", "FF10Fuzzy", "FF11Fuzzy", "FF12Fuzzy", "FF13Fuzzy",  "FF14Fuzzy", "FF15Fuzzy",
                                                        "FF16Fuzzy", "FF17Fuzzy", "FF18Fuzzy", "FF19Fuzzy", "FF20Fuzzy", "FF21Fuzzy", "FF22Fuzzy", "FF23Fuzzy",
                                                        "EFFuzzy"))
#> Error in subset(FSQCATestDataNoCPPDcolumns, select = c("Xcp", "Xm", "Xt", : object 'FSQCATestDataNoCPPDcolumns' not found


#Necessary Analysis
#attach(Fuzzy1)
necessary <- superSubset(Fuzzy1, outcome = "EFFuzzy", neg.out = FALSE,
                           conditions = c("Xcp", "Xm", "Xt", "Xn", "FF1Fuzzy", "FF2Fuzzy",

                                          "FF3Fuzzy", "FF4Fuzzy", "FF5Fuzzy", "FF6Fuzzy",
                                          "FF7Fuzzy", "FF8Fuzzy", "FF9Fuzzy", "FF10Fuzzy",
                                          "FF11Fuzzy", "FF12Fuzzy", "FF13Fuzzy", "FF14Fuzzy",
                                          "FF15Fuzzy", "FF16Fuzzy", "FF17Fuzzy", "FF18Fuzzy",
                                          "FF19Fuzzy", "FF20Fuzzy", "FF21Fuzzy", "FF22Fuzzy",
                                          "FF23Fuzzy"),
                           relation = "necessity",

                           incl.cut = 0.10, cov.cut = 0)
#> Error in is.data.frame(x): object 'Fuzzy1' not found

                         
#Sufficiency Analysis
attach(Fuzzy1)
#> Error in attach(Fuzzy1): object 'Fuzzy1' not found
sufficiency <- superSubset(Fuzzy1, outcome = "EFFuzzy", neg.out = FALSE,
                           conditions = c("Xcp", "Xm", "Xt", "Xn", "FF1Fuzzy", "FF2Fuzzy",

                                          "FF3Fuzzy", "FF4Fuzzy", "FF5Fuzzy", "FF6Fuzzy",
                                          "FF7Fuzzy", "FF8Fuzzy", "FF9Fuzzy", "FF10Fuzzy",
                                          "FF11Fuzzy", "FF12Fuzzy", "FF13Fuzzy", "FF14Fuzzy",
                                          "FF15Fuzzy", "FF16Fuzzy", "FF17Fuzzy", "FF18Fuzzy",
                                          "FF19Fuzzy", "FF20Fuzzy", "FF21Fuzzy", "FF22Fuzzy",
                                          "FF23Fuzzy"),
                           relation = "sufficiency",
                           incl.cut = 0.10, cov.cut = 0)
#> Error in is.data.frame(x): object 'Fuzzy1' not found
sufficiency
#> Error in eval(expr, envir, enclos): object 'sufficiency' not found

#TruthTable
FsqcaTruthTable <- truthTable(Fuzzy1, outcome = "EFFuzzy", neg.out = FALSE,
                              conditions = c("Xcp", "Xm", "Xt", "Xn", "FF1Fuzzy", "FF2Fuzzy",

                                             "FF3Fuzzy", "FF4Fuzzy", "FF5Fuzzy", "FF6Fuzzy",
                                             "FF7Fuzzy", "FF8Fuzzy", "FF9Fuzzy", "FF10Fuzzy",
                                             "FF11Fuzzy", "FF12Fuzzy", "FF13Fuzzy", "FF14Fuzzy",
                                             "FF15Fuzzy", "FF16Fuzzy", "FF17Fuzzy", "FF18Fuzzy",
                                             "FF19Fuzzy", "FF20Fuzzy", "FF21Fuzzy", "FF22Fuzzy",
                                             "FF23Fuzzy"), n.cut = 1, incl.cut = 0.850,
                              complete = TRUE, show.cases = FALSE, sort.by = c("incl", "n"), decreasing = TRUE)
#> Error in is.data.frame(x): object 'Fuzzy1' not found
FsqcaTruthTable
#> Error in eval(expr, envir, enclos): object 'FsqcaTruthTable' not found
                                    
                                            
#Complex solutions
#FsqcaComplexSolution <- minimize(FsqcaTruthTable, explain = "1", include = "1", details = TRUE)
library(QCA)
FsqcaComplexSolution <- minimize(FsqcaTruthTable, explain = "1", include = "1", details = TRUE)
#> Error in minimize(FsqcaTruthTable, explain = "1", include = "1", details = TRUE): object 'FsqcaTruthTable' not found
FsqcaComplexSolution
#> Error in eval(expr, envir, enclos): object 'FsqcaComplexSolution' not found

#Parsimonious solutions
FsqcaParsimoniousSolution <- minimize(FsqcaTruthTable, include = "?", row.dom = FALSE, details = TRUE)
#> Error in minimize(FsqcaTruthTable, include = "?", row.dom = FALSE, details = TRUE): object 'FsqcaTruthTable' not found
FsqcaParsimoniousSolution
#> Error in eval(expr, envir, enclos): object 'FsqcaParsimoniousSolution' not found

#Intermediate solution
FsqcaIntermediateSolution <- minimize(FsqcaTruthTable, include = "?", dir.exp = c(""), details = TRUE)
#> Error in minimize(FsqcaTruthTable, include = "?", dir.exp = c(""), details = TRUE): object 'FsqcaTruthTable' not found
FsqcaIntermediateSolution
#> Error in eval(expr, envir, enclos): object 'FsqcaIntermediateSolution' not found
```

Ingo Rohlfing

unread,
Jul 7, 2021, 4:52:53 PM7/7/21
to qcaw...@googlegroups.com

Dear Wuraola,

I might have gotten lost in the code, but it looks to me like the data file does not get read into RStudio in the first place. As a consequence, all commands using the data throw error messages.

FSQCATestData <- read_excel("FSQCATestData2.xlsx")
#> Error: `path` does not exist: 'FSQCATestData2.xlsx'

This suggests that the working directory you are working with is not the one where the Excel file sits. Type getwd() in the console to see what the working directory is and whether this is the folder that hosts the file. If not, you have to change the working directory to this folder.

http://www.sthda.com/english/wiki/running-rstudio-and-setting-up-your-working-directory-easy-r-programming#change-your-working-directory

Regards

Ingo Rohlfing

To view this discussion on the web visit https://groups.google.com/d/msgid/qcawithr/CAJ%3D0CtB7-GbeA8pX5CxSPY4wM7wmHwu8941Zu31WsnDkH4NuTg%40mail.gmail.com.
-- 
Ingo Rohlfing
Professor for Methods of Comparative Political Research
Cologne Center for Comparative Politics
Universität zu Köln
office: Herbert-Lewin-Str. 2 (IBW-Gebäude), room 313.c
phone: +4922147089973
fax: +492214702889
Albertus-Magnus-Platz
50923 Köln
http://ingorohlfing.wordpress.com
Reply all
Reply to author
Forward
0 new messages