On Wed, 7 Nov 2012, Pindar wrote: > when working on my multivariate statistic package I found the following bug > in function msortby: > If one wants to sort an already sorted matrix the matrix elements get though > rearranged. > In the 2-factor Anova with interaction this results in wrong calculations. > > <hansl> > nulldata 24 > #two factor orthogonal Anova > matrix FaktorA={1;1;1;1;1;1;2;2;2;2;2;2;3;3;3;3;3;3;4;4;4;4;4;4} > matrix FaktorB={1;1;2;2;3;3;1;1;2;2;3;3;1;1;2;2;3;3;1;1;2;2;3;3} > matrix > OutputM={69;77;61;67;65;69;79;83;62;64;72;78;80;78;74;76;80;74;75;67;70;62;70;76} > > eval OutputM~FaktorA > eval msortby(OutputM~FaktorA,2) > <hansl>
Hmm, I'm not seeing anything wrong with gretl's output on this. I take it your point is that, since FaktorA is already in sort order, msortby() should be a null operation and the two "evals" above should give the same output -- but that in fact they don't? Here they do give the same. To check explicitly: <hansl> matrix FaktorA={1;1;1;1;1;1;2;2;2;2;2;2;3;3;3;3;3;3;4;4;4;4;4;4} matrix FaktorB={1;1;2;2;3;3;1;1;2;2;3;3;1;1;2;2;3;3;1;1;2;2;3;3} matrix \ OutputM={69;77;61;67;65;69;79;83;62;64;72;78;80;78;74;76; \ 80;74;75;67;70;62;70;76} matrix K = OutputM ~ FaktorA matrix P = msortby(K, 2) Test = K - P print Test </hansl> Here the Test matrix is all zeros. Allin Cottrell