########################################################### ## ## ## Title : Modeling Causal Irrelevance in Evaluations ## ## of Configurational Comparative Methods ## ## Authors: Alrik Thiem and Michael Baumgartner ## ## Script : Alrik Thiem ## ## Date : 3 July 2016 ## ## ## ########################################################### # load package library(QCApro) simulation <- vector(mode = "list", length = 3) nofs <- 1000 # number of samples corr <- c("-", "0", "+") # directions of correlation nofc <- c(40, 80, 160, 320, 640) # number of cases in each sample # takes 10-15 minutes simulation <- lapply(corr, function (x) {lapply(nofc, function (y) { implicIndep("(X1*X2 + X3*X4 <=> Y)*(Z1 + z1)", nofs, y, x)})}) # has Z1 been eliminated in ALL data experiments of a block of tests? series.test <- matrix(sapply(1:length(corr), function (x) {sapply(1:length(nofc), function (y) {simulation[[x]][[y]]$test == "Z1 has been eliminated."})}), ncol = length(corr), dimnames = list(as.character(nofc), corr)) series.test # replace <..> by 1 (corr = "-"), 2 (corr = "0"), or 3 (corr = "+") and <.> by # 1 (sample.n = 40), etc. where required to see individual test components simulation[[<..>]][[<.>]]$tt # underlying truth table simulation[[<..>]][[<.>]]$dat.list # list of data sets simulation[[<..>]][[<.>]]$sol.list # list of corresponding QCA solutions simulation[[<..>]][[<.>]]$cor.list # list of correlations between outcome factor and irrelevant factor simulation[[<..>]][[<.>]]$test # test result of whether the irrelevant factor has been eliminated # code for figure 1 cors <- cbind(rep(nofc, each = nofs), sapply(seq_along(corr), function (x) { sapply(seq_along(nofc), function (y) {cbind(simulation[[c(x, y)]][["cor.list"]])})})) windows(width = 8, height = 4) plot(cors[,2], cors[,1], xlim = c(-1,1), ylim = c(0,700), xlab = "Correlation between Irrelevant Factor and Outcome Factor", main = "", ylab = "Size of Sample", cex = 1.5, pch = 21, bg = grey(0.4), yaxt = "n", xaxt = "n") axis(1, at = seq(-1, 1, by = 0.2), labels = as.character(seq(-1, 1, by = 0.2))) axis(2, at = seq(0,700, by = 100), labels = as.character(seq(0,700, by = 100)), las = 1) points(cors[,4], cors[,1], cex = 1.5, pch = 21, bg = grey(0.4)) points(cors[,3], cors[,1], pch = 21, bg = grey(0.85))