I am perfectly aware that this question is not an R question, at least not yet, but I have not succeeded in finding what I want in other ways, so ... What I am looking for are two algorithms, preferabley in Pascal, but other languages may do. For (a) systematic (complete) permutations for grouped data with unequal group sizes, and (b) random permutations for the same kind of data. I know of one source: E. S. Edgington (1980): Randomization Tests (program 4.1 and program 4.3), but those are written in Fortran with a lot of GO TO's which probably would not be very efficient even if I managed to manually these programs and do a correct translation. There must be some more modern ones around, but where? I need the algorithms for a program I have written for exploring structural balance in sociometric group structures. Tom +----------------------------------------------------------------+ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185 Fax : +47-5558-9879 | | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | +----------------------------------------------------------------+
Hi r-help-bounces at r-project.org napsal dne 02.11.2007 15:16:37:> I am perfectly aware that this question is not an R question, at least > not yet, but I have not succeeded in finding what I want in other > ways, so ... > > What I am looking for are two algorithms, preferabley in Pascal, but > other languages may do. For (a) systematic (complete) permutations > for grouped data with unequal group sizes, and (b) random permutations > for the same kind of data. I know of one source: E. S. EdgingtonI am not sure if it is what you want but lll <- lapply(split(some vector, group vector), function(x) sample(1:length(x))) gives you a list of systematic permutation of the first vector in each group and you can use it for subsetting your data. for (i in no.of.groups) split(data, group vector)[[i]] [lll[[i]],] Random permutation (if I understand correctly) can be constructed by not exhaustive sampling so you can limit number of samples by size argument to sample function. Regards Petr> (1980): Randomization Tests (program 4.1 and program 4.3), but those > are written in Fortran with a lot of GO TO's which probably would not > be very efficient even if I managed to manually these programs and do > a correct translation. There must be some more modern ones around, > but where? > > I need the algorithms for a program I have written for exploring > structural balance in sociometric group structures. > > Tom > > +----------------------------------------------------------------+ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185 Fax : +47-5558-9879 | > | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | > +----------------------------------------------------------------+ > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
On Fri, 2 Nov 2007, Tom Backer Johnsen wrote:> I am perfectly aware that this question is not an R question, at least > not yet, but I have not succeeded in finding what I want in other > ways, so ... > > What I am looking for are two algorithms, preferabley in Pascal, but > other languages may do. For (a) systematic (complete) permutations > for grouped data with unequal group sizes, and (b) random permutations > for the same kind of data.The "coin" package might be of help here. Option (b) is always possible, (a) might be very slow depending on the size of your data set and the type of test statistic you are evaluating. See vignette("LegoCondInf", package = "coin") to get started. hth, Z> I know of one source: E. S. Edgington > (1980): Randomization Tests (program 4.1 and program 4.3), but those > are written in Fortran with a lot of GO TO's which probably would not > be very efficient even if I managed to manually these programs and do > a correct translation. There must be some more modern ones around, > but where? > > I need the algorithms for a program I have written for exploring > structural balance in sociometric group structures. > > Tom > > +----------------------------------------------------------------+ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185 Fax : +47-5558-9879 | > | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | > +----------------------------------------------------------------+ > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >
Brian S Cade wrote:> Tom: Paul Mielke, emeritus professor at Colorado State University, > probably has some of the most efficient Fortran programs for enumerating > all possible permutations of small sample sizes for grouped comparisons > and Monte Carlo random sampling of the possible permutations for larger > group sizes. The Fortran source code is available off his CSU Statistics > Department web page. The code is for Mielke's multiresponse permutation > procedures (MRPP), which includes permutation versions of ANOVA or t-tests > as a special case.Thank you very much, it may be just what I need. I have just downloaded the source and started looking at them. I'll have to look for a Fortran compiler as well. Alternatively, we've implemented Mielke's code into> our Blossom statistical package, which provides a more user friendly front > end and output than Mielke's programs. This is available at > http://www.fort.usgs.gov/Products/Software/blossom/The main point is that I would like to include the algorithm into my own somewhat dedicated code, currently written in Object Pascal, (Delphi), but I plan to port the code to some open source variant.> My experience with implementing similar permutation tests in software like > R or S-Plus that are optimal for vector computations is that they will > never be as fast as the looping structures that are implemented in the > Fortran programs. And when you are talking about enumerating all > possible permutations, speed becomes a very limiting factor. Mielke's > code will easily do complete enumeration of 2 groups of n=12 ( 2,704,156 > possible combination) in 10 seconds or so (on Windows XP with 2GB memory) > and 2 groups of n =13 (10,400,600 possible combinations) should still be > not unreasonable.That is really impressive! Tom> > Brian > > Brian S. Cade > > U. S. Geological Survey > Fort Collins Science Center > 2150 Centre Ave., Bldg. C > Fort Collins, CO 80526-8818 > > email: brian_cade at usgs.gov > tel: 970 226-9326 > > > > Tom Backer Johnsen <backer at psych.uib.no> > Sent by: r-help-bounces at r-project.org > 11/02/2007 08:16 AM > > To > r-help at stat.math.ethz.ch > cc > > Subject > [R] Permutation test, grouped data > > > > > > > I am perfectly aware that this question is not an R question, at least > not yet, but I have not succeeded in finding what I want in other > ways, so ... > > What I am looking for are two algorithms, preferabley in Pascal, but > other languages may do. For (a) systematic (complete) permutations > for grouped data with unequal group sizes, and (b) random permutations > for the same kind of data. I know of one source: E. S. Edgington > (1980): Randomization Tests (program 4.1 and program 4.3), but those > are written in Fortran with a lot of GO TO's which probably would not > be very efficient even if I managed to manually these programs and do > a correct translation. There must be some more modern ones around, > but where? > > I need the algorithms for a program I have written for exploring > structural balance in sociometric group structures. > > Tom > > +----------------------------------------------------------------+ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185 Fax : +47-5558-9879 | > | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | > +----------------------------------------------------------------+ > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- +----------------------------------------------------------------+ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185 Fax : +47-5558-9879 | | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | +----------------------------------------------------------------+
Brian S Cade wrote:> Tom: Paul Mielke, emeritus professor at Colorado State University, > probably has some of the most efficient Fortran programs for enumerating > all possible permutations of small sample sizes for grouped comparisons > and Monte Carlo random sampling of the possible permutations for larger > group sizes. The Fortran source code is available off his CSU Statistics > Department web page. The code is for Mielke's multiresponse permutation > procedures (MRPP), which includes permutation versions of ANOVA or t-tests > as a special case.But where do I find documentation for the programs? Is that in the Spinger book? Tom +----------------------------------------------------------------+ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185 Fax : +47-5558-9879 | | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | +----------------------------------------------------------------+