library(lme4) MixLogFaker = function(N=1000,sat=F,nsub=5,nset=5,bias=0.5,nfact=2,ord=T,byit=F) { # MixLogFaker simulates small-scale judgment experiments # and estimates actual probability of getting p < .05 # Defaults # N = 1000: Number of simulations # sat = F: Test for satiation or not (interactions with Order) # nsub = 5: Number of subjects (people making judgments) # nset = 5: Number of sentence sets # bias = 0.5: Higher means greater probability of 1 judgment # nfact = 2: Number of factors (can only be 1 or 2) # ord = T: Include Order as a covariate # byit = F: Don't include Item as random variable nitem = nset*nfact^2 totaln = nsub*nitem ordran = numeric(nitem) ordval = numeric(nitem) if (ord && nfact == 1 && !sat) {nump = 2} if (ord && nfact == 1 && sat) {nump = 3} if (ord && nfact == 2 && !sat) {nump = 4} if (ord && nfact == 2 && sat) {nump = 7} if (!ord && nfact == 1) {nump = 1} if (!ord && nfact == 2) {nump = 3} sig = numeric(nump) for (s in 1:N) { Judgment = as.numeric(runif(totaln)