search for: tempsize

Displaying 1 result from an estimated 1 matches for "tempsize".

Did you mean: tempfile
2000 Sep 20
1
SV: sample from contingency table
I have had the same problem and I wrote this function rmulti <- function(n, size, p) { NrDim <- length(p) if(NrDim<2) stop("The simulated variabel has to be at least 2-dimensional") res <- matrix(data=NA, nrow=n, ncol=NrDim) p <- p/sum(p) TempSize <- size for(i in 1:NrDim) { TempP <- p[i]/sum(p[i:NrDim]) TempBin <- rbinom(n=n, size=TempSize, prob=TempP) TempSize <- TempSize-TempBin res[,i] <- TempBin } return(res) } # Then you can draw 10 samples like this, whith # each row representing a contingency t...