QCAfit - Qualitative comparative analysis

I had to guess without a reprex. See the FAQ. Does the help() example work on your installation and is comparable to your data structure and call?

library(SetMethods)
#> Loading required package: QCA
#> Loading required package: admisc
#> 
#> 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()
#> Loading required package: ggplot2
#> Loading required package: ggrepel
#> Loading required package: stargazer
#> 
#> Please cite as:
#>  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
#>  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
#> 
#> 
#>   To cite package SetMethods in publications use: 
#> 
#>   Oana, Ioana-Elena and Carsten Q. Schneider. 2018. SetMethods: An Add-on R Package for 
#>   Advanced QCA. The R Journal 10(1): 507-33. https://journal.r-project.org/archive/2018/RJ-2018-031/index.html
#>   
#> 
# Generate fake data
set.seed(1234)

a <- runif(100, 0, 1)
b <- runif(100, 0, 1)
c <- runif(100, 0, 1)
y <- runif(100, 0, 1)

# Only one condition, for necessity
QCAfit(a, y, cond.lab = "A")
#>   Cons.Nec Cov.Nec   RoN
#> A    0.593   0.705 0.813
# With three conditions and their negation, for necessity
QCAfit(cbind(a, b, c), y)
#>    Cons.Nec Cov.Nec   RoN
#> a     0.593   0.705 0.813
#> b     0.694   0.682 0.737
#> c     0.653   0.677 0.755
#> ~a    0.721   0.666 0.700
#> ~b    0.611   0.675 0.775
#> ~c    0.674   0.702 0.771
# Only one condition, for sufficiency
QCAfit(a, y, cond.lab = "A", necessity = FALSE)
#> Cons.Suf  Cov.Suf      PRI 
#>    0.705    0.593    0.480

# With three conditions, their negation and negated output, for necessity
QCAfit(cbind(a, b, c), y, neg.out = TRUE)
#>    Cons.Nec Cov.Nec   RoN
#> a     0.609   0.668 0.795
#> b     0.681   0.618 0.699
#> c     0.691   0.661 0.746
#> ~a    0.731   0.624 0.674
#> ~b    0.650   0.662 0.769
#> ~c    0.663   0.638 0.735

# Load the Schneider data:

data(SCHF)

# Get parameters of fit for condition EMP as necessary for outcome EXPORT:

QCAfit(SCHF$EMP, SCHF$EXPORT, cond.lab = "EMP")
#>     Cons.Nec Cov.Nec   RoN
#> EMP     0.58   0.607 0.698

QCAfit(1-SCHF$EMP, SCHF$EXPORT, neg.out=TRUE, cond.lab = "~EMP")
#>      Cons.Nec Cov.Nec   RoN
#> ~EMP    0.545   0.518 0.695

# Obtain the parsimonious solution for outcome "EXPORT":

sol_yp <- minimize(SCHF, outcome = "EXPORT",
                   conditions = c("EMP","BARGAIN","UNI","OCCUP","STOCK", "MA"),
                   incl.cut = .9,
                   include = "?",
                   details = TRUE, show.cases = TRUE)

# Get parameters of fit for the parsimonious solution:

QCAfit(x = sol_yp, y = "EXPORT", necessity = FALSE)
#>                   Cons.Suf Cov.Suf   PRI
#> ~EMP*OCCUP           0.836   0.353 0.596
#> BARGAIN*UNI*STOCK    0.796   0.497 0.665
#> ~OCCUP*STOCK*~MA     0.890   0.374 0.788
#> solution_formula     0.790   0.742 0.675

# Get parameters of fit for truth table rows 2,8, and 10:

QCAfit(x = sol_yp, y = "EXPORT", ttrows=c("2","8","10"), necessity = FALSE)
#>    Cons.Suf Cov.Suf    PRI
#> 2    0.7869  0.0461 0.3158
#> 8    0.9303  0.0899 0.7760
#> 10   0.6615  0.0723 0.1585

# Get parameters of fit for truth table rows 2,8, and 10:

QCAfit(x = sol_yp, y = "EXPORT", ttrows=c("2","8","10"), necessity = FALSE)
#>    Cons.Suf Cov.Suf    PRI
#> 2    0.7869  0.0461 0.3158
#> 8    0.9303  0.0899 0.7760
#> 10   0.6615  0.0723 0.1585

Created on 2023-02-05 with reprex v2.0.2