[Qca-commits] r11 - in pkg: . tests tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 16 10:15:30 CEST 2014


Author: dusadrian
Date: 2014-06-16 10:15:30 +0200 (Mon, 16 Jun 2014)
New Revision: 11

Added:
   pkg/tests/
   pkg/tests/Examples/
   pkg/tests/Examples/QCA-Ex.Rout.save
Log:
adding automatic tests file, to check against at the next build

Added: pkg/tests/Examples/QCA-Ex.Rout.save
===================================================================
--- pkg/tests/Examples/QCA-Ex.Rout.save	                        (rev 0)
+++ pkg/tests/Examples/QCA-Ex.Rout.save	2014-06-16 08:15:30 UTC (rev 11)
@@ -0,0 +1,2474 @@
+
+R version 3.1.0 (2014-04-10) -- "Spring Dance"
+Copyright (C) 2014 The R Foundation for Statistical Computing
+Platform: x86_64-apple-darwin13.1.0 (64-bit)
+
+R is free software and comes with ABSOLUTELY NO WARRANTY.
+You are welcome to redistribute it under certain conditions.
+Type 'license()' or 'licence()' for distribution details.
+
+  Natural language support but running in an English locale
+
+R is a collaborative project with many contributors.
+Type 'contributors()' for more information and
+'citation()' on how to cite R or R packages in publications.
+
+Type 'demo()' for some demos, 'help()' for on-line help, or
+'help.start()' for an HTML browser interface to help.
+Type 'q()' to quit R.
+
+> pkgname <- "QCA"
+> source(file.path(R.home("share"), "R", "examples-header.R"))
+> options(warn = 1)
+> base::assign(".ExTimings", "QCA-Ex.timings", pos = 'CheckExEnv')
+> base::cat("name\tuser\tsystem\telapsed\n", file=base::get(".ExTimings", pos = 'CheckExEnv'))
+> base::assign(".format_ptime",
++ function(x) {
++   if(!is.na(x[4L])) x[1L] <- x[1L] + x[4L]
++   if(!is.na(x[5L])) x[2L] <- x[2L] + x[5L]
++   options(OutDec = '.')
++   format(x[1L:3L], digits = 7L)
++ },
++ pos = 'CheckExEnv')
+> 
+> ### * </HEADER>
+> library('QCA')
+
+Please cite the QCA package as:
+  Dusa, Adrian and Alrik Thiem (2014). QCA: A Package for Qualitative
+  Comparative Analysis. R package version 1.1-3. URL
+  http://CRAN.R-project.org/package=QCA
+
+A complete BibTeX reference is provided by:
+  citation("QCA")
+
+> 
+> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
+> cleanEx()
+> nameEx("allExpressions")
+> ### * allExpressions
+> 
+> flush(stderr()); flush(stdout())
+> 
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: allExpressions
+> ### Title: Create Implicant Matrices
+> ### Aliases: allExpressions
+> ### Keywords: functions
+> 
+> ### ** Examples
+> 
+> # three condition variables with two values each;
+> # first row is empty set
+> allExpressions(noflevels = rep(2, 3))
+
+ 1                
+ 2              0 
+ 3              1 
+ 4         0      
+ 5         0    0 
+ 6         0    1 
+ 7         1      
+ 8         1    0 
+ 9         1    1 
+10    0           
+11    0         0 
+12    0         1 
+13    0    0      
+14    0    0    0 
+15    0    0    1 
+16    0    1      
+17    0    1    0 
+18    0    1    1 
+19    1           
+20    1         0 
+21    1         1 
+22    1    0      
+23    1    0    0 
+24    1    0    1 
+25    1    1      
+26    1    1    0 
+27    1    1    1 
+
+> 
+> # two condition variables with three values each
+> allExpressions(noflevels = rep(3, 2))
+
+ 1           
+ 2         0 
+ 3         1 
+ 4         2 
+ 5    0      
+ 6    0    0 
+ 7    0    1 
+ 8    0    2 
+ 9    1      
+10    1    0 
+11    1    1 
+12    1    2 
+13    2      
+14    2    0 
+15    2    1 
+16    2    2 
+
+> 
+> # arranged differently
+> allExpressions(noflevels = rep(3, 2), arrange = TRUE)
+
+ 1           
+ 2         0 
+ 3         1 
+ 4         2 
+ 5    0      
+ 6    1      
+ 7    2      
+ 8    0    0 
+ 9    0    1 
+10    0    2 
+11    1    0 
+12    1    1 
+13    1    2 
+14    2    0 
+15    2    1 
+16    2    2 
+
+> 
+> # with internal indicator for eliminated values
+> allExpressions(noflevels = rep(3, 2), raw = TRUE)
+
+ 1   -1   -1 
+ 2   -1    0 
+ 3   -1    1 
+ 4   -1    2 
+ 5    0   -1 
+ 6    0    0 
+ 7    0    1 
+ 8    0    2 
+ 9    1   -1 
+10    1    0 
+11    1    1 
+12    1    2 
+13    2   -1 
+14    2    0 
+15    2    1 
+16    2    2 
+
+> 
+> 
+> 
+> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
+> base::cat("allExpressions", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
+> cleanEx()
+> nameEx("calibrate")
+> ### * calibrate
+> 
+> flush(stderr()); flush(stdout())
+> 
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: calibrate
+> ### Title: Calibrate Crisp and Fuzzy Set Variables
+> ### Aliases: calibrate
+> ### Keywords: functions
+> 
+> ### ** Examples
+> 
+> # base variable; random draw from standard normal distribution
+> x <- rnorm(30)
+> 
+> # calibration thresholds
+> th <- quantile(x, seq(from = 0.1, to = 0.9, length = 5))
+> 
+> # calibration of bivalent crisp set variables
+> calibrate(x, thresholds = th[3])
+ [1] 0 0 0 1 1 0 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 1 0 0 1 0 0 0 0 1
+> 
+> # calibration of trivalent crisp set variables
+> calibrate(x, thresholds = c(th[2], th[4]))
+ [1] 0 1 0 2 1 0 1 2 1 0 2 1 0 0 2 1 1 2 2 1 2 2 1 0 2 1 1 0 0 1
+> 
+> # fuzzy-set calibration (positive end-point concept, linear)
+> plot(x, calibrate(x, type = "fuzzy", thresholds = c(th[1], th[3], th[5])), 
++   ylab = "Fuzzy Set Membership")
+> 
+> # fuzzy-set calibration (positive and corresponding negative
+> # end-point concept, logistic)
+> plot(x, calibrate(x, type = "fuzzy", thresholds = c(th[1], th[3], th[5]), 
++   logistic = TRUE, idm = 0.99), ylab = "Fuzzy Set Membership")
+> points(x, calibrate(x, type = "fuzzy", thresholds = c(th[5], th[3], th[1]),
++   logistic = TRUE, idm = 0.99))
+> 
+> # fuzzy-set calibration (positive end-point concept, ECDF)
+> plot(x, calibrate(x, type = "fuzzy", thresholds = c(th[1], th[3], th[5]), 
++   ecdf = TRUE), ylab = "Fuzzy Set Membership")
+> 
+> # fuzzy-set calibration (negative end-point concept, s-shaped)
+> plot(x, calibrate(x, type = "fuzzy", thresholds = c(th[5], th[3], th[1]), 
++   p = 2, q = 2), ylab = "Fuzzy Set Membership")
+> 
+> # fuzzy-set calibration (positive mid-point concept, triangular)
+> plot(x, calibrate(x, type = "fuzzy", thresholds = th[c(1,2,3,3,4,5)]),
++   ylab = "Fuzzy Set Membership")
+> 
+> # fuzzy-set calibration (negative mid-point concept, bell-shaped)
+> plot(x, calibrate(x, type = "fuzzy", thresholds = th[c(3,2,1,5,4,3)],
++   p = 3, q = 3), ylab = "Fuzzy Set Membership")
+> 
+> 
+> 
+> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
+> base::cat("calibrate", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
+> cleanEx()
+> nameEx("createMatrix")
+> ### * createMatrix
+> 
+> flush(stderr()); flush(stdout())
+> 
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: createMatrix
+> ### Title: Create Configuration and Implicant Matrices
+> ### Aliases: createMatrix
+> ### Keywords: functions
+> 
+> ### ** Examples
+> 
+> # a configuration matrix with three bivalent condition variables
+> noflevels <- rep(2, 3)
+> createMatrix(noflevels)
+     [,1] [,2] [,3]
+[1,]    0    0    0
+[2,]    0    0    1
+[3,]    0    1    0
+[4,]    0    1    1
+[5,]    1    0    0
+[6,]    1    0    1
+[7,]    1    1    0
+[8,]    1    1    1
+> 
+> # with logical values
+> createMatrix(noflevels, logical = TRUE)
+      [,1]  [,2]  [,3]
+[1,] FALSE FALSE FALSE
+[2,] FALSE FALSE  TRUE
+[3,] FALSE  TRUE FALSE
+[4,] FALSE  TRUE  TRUE
+[5,]  TRUE FALSE FALSE
+[6,]  TRUE FALSE  TRUE
+[7,]  TRUE  TRUE FALSE
+[8,]  TRUE  TRUE  TRUE
+> 
+> # its implicant matrix ("-1" stands for an eliminated value)
+> createMatrix(noflevels + 1) - 1
+      [,1] [,2] [,3]
+ [1,]   -1   -1   -1
+ [2,]   -1   -1    0
+ [3,]   -1   -1    1
+ [4,]   -1    0   -1
+ [5,]   -1    0    0
+ [6,]   -1    0    1
+ [7,]   -1    1   -1
+ [8,]   -1    1    0
+ [9,]   -1    1    1
+[10,]    0   -1   -1
+[11,]    0   -1    0
+[12,]    0   -1    1
+[13,]    0    0   -1
+[14,]    0    0    0
+[15,]    0    0    1
+[16,]    0    1   -1
+[17,]    0    1    0
+[18,]    0    1    1
+[19,]    1   -1   -1
+[20,]    1   -1    0
+[21,]    1   -1    1
+[22,]    1    0   -1
+[23,]    1    0    0
+[24,]    1    0    1
+[25,]    1    1   -1
+[26,]    1    1    0
+[27,]    1    1    1
+> 
+> # a configuration matrix (the second variable has three values) 
+> noflevels <- c(2, 3, 2)
+> createMatrix(noflevels)
+      [,1] [,2] [,3]
+ [1,]    0    0    0
+ [2,]    0    0    1
+ [3,]    0    1    0
+ [4,]    0    1    1
+ [5,]    0    2    0
+ [6,]    0    2    1
+ [7,]    1    0    0
+ [8,]    1    0    1
+ [9,]    1    1    0
+[10,]    1    1    1
+[11,]    1    2    0
+[12,]    1    2    1
+> 
+> # its implicants matrix
+> createMatrix(noflevels + 1) - 1
+      [,1] [,2] [,3]
+ [1,]   -1   -1   -1
+ [2,]   -1   -1    0
+ [3,]   -1   -1    1
+ [4,]   -1    0   -1
+ [5,]   -1    0    0
+ [6,]   -1    0    1
+ [7,]   -1    1   -1
+ [8,]   -1    1    0
+ [9,]   -1    1    1
+[10,]   -1    2   -1
+[11,]   -1    2    0
+[12,]   -1    2    1
+[13,]    0   -1   -1
+[14,]    0   -1    0
+[15,]    0   -1    1
+[16,]    0    0   -1
+[17,]    0    0    0
+[18,]    0    0    1
+[19,]    0    1   -1
+[20,]    0    1    0
+[21,]    0    1    1
+[22,]    0    2   -1
+[23,]    0    2    0
+[24,]    0    2    1
+[25,]    1   -1   -1
+[26,]    1   -1    0
+[27,]    1   -1    1
+[28,]    1    0   -1
+[29,]    1    0    0
+[30,]    1    0    1
+[31,]    1    1   -1
+[32,]    1    1    0
+[33,]    1    1    1
+[34,]    1    2   -1
+[35,]    1    2    0
+[36,]    1    2    1
+> 
+> 
+> 
+> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
+> base::cat("createMatrix", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
+> cleanEx()
+> nameEx("deMorgan")
+> ### * deMorgan
+> 
+> flush(stderr()); flush(stdout())
+> 
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: deMorgan
+> ### Title: Negate Set-Theoretic Expressions using DeMorgan's Laws
+> ### Aliases: deMorgan is.deMorgan
+> ### Keywords: functions
+> 
+> ### ** Examples
+> 
+> # example from Ragin (1987, p.99)
+> deMorgan("AC + B~C")
+
+S1: AC + B~C 
+N1: ~A~B + ~AC + ~B~C 
+
+> 
+> # with different intersection operators
+> deMorgan("A*C + B*~C", prod.split = "*")
+
+S1: A*C + B*~C 
+N1: ~A*~B + ~A*C + ~B*~C 
+
+> deMorgan("A&C + B&~C", prod.split = "&")
+
+S1: A&C + B&~C 
+N1: ~A&~B + ~A&C + ~B&~C 
+
+> 
+> # use solution object of class "qca" returned by eqmcc() function; 
+> # even with multiple solutions
+> data(d.Kro)
+> Kro.sol <- eqmcc(d.Kro, outcome = "WNP", include = "?")
+> deMorgan(Kro.sol)
+
+S1: WS + ES*WM + QU*LP + WM*LP 
+N1: es*lp*ws + qu*wm*ws + lp*wm*ws 
+
+S2: WS + ES*WM + QU*LP + es*LP 
+N2: es*lp*ws + ES*qu*wm*ws + lp*wm*ws 
+
+> 
+> 
+> 
+> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
+> base::cat("deMorgan", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
+> cleanEx()
+> nameEx("demoChart")
+> ### * demoChart
+> 
+> flush(stderr()); flush(stdout())
+> 
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: demoChart
+> ### Title: Create Prime Implicant Charts
+> ### Aliases: demoChart
+> ### Keywords: functions
+> 
+> ### ** Examples
+> 
+> # simple PI chart, formatted using internal function prettyTable();
+> PI <- c("A", "B", "c")
+> CO <- c("ABC", "Abc", "AbC", "aBc")
+> chart <- demoChart(PI, CO)
+> prettyTable(chart)
+
+  ABC Abc AbC aBc
+A  x   x   x   - 
+B  x   -   -   x 
+c  -   x   -   x 
+> 
+> # more complex example
+> PI <- c("AB", "BC", "Ac", "aC", "abd", "bcd")
+> CO <- c("ABCD", "ABCd", "ABcD", "ABcd", "AbcD", "Abcd",
++         "aBCD", "aBCd", "abCD", "abCd", "abcd")
+> chart <- demoChart(PI, CO)
+> prettyTable(chart)
+
+    ABCD ABCd ABcD ABcd AbcD Abcd aBCD aBCd abCD abCd abcd
+AB   x    x    x    x    -    -    -    -    -    -    -  
+BC   x    x    -    -    -    -    x    x    -    -    -  
+Ac   -    -    x    x    x    x    -    -    -    -    -  
+aC   -    -    -    -    -    -    x    x    x    x    -  
+abd  -    -    -    -    -    -    -    -    -    x    x  
+bcd  -    -    -    -    -    x    -    -    -    -    x  
+> 
+> # different intersection operators
+> PI <- c("AZ", "BY", "~CX")
+> CO <- c("AZ*BY*CX", "AZ*~BY*~CX", "AZ*~BY*CX", "~AZ*BY*~CX")
+> prettyTable(demoChart(PI, CO, prod.split = "*"))
+
+    AZ*BY*CX AZ*~BY*~CX AZ*~BY*CX ~AZ*BY*~CX
+AZ     x         x          x         -     
+BY     x         -          -         x     
+~CX    -         x          -         x     
+> 
+> CO <- gsub("*", "&", CO, fixed = TRUE)
+> prettyTable(demoChart(PI, CO, prod.split = "&"))
+
+    AZ&BY&CX AZ&~BY&~CX AZ&~BY&CX ~AZ&BY&~CX
+AZ     x         x          x         -     
+BY     x         -          -         x     
+~CX    -         x          -         x     
+> 
+> 
+> 
+> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
+> base::cat("demoChart", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
+> cleanEx()
+> nameEx("eqmcc")
+> ### * eqmcc
+> 
+> flush(stderr()); flush(stdout())
+> 
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: eqmcc
+> ### Title: Minimization with Enhanced Quine-McCluskey Algorithm
+> ### Aliases: eqmcc is.qca
+> ### Keywords: functions
+> 
+> ### ** Examples
+> 
+> # csQCA using Krook (2010)
+> #-------------------------
+> data(d.Kro)
+> head(d.Kro)
+   ES QU WS WM LP WNP
+SE  1  1  1  0  0   1
+FI  1  0  1  0  0   1
+NO  1  1  1  1  1   1
+DK  1  0  1  1  1   1
+NL  1  1  0  1  1   1
+ES  1  1  0  1  0   1
+> 
+> # conservative solution
+> eqmcc(d.Kro, outcome = "WNP")
+
+M1: ES*QU*ws*LP + ES*QU*ws*WM + ES*WS*WM*LP + ES*WS*wm*lp + es*ws*WM*LP <=> WNP
+
+> 
+> # negated outcome, conservative solution
+> eqmcc(d.Kro, outcome = "WNP", neg.out = TRUE)
+
+M1: QU*ws*wm*lp + es*ws*WM*lp + ES*qu*ws*wm*LP <=> wnp
+
+> 
+> # parsimonious solution with details and case names
+> Kro.sp <- eqmcc(d.Kro, outcome = "WNP", include = "?", 
++   details = TRUE, show.cases = TRUE)
+> Kro.sp
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    ES QU WS WM LP OUT n  incl  cases      
+ 3  0  0  0  1  0   0  2  0.000 CA,US      
+ 4  0  0  0  1  1   1  1  1.000 NZ         
+ 9  0  1  0  0  0   0  1  0.000 IT         
+11  0  1  0  1  0   0  4  0.000 AU,GB,FR,IE
+12  0  1  0  1  1   1  1  1.000 DE         
+18  1  0  0  0  1   0  1  0.000 LU         
+21  1  0  1  0  0   1  1  1.000 FI         
+24  1  0  1  1  1   1  1  1.000 DK         
+25  1  1  0  0  0   0  3  0.000 CH,PT,GR   
+26  1  1  0  0  1   1  1  1.000 AT         
+27  1  1  0  1  0   1  1  1.000 ES         
+28  1  1  0  1  1   1  2  1.000 NL,BE      
+29  1  1  1  0  0   1  1  1.000 SE         
+32  1  1  1  1  1   1  2  1.000 NO,IS      
+
+n OUT = 1/0/C: 11/11/0 
+  Total      : 22 
+
+Number of multiple-covered cases: 6 
+
+M1: WS + ES*WM + QU*LP + (WM*LP) <=> WNP 
+M2: WS + ES*WM + QU*LP + (es*LP) <=> WNP 
+
+                        ------------------- 
+          incl   cov.r  cov.u  (M1)   (M2)   cases 
+--------------------------------------------------------------------- 
+1  WS     1.000  0.455  0.182  0.182  0.182  FI; DK; SE; NO,IS 
+2  ES*WM  1.000  0.545  0.091  0.091  0.091  DK; ES; NL,BE; NO,IS 
+3  QU*LP  1.000  0.545  0.091  0.091  0.091  DE; AT; NL,BE; NO,IS 
+--------------------------------------------------------------------- 
+4  WM*LP  1.000  0.636  0.000  0.091         NZ; DE; DK; NL,BE; NO,IS 
+5  es*LP  1.000  0.182  0.000         0.091  NZ; DE 
+--------------------------------------------------------------------- 
+   M1     1.000  1.000 
+   M2     1.000  1.000 
+
+> 
+> # check PI chart
+> Kro.sp$PIchart
+
+          4  12 21 24 26 27 28 29 32
+WS        -  -  x  x  -  -  -  x  x 
+ES*WM     -  -  -  x  -  x  x  -  x 
+QU*LP     -  x  -  -  x  -  x  -  x 
+WM*LP     x  x  -  x  -  -  x  -  x 
+es*LP     x  x  -  -  -  -  -  -  - 
+ES*qu*lp  -  -  x  -  -  -  -  -  - 
+qu*wm*lp  -  -  x  -  -  -  -  -  - 
+
+> 
+> # simplifying assumptions (SAs)
+> Kro.sp$SA
+$S1
+   ES QU WS WM LP
+5   0  0  1  0  0
+6   0  0  1  0  1
+7   0  0  1  1  0
+8   0  0  1  1  1
+10  0  1  0  0  1
+13  0  1  1  0  0
+14  0  1  1  0  1
+15  0  1  1  1  0
+16  0  1  1  1  1
+19  1  0  0  1  0
+20  1  0  0  1  1
+22  1  0  1  0  1
+23  1  0  1  1  0
+30  1  1  1  0  1
+31  1  1  1  1  0
+
+$S2
+   ES QU WS WM LP
+2   0  0  0  0  1
+5   0  0  1  0  0
+6   0  0  1  0  1
+7   0  0  1  1  0
+8   0  0  1  1  1
+10  0  1  0  0  1
+13  0  1  1  0  0
+14  0  1  1  0  1
+15  0  1  1  1  0
+16  0  1  1  1  1
+19  1  0  0  1  0
+20  1  0  0  1  1
+22  1  0  1  0  1
+23  1  0  1  1  0
+30  1  1  1  0  1
+31  1  1  1  1  0
+
+> 
+> # minimized expressions for SAs using fake outcome (FO)
+> for(i in 1:2){
++   print(eqmcc(cbind(Kro.sp$SA[[i]], FO = 1), outcome = "FO"))
++ }  
+
+M1: es*WS + WS*WM*lp + WS*wm*LP + ES*qu*ws*WM + es*QU*wm*LP <=> FO
+
+
+M1: es*WS + WS*WM*lp + WS*wm*LP + es*wm*LP + ES*qu*ws*WM <=> FO
+
+>   
+> # conservative solution with truth table object
+> Kro.tt <- truthTable(d.Kro, outcome = "WNP")
+> Kro.sc <- eqmcc(Kro.tt)
+> Kro.sc
+
+M1: ES*QU*ws*LP + ES*QU*ws*WM + ES*WS*WM*LP + ES*WS*wm*lp + es*ws*WM*LP <=> WNP
+
+> 
+> # fsQCA using Emmenegger (2011)
+> #------------------------------
+> data(d.Emm)
+> head(d.Emm)
+      S    C    L   R   P    V  JSR
+AU 0.00 0.00 0.57 0.2 0.0 1.00 0.14
+AT 0.67 1.00 0.57 1.0 0.8 0.67 0.71
+BE 1.00 0.67 0.43 1.0 1.0 0.67 0.57
+CA 0.00 0.00 0.14 0.2 0.0 1.00 0.14
+DK 0.00 0.67 0.86 0.4 0.4 0.00 0.29
+FI 0.67 1.00 0.71 0.4 0.4 0.00 0.43
+> 
+> # parsimonious solution with details
+> eqmcc(d.Emm, outcome = "JSR", incl.cut1 = 0.9, include = "?", 
++   details = TRUE)
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    S  C  L  R  P  V  OUT n  incl 
+ 2  0  0  0  0  0  1   0  2  0.198
+ 5  0  0  0  1  0  0   0  1  0.581
+10  0  0  1  0  0  1   0  1  0.494
+20  0  1  0  0  1  1   0  2  0.716
+25  0  1  1  0  0  0   0  2  0.839
+27  0  1  1  0  1  0   1  1  0.940
+33  1  0  0  0  0  0   0  2  0.203
+37  1  0  0  1  0  0   1  2  0.977
+47  1  0  1  1  1  0   1  1  1.000
+48  1  0  1  1  1  1   1  1  1.000
+56  1  1  0  1  1  1   1  2  1.000
+57  1  1  1  0  0  0   0  1  0.717
+64  1  1  1  1  1  1   1  1  1.000
+
+n OUT = 1/0/C: 8/11/0 
+  Total      : 19 
+
+M1: SR + (LP) => JSR 
+M2: SR + (Pv) => JSR 
+
+                     ------------------- 
+       incl   cov.r  cov.u  (M1)   (M2)  
+---------------------------------------- 
+1  SR  0.871  0.610  0.231  0.256  0.335 
+---------------------------------------- 
+2  LP  0.979  0.506  0.014  0.152        
+3  Pv  0.950  0.417  0.004         0.142 
+---------------------------------------- 
+   M1  0.883  0.762 
+   M2  0.874  0.752 
+
+> 
+> # intermediate solution
+> Emm.si <- eqmcc(d.Emm, outcome = "JSR", incl.cut1 = 0.9, 
++   include = "?", dir.exp = c(1,1,1,1,1,0), details = TRUE)
+> Emm.si
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    S  C  L  R  P  V  OUT n  incl 
+ 2  0  0  0  0  0  1   0  2  0.198
+ 5  0  0  0  1  0  0   0  1  0.581
+10  0  0  1  0  0  1   0  1  0.494
+20  0  1  0  0  1  1   0  2  0.716
+25  0  1  1  0  0  0   0  2  0.839
+27  0  1  1  0  1  0   1  1  0.940
+33  1  0  0  0  0  0   0  2  0.203
+37  1  0  0  1  0  0   1  2  0.977
+47  1  0  1  1  1  0   1  1  1.000
+48  1  0  1  1  1  1   1  1  1.000
+56  1  1  0  1  1  1   1  2  1.000
+57  1  1  1  0  0  0   0  1  0.717
+64  1  1  1  1  1  1   1  1  1.000
+
+n OUT = 1/0/C: 8/11/0 
+  Total      : 19 
+
+p.sol: SR + LP
+
+M1:    SRv + CLPv + SCRP + SLRP => JSR 
+
+         incl   cov.r  cov.u 
+---------------------------- 
+1  SRv   0.990  0.402  0.152 
+2  CLPv  0.964  0.297  0.138 
+3  SCRP  0.965  0.277  0.041 
+4  SLRP  1.000  0.354  0.027 
+---------------------------- 
+   M1    0.965  0.685 
+
+
+p.sol: SR + Pv
+
+M1:    SRv + CLPv + SCRP + SLRP => JSR 
+
+         incl   cov.r  cov.u 
+---------------------------- 
+1  SRv   0.990  0.402  0.152 
+2  CLPv  0.964  0.297  0.138 
+3  SCRP  0.965  0.277  0.041 
+4  SLRP  1.000  0.354  0.027 
+---------------------------- 
+   M1    0.965  0.685 
+
+> 
+> # are the prime implicants also sufficient for the negation of the outcome?
+> pof(Emm.si$i.sol$C1P1$pims, outcome = "JSR", d.Emm, neg.out = TRUE,
++   relation = "suf")
+
+         incl   cov.r  cov.u 
+---------------------------- 
+1  SRv   0.438  0.198  0.031 
+2  CLPv  0.756  0.259  0.108 
+3  SCRP  0.557  0.178  0.000 
+4  SLRP  0.492  0.193  0.000 
+---------------------------- 
+
+> 
+> # check PI chart for intermediate solution;
+> # C1P1: first conservative and first parsimonious solution
+> Emm.si$i.sol$C1P1$PIchart
+
+      27 37 47 48 56 64
+SRv   -  x  x  -  -  - 
+CLPv  x  -  -  -  -  - 
+SCRP  -  -  -  -  x  x 
+SLRP  -  -  x  x  -  x 
+
+> 
+> # same intermediate solution, but not same SAs
+> identical(rownames(Emm.si$SA$S1), rownames(Emm.si$SA$S2))
+[1] FALSE
+> 
+> # check easy counterfactuals; same
+> (EC1 <- Emm.si$i.sol$C1P1$EC)
+   S C L R P V
+31 0 1 1 1 1 0
+39 1 0 0 1 1 0
+45 1 0 1 1 0 0
+53 1 1 0 1 0 0
+55 1 1 0 1 1 0
+59 1 1 1 0 1 0
+61 1 1 1 1 0 0
+63 1 1 1 1 1 0
+> (EC2 <- Emm.si$i.sol$C1P2$EC)
+   S C L R P V
+31 0 1 1 1 1 0
+39 1 0 0 1 1 0
+45 1 0 1 1 0 0
+53 1 1 0 1 0 0
+55 1 1 0 1 1 0
+59 1 1 1 0 1 0
+61 1 1 1 1 0 0
+63 1 1 1 1 1 0
+> identical(rownames(EC1), rownames(EC2))
+[1] TRUE
+> 
+> # minimized expressions for ECs using fake outcome (FO)
+> eqmcc(cbind(Emm.si$i.sol$C1P1$EC, FO = 1), outcome = "FO")
+
+M1: SCRv + CLRPv + SCLPv + SLRpv + SlRPv <=> FO
+
+> 
+> # plot all four prime implicants of the intermediate solution
+> PIsc <- Emm.si$i.sol$C1P1$pims
+> par(mfrow = c(2, 2))
+> for(i in 1:4){
++  plot(PIsc[, i], d.Emm$JSR, pch = 19, ylab = "JSR",
++   xlab = names(PIsc)[i], xlim = c(0, 1), ylim = c(0, 1),
++   main = paste("Prime Implicant", print(i)))
++  mtext(paste(
++   "Inclusion = ", round(Emm.si$i.sol$C1P1$IC$incl.cov$incl[i], 3),
++   "; Coverage = ", round(Emm.si$i.sol$C1P1$IC$incl.cov$cov.r[i], 3)), 
++   cex = 0.7, line = 0.4)
++  abline(h = 0.5, lty = 2, col = gray(0.5))
++  abline(v = 0.5, lty = 2, col = gray(0.5))
++  abline(0, 1)
++ }
+[1] 1
+[1] 2
+[1] 3
+[1] 4
+> 
+> # mvQCA using Hartmann and Kemmerzell (2010)
+> #-------------------------------------------
+> data(d.HK)
+> head(d.HK)
+   C F T R V PB PBI
+AO 0 2 1 2 1  1   1
+BJ 1 2 1 0 0  1   0
+BW 2 0 0 0 0  0   0
+BF 1 2 2 1 0  1   0
+BI 0 2 2 1 1  1   1
+CF 1 1 2 1 0  1   1
+> 
+> # create vector of condition variables
+> conds <- c("C", "F", "T", "V")
+> 
+> # parsimonious solution, with contradictions included
+> HK.sp <- eqmcc(d.HK, outcome = "PB{1}", conditions = conds,
++   incl.cut0 = 0.4, include = c("?", "C"), details = TRUE)
+> HK.sp
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    C  F  T  V  OUT n  incl 
+11  0  1  2  0   1  2  1.000
+12  0  1  2  1   1  1  1.000
+15  0  2  1  0   1  1  1.000
+16  0  2  1  1   1  1  1.000
+17  0  2  2  0   1  6  1.000
+18  0  2  2  1   1  3  1.000
+19  1  0  0  0   1  1  1.000
+27  1  1  1  0   1  1  1.000
+28  1  1  1  1   1  1  1.000
+29  1  1  2  0   1  4  1.000
+33  1  2  1  0   1  2  1.000
+34  1  2  1  1   1  1  1.000
+35  1  2  2  0   1  7  1.000
+37  2  0  0  0   0  2  0.000
+38  2  0  0  1   0  1  0.000
+39  2  0  1  0   1  1  1.000
+40  2  0  1  1   0  1  0.000
+41  2  0  2  0   1  1  1.000
+45  2  1  1  0   1  1  1.000
+47  2  1  2  0   1  1  1.000
+48  2  1  2  1   C  4  0.500
+53  2  2  2  0   1  3  1.000
+54  2  2  2  1   1  2  1.000
+
+n OUT = 1/0/C: 40/4/4 
+  Total      : 48 
+
+M1: C{1} + T{2} + T{1}*V{0} + (C{0}) => PB{1} 
+M2: C{1} + T{2} + T{1}*V{0} + (F{2}) => PB{1} 
+
+                            ------------------- 
+              incl   cov.r  cov.u  (M1)   (M2)  
+----------------------------------------------- 
+1  C{1}       1.000  0.405  0.048  0.071  0.048 
+2  T{2}       0.941  0.762  0.095  0.214  0.167 
+3  T{1}*V{0}  1.000  0.143  0.048  0.048  0.048 
+----------------------------------------------- 
+4  C{0}       1.000  0.333  0.000  0.024        
+5  F{2}       1.000  0.619  0.000         0.024 
+----------------------------------------------- 
+   M1         0.955  1.000 
+   M2         0.955  1.000 
+
+> 
+> # Venn diagram of solution S1;
+> # first extract PI membership scores
+> PIms <- HK.sp$pims
+> 
+> require(VennDiagram)
+Loading required package: VennDiagram
+Loading required package: grid
+> vennHK.suf <- venn.diagram(
++  x = list(
++   "PB{1}" = which(d.HK$PB == 1),
++   "C{0,1}" = which(PIms[, 1] == 1 | PIms[, 2] == 1),
++   "T{2}" = which(PIms[, 4] == 1),
++   "T{1}*V{0}" = which(PIms[, 5] == 1)),
++  filename = NULL,
++  cex = 2.5, cat.cex = 2, cat.pos = c(180, 180, 0, 0),
++  cat.dist = c(0.4, 0.4, 0.12, 0.12),
++  fill = gray(c(0.3, 0.5, 0.7, 0.9))
++ )
+> grid.draw(vennHK.suf)
+> 
+> # which are the two countries in T{2} but not PB{1}?
+> rownames(d.HK[d.HK$T == 2 & d.HK$PB != 1, ])
+[1] "KE" "ZM"
+> 
+> # minimize contradictions (only one contradiction)
+> eqmcc(d.HK, outcome = "PB{1}", conditions = conds, incl.cut0 = 0.4,
++   explain = "C")
+
+M1: C{2}*F{1}*T{2}*V{1}
+
+> 
+> # intermediate solution with directional expectations:
+> # C{1}, F{1,2}, T{2}, V contribute to OUT = 1
+> HK.si <- eqmcc(d.HK, outcome = "PB{1}", conditions = conds,
++   include = "?", dir.exp = c(1, "1;2", 2, 1), details = TRUE)
+> HK.si
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    C  F  T  V  OUT n  incl 
+11  0  1  2  0   1  2  1.000
+12  0  1  2  1   1  1  1.000
+15  0  2  1  0   1  1  1.000
+16  0  2  1  1   1  1  1.000
+17  0  2  2  0   1  6  1.000
+18  0  2  2  1   1  3  1.000
+19  1  0  0  0   1  1  1.000
+27  1  1  1  0   1  1  1.000
+28  1  1  1  1   1  1  1.000
+29  1  1  2  0   1  4  1.000
+33  1  2  1  0   1  2  1.000
+34  1  2  1  1   1  1  1.000
+35  1  2  2  0   1  7  1.000
+37  2  0  0  0   0  2  0.000
+38  2  0  0  1   0  1  0.000
+39  2  0  1  0   1  1  1.000
+40  2  0  1  1   0  1  0.000
+41  2  0  2  0   1  1  1.000
+45  2  1  1  0   1  1  1.000
+47  2  1  2  0   1  1  1.000
+48  2  1  2  1   0  4  0.500
+53  2  2  2  0   1  3  1.000
+54  2  2  2  1   1  2  1.000
+
+n OUT = 1/0/C: 40/8/0 
+  Total      : 48 
+
+p.sol: C{0} + C{1} + F{2} + T{1}*V{0} + T{2}*V{0}
+
+M1:    C{1}*F{1} + C{1}*F{2} + F{2}*T{2} + C{0}*F{1}*T{2} + C{0}*F{2}*T{1} +
+       C{2}*T{1}*V{0} + C{2}*T{2}*V{0} + (C{1}*T{0}) => PB{1} 
+M2:    C{1}*F{1} + C{1}*F{2} + F{2}*T{2} + C{0}*F{1}*T{2} + C{0}*F{2}*T{1} +
+       C{2}*T{1}*V{0} + C{2}*T{2}*V{0} + (C{1}*V{0}) => PB{1} 
+                                 ------------------- 
+                   incl   cov.r  cov.u  (M1)   (M2)  
+---------------------------------------------------- 
+1  C{1}*F{1}       1.000  0.143  0.024  0.143  0.024 
+2  C{1}*F{2}       1.000  0.238  0.024  0.071  0.024 
+3  F{2}*T{2}       1.000  0.500  0.262  0.262  0.262 
+4  C{0}*F{1}*T{2}  1.000  0.071  0.071  0.071  0.071 
+5  C{0}*F{2}*T{1}  1.000  0.048  0.048  0.048  0.048 
+6  C{2}*T{1}*V{0}  1.000  0.048  0.048  0.048  0.048 
+7  C{2}*T{2}*V{0}  1.000  0.119  0.048  0.048  0.048 
+---------------------------------------------------- 
+8  C{1}*T{0}       1.000  0.024  0.000  0.024        
+9  C{1}*V{0}       1.000  0.357  0.000         0.024 
+---------------------------------------------------- 
+   M1              1.000  0.952 
+   M2              1.000  0.952 
+
+> 
+> # mvQCA using Sager and Andereggen (2012)
+> #----------------------------------------
+> data(d.SA)
+> head(d.SA)
+     FED FIN URB GER HIS COO PRO DIS EXP ACC
+Lung   2   1   0   1   0   1   0   0   0   1
+Pfyn   1   1   0   1   1   1   1   1   1   1
+Sol1   0   1   1   1   1   1   1   1   1   1
+Sol2   0   1   1   1   1   1   1   1   1   1
+ZurW   1   1   1   1   0   0   1   1   1   1
+TrB1   1   1   1   1   0   0   1   1   0   0
+> 
+> # directional expectation of FED{0} leads to non-simplifying
+> # easy counterfactual (see Thiem 2014 for more details)
+> SA.si <- eqmcc(d.SA, outcome = "ACC{1}", conditions = names(d.SA)[1:5],
++   include = "?", dir.exp = c(0,1,0,1,1), details = TRUE)
+> SA.si
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    FED FIN URB GER HIS OUT n  incl 
+ 6   0   0   1   0   1   0  1  0.000
+14   0   1   1   0   1   1  1  1.000
+16   0   1   1   1   1   1  2  1.000
+20   1   0   0   1   1   0  1  0.000
+22   1   0   1   0   1   0  2  0.000
+23   1   0   1   1   0   1  1  1.000
+24   1   0   1   1   1   0  2  0.500
+27   1   1   0   1   0   0  1  0.000
+28   1   1   0   1   1   1  2  1.000
+30   1   1   1   0   1   0  2  0.500
+31   1   1   1   1   0   0  3  0.333
+32   1   1   1   1   1   1  1  1.000
+35   2   0   0   1   0   1  1  1.000
+43   2   1   0   1   0   1  1  1.000
+
+n OUT = 1/0/C: 9/12/0 
+  Total      : 21 
+
+p.sol: FED{2} + FED{0}*FIN{1} + FIN{0}*HIS{0} + FIN{1}*GER{1}*HIS{1}
+
+M1:    FED{0}*FIN{1}*HIS{1} + FED{2}*URB{0}*GER{1} +
+       FED{1}*FIN{0}*GER{1}*HIS{0} + FED{1}*FIN{1}*GER{1}*HIS{1} => ACC{1} 
+
+                                incl   cov.r  cov.u 
+--------------------------------------------------- 
+1  FED{0}*FIN{1}*HIS{1}         1.000  0.250  0.250 
+2  FED{2}*URB{0}*GER{1}         1.000  0.167  0.167 
+3  FED{1}*FIN{0}*GER{1}*HIS{0}  1.000  0.083  0.083 
+4  FED{1}*FIN{1}*GER{1}*HIS{1}  1.000  0.250  0.250 
+--------------------------------------------------- 
+   M1                           1.000  0.750 
+
+> 
+> SA.si$i.sol$C1P1$NSEC
+  FED FIN URB GER HIS
+7   0   0   1   1   0
+> 
+> # tQCA using Ragin and Strand (2008)
+> #-----------------------------------
+> data(d.RS)
+> head(d.RS)
+  P E A S EBA REC
+a 1 1 1 1   1   1
+b 1 1 1 1   1   1
+c 1 1 1 1   0   1
+d 1 1 1 0   1   1
+e 1 1 1 0   1   1
+f 1 1 0 1   -   1
+> 
+> # conservative solution with details and case names;
+> # auxiliary temporal order condition "EBA" automatically excluded 
+> # from parameters of fit
+> eqmcc(d.RS, outcome = "REC", details = TRUE, show.cases = TRUE)
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    P  E  A  S  EBA OUT n  incl  cases
+ 3  0  0  0  0   -   0  3  0.000 o,p,q
+15  0  1  0  0   -   0  1  0.000 n    
+22  0  1  1  1   0   1  1  1.000 m    
+27  1  0  0  0   -   0  1  0.000 l    
+30  1  0  0  1   -   0  3  0.000 i,j,k
+36  1  0  1  1   -   0  2  0.000 g,h  
+42  1  1  0  1   -   1  1  1.000 f    
+44  1  1  1  0   1   1  2  1.000 d,e  
+46  1  1  1  1   0   1  1  1.000 c    
+47  1  1  1  1   1   1  2  1.000 a,b  
+
+n OUT = 1/0/C: 7/10/0 
+  Total      : 17 
+
+Number of multiple-covered cases: 3 
+
+M1: P*E*S + E*A*S*eba + P*E*A*EBA <=> REC
+
+              incl   cov.r  cov.u  cases 
+-------------------------------------------- 
+1  P*E*S      1.000  0.571  0.143  f; c; a,b 
+2  E*A*S*eba  1.000  0.571  0.143  m; c 
+3  P*E*A*EBA  1.000  0.714  0.286  d,e; a,b 
+-------------------------------------------- 
+   M1         1.000  1.000 
+
+> 
+> # QCA path models ("causal chain" in CNA); data from Baumgartner (2009);
+> # note that CNA and QCA results are not always equal because CNA applies a
+> # different concept of the truth table that does not take each configuration's
+> # inclusion score into consideration before minimization
+> #-----------------------------------------------------------------------------
+> d.Bau <- data.frame(
++   U = c(1,1,1,1,0,0,0,0), D = c(1,1,0,0,1,1,0,0),
++   L = c(1,1,1,1,1,1,0,0), G = c(1,0,1,0,1,0,1,0),
++   E = c(1,1,1,1,1,1,1,0),
++   row.names = letters[1:8])
+> head(d.Bau)
+  U D L G E
+a 1 1 1 1 1
+b 1 1 1 0 1
+c 1 0 1 1 1
+d 1 0 1 0 1
+e 0 1 1 1 1
+f 0 1 1 0 1
+> 
+> # with multiple outcomes, no solution details are printed;
+> # "causal-chain structure": (D + U <=> L) * (G + L <=> E)
+> # "common-cause structure": (D + U <=> L) * (G + D + U <=> E)
+> Bau.cna <- eqmcc(d.Bau, outcome = names(d.Bau), relation = "sufnec", 
++   include = "?", min.dis = FALSE)
+> Bau.cna
+
+There is no solution for outcome "U".
+
+There is no solution for outcome "D".
+
+M1: D + U <=> L
+
+There is no solution for outcome "G".
+
+
+M1: G + (L) <=> E 
+M2: G + (D + U) <=> E 
+
+
+> 
+> # get the truth table, solution details and case names for outcome "E"
+> print(Bau.cna$E, details = TRUE, show.cases = TRUE)
+
+  OUT: outcome value
+    n: number of cases in configuration
+ incl: sufficiency inclusion score
+
+    U  D  L  G  OUT n  incl 
+ 1  0  0  0  0   0  1  0.000
+ 2  0  0  0  1   1  1  1.000
+ 7  0  1  1  0   1  1  1.000
+ 8  0  1  1  1   1  1  1.000
+11  1  0  1  0   1  1  1.000
+12  1  0  1  1   1  1  1.000
+15  1  1  1  0   1  1  1.000
+16  1  1  1  1   1  1  1.000
+
+n OUT = 1/0/C: 7/1/0 
+  Total      : 8 
+
+Number of multiple-covered cases: 3 
+
+M1: G + (L) <=> E 
+M2: G + (D + U) <=> E 
+
+                     ------------------- 
+       incl   cov.r  cov.u  (M1)   (M2)   cases 
+---------------------------------------------------------- 
+1  G   1.000  0.571  0.143  0.143  0.143  g; e; c; a 
+---------------------------------------------------------- 
+2  D   1.000  0.571  0.000         0.143  f; e; b; a 
+3  L   1.000  0.857  0.000  0.429         f; e; d; c; b; a 
+4  U   1.000  0.571  0.000         0.143  d; c; b; a 
+---------------------------------------------------------- 
+   M1  1.000  1.000 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/qca -r 11


More information about the Qca-commits mailing list