QCA with R
A Comprehensive Resource
2024-02-29
Preamble
The initial idea to write this book emerged in August 2016, with the intention to update the description of package QCA in R. A lot of things have changed since the appearance of the previous user guide four years before, when the package reached version 1.0-0.
Most of the commands are backwards compatible, meaning that all examples from the previous guide still work with the current version of the package. There are some minor but important differences, for instance the function calibrate()
has its default changed from type = "crisp"
to type = "fuzzy"
. Examples still work with previous versions, but for crisp calibration the argument type = "crisp"
should be explicitly specified. All changes, from all versions of the package, are specified in the ChangeLog file which is located in the package’s installation directory (details at chapter 2).
This book is correlated with the release of version 3.17 of the package. There are many new, cutting edge features that were not available before: dramatically improved functionality, and of course a graphical user interface to enable R beginners to use this package using a point and click method. If previously it was all about the command line, now it is all about the interconnection between the command line and the graphical user interface.
Since the first edition of this book was published, a few other improvements have been made to the package, most notably introducing conjunctural directional expectations (to be discussed in section 8.7), and a new method of deriving the intermediate solution without using easy counterfactuals, with the same results. In addition, the argument exclude
was moved from function minimize()
to function truthTable()
, where it better serves its purpose with increased transparency.
Perhaps the most useful and interesting new feature is the function simplify()
which performs a Boolean minimization on a SOP / DNF expression in order to find the simplest possible equivalent. Such expressions are now extensively used when specifying directional expectations, in either traditional atomic way or as conjunctural expectations.
To advance the presentation from section 2.4, the point of the graphical user interface is not to replace the command line, but to offer a more accessible way to learn how to use the commands. No graphical user interface, irrespective how user friendly, can replace the complete flexibility of the command line. The variety of available written functions, from the base R and specifically from package QCA, is beyond the possibilities of any standardized graphical (therefore confined) user interface.
But there is one thing that makes this user interface special: each and every mouse click on the various options trigger an immediate construction of the corresponding command. The real purpose of the graphical user interface is to demonstrate one possible way to write commands, while there are many others that users are invited to discover.
The structure of this book is different from the former user guide. It will of course touch on the same topics and present the same (updated) package, but instead of organizing chapters on the distinction between crisp, multi-value, and fuzzy sets, a better approach is to organize the book on QCA related analyses: calibration, analysis of necessity, analysis of sufficiency, constructing and minimizing a truth table etc.
It has grown much more than a guide, but it is also not intended as a complete theoretical material. This is valid for both R related information (chapter 1 being a very short introduction) and QCA related topics as well. There are entire books to cover each, and this book cannot replace them all but instead it shifts the focus on how to perform QCA using R.
There are dedicated chapters combining theory for all QCA variants (cs, mv and fs, also extensions) and R, with detailed instructions how to perform each of the analyses using both command line and using the new graphical user interface. Readers are nevertheless invited to supplement their knowledge from other sources, most being introduced in the specific sections.
To say that writing this book has been a challenge is an understatement. It started as a challenge, but it has developed into something I definitely did not anticipate. The text in the book is written for an imaginary character with whom I had many interesting discussions emerging from natural questions. This character can be both a QCA expert who is interested in using R, or an R expert who is interested in QCA, or perhaps the most common scenario someone who is neither a QCA, nor an R expert. But the questions are the same:
- What exactly is this? and/or
- How do I do it with R?
Many sections, paragraphs, sometimes down to each word, had to be re-written while conversing with this imaginary character and trying to anticipate what kind of questions and what kind of answers are expected from this book. During all this process of describing and explaining, I have often realized that many things that I took for granted were not exactly trivial. This was practically and invitation to rethink and rewrite the structure of the commands to better answer possible questions, while at the same time increasing the user experience.
Much like a sculptor who has a concrete idea about the potential of a statue to be carved out from a stone, the initial book plan gradually adapted to the new structure to accommodate all ideas that have emerged while writing it. In a way, the book wrote itself, just as the statue that already exists inside the stone and the sculptor only removes the excess material to reveal it. I am extremely pleased to have actively experienced this process.
Naturally, improving the code in the package implied further and better explanations in the book, while describing the concepts many times involved rewriting the code, into an energy draining spiral that lasted for almost an entire year. On top of the book, and on top of the code, every change meant even more additional effort to update the graphical user interface. In the absence of a formal background in programming, writing the package and especially the graphical user interface was a Herculean effort.
In order to circumvent differences between operating systems, the natural choice is to open dialogs into the most universal environment, a web page. Thankfully, using the excellent package shiny made this effort manageable, although I still had to learn HTML, Javascript and SVG in the process. It has now reached a rather stable and easy to manage backend, while the front end is very close to an ideal, combining point and click dialogs with a web-based command line, all in the same workspace.
The only important thing that it still lacks, and will certainly stay on the development list for the next versions, is a code editor. There are a number of very good choices to pick from, but this is something I simply did not have the time to do for this book. Most likely, the next versions of the package will be geared towards completing the graphical user interface.
R is a great environment and few people are aware that it can be used to write books. Not surprisingly, this book was written using R. There are not enough words to describe the amazing work of Yihui Xie and all the team of engineers from RStudio, who provide this public service and especially for the packages knitr, rmarkdown and bookdown that allow this form of HTML, PDF and e-book publication (among others). It made the writing of this book a whole lot easier than I had expected, by automatically transforming the markdown code into LaTeX and finally rendered into an eye-candy PDF version.
In the book, there are many places where theoretical information is exemplified using R commands. These are placed into specific grey boxes, and they have colors associated (for instance all functions have red color, arguments are green and text input is blue). With the exception of very few commands that are only illustrative, all of them have an output which is printed immediately below, using a mono spaced font.
I am deeply thankful to a select group of people who contributed feedback while writing the book, and even provided ideas to further improve the package functionality: to Eva Thomann, Omar Bautista González and Monica Șerban for the very careful reading of the entire book text, and to Ioana-Elena Oana and Carsten Schneider for all their work making the package SetMethods work smoothly with package QCA.
There have been numerous other suggestions, bug reports and feature requests from too many people to mention here, and I very much appreciate all their interest.
This book is dedicated to my wife Adriana Rotar, who has been over patient with me while writing it. I have taken time out from too many common activities, and I am grateful beyond words for being so understanding.