![]() ![]() I added integers, instead of doubles inside cumsum(). The function is reduced, which saves about 25% of the time. It produces a bunch of 0/1s, which are rescaled to -1/1s with integer arithmetic. The balanced sides also permit simplifications like remove the ifelse() clause. This example also shows the discrepancy between the permutation-adjusted P values and Benjamini-Hochberg-adjusted P values. instead of splitting y in the loop, and them joining them back in the function (into w), just keep it together. An example where permutation-adjusted P values increase, but (unadjusted) permuted P values decrease: This happens also with a higher number of permutations, e.g. The two sides (ie, x & y) have the same number of elements, so you don't need to count them separately.Because you're simulating your well-behaved bootstrap samples, you can make two simplifying assumptions that the general base function can't: Under a permutation model for statistical tests, proper analyses should employ tests that incorporate the blocking used in the randomization. The 1:B loop has several places to optimize, but I agree that the real consumer is that inner function. This article describes some of the important statistical properties of the commonly used permuted-block design, also known simply as blocked-randomization. A single variable is chosen to be permuted, and the permutation. Z <- cumsum(ifelse(order(w) <= n.x, 1/n.x, -1/n.y)) permute performs permutation tests using Monte Carlo permutations or by enumeration of. #Modified KS-test function (from base package) ![]() Perm.KS.list]= apply(,2,function(y) ks.test.stat(y,y)) #Compute the permutation-based test statistics Samp.dat = matrix(rnorm(n.row*n.col),nrow=n.row) Is there a much faster way? In the future, I'd like to increase B to a larger value. Question This process takes a very long time (about 30-40 minutes) to generate the list. Setup For the purposes of my simulation, I'm generating a list of B=2000 elements, with each element being the output of a permutation procedure in which I first permute the rows of a 200x8000 matrix and for each column, I calculate the Kolmogorov-Smirnov test statistic between the first and second 100 rows (you can think of the first 100 rows as data from one group and the second 100 rows as data from another group). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |