<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Dear Yaroslav,<div><br></div><div>Thanks very much for your help! I wasn't sure if I can use&nbsp;MCNullDist for CrossValidationTransferError in the same way as for TransferError. Now I can make the code much simpler and run much quicker!</div><div><br></div><div>PS, I think the examples in my data should be well independent. It is a slow event-related design. The inter-stimulus interval is at least 9 seconds and only one fMRI volume (acquired at about 9 sec after each stimulus) per stimulus/trial was taken and fed into the classifier, that is, only one example for each stimulus.&nbsp;</div><div>Actually, my purpose of performing a permutation here is to see how the null distribution looks like, i.e., if it is centred at 50%, to confirm that there is no unknown technical problem which shifts the chance level away from 50%. Since my MVPA is run on each subject, the final P value will be determined by performing a t test (against 50%) or non-parametric test (e.g. Wilcoxon signed rank test) on prediction rates across all subjects. Please let me know if there is anything incorrect.</div><div><br></div><div>Best,</div><div>Meng<br><br>&gt; Date: Fri, 11 Mar 2011 22:29:52 -0500<br>&gt; From: debian@onerussian.com<br>&gt; To: pkg-exppsy-pymvpa@lists.alioth.debian.org<br>&gt; Subject: Re: [pymvpa] Cross validation and permutation test<br>&gt; <br>&gt; &gt;    Thanks, Yaroslav, I've had a glance at the tutorial for 0.6 version and<br>&gt; &gt;    it looks like I do have to learn twice... Is there a PDF file of the<br>&gt; &gt;    tutorial? - it would be easier to read and search for specific<br>&gt; &gt;    commands.<br>&gt; <br>&gt; ha -- we just thought noone would be interested in PDF any more , so we<br>&gt; haven't fixed issues emerged while building it... ok -- demand is here, we will<br>&gt; fix it up and let you know<br>&gt; <br>&gt; &gt;    For performing permutation test for cross validation on 0.4 version, if<br>&gt; &gt;    there isn't an easy way to do the permutation directly<br>&gt; &gt;    using CrossValidatedTransferError<br>&gt; <br>&gt; there is -- but then not on per split but on the average error at once:<br>&gt; CrossValidatedTransferError is just yet another Measure so it could take<br>&gt; null_dist as the argument the same as you did for TransferError itself:<br>&gt; <br>&gt;         # Lets do the same for CVTE<br>&gt;         cvte = CrossValidatedTransferError(<br>&gt;             TransferError(clf=l_clf),<br>&gt;             OddEvenSplitter(),<br>&gt;             null_dist=MCNullDist(permutations=num_perm,<br>&gt;                                  tail='left',<br>&gt;                                  enable_states=['dist_samples']))<br>&gt;         cv_err = cvte(train)<br>&gt; <br>&gt; NB this is a snippet from our unittests... for some reason we haven't included<br>&gt; something like that into the examples, e.g.<br>&gt; <br>&gt;  http://v04.pymvpa.org/examples/permutation_test.html<br>&gt; <br>&gt; but there are issues with such testing if your samples might not be fully independent...<br>&gt; <br>&gt; in 0.6 we are going to make it more flexible to allow more adequate permutation<br>&gt; testing - starting from permutting only within training split, and then,<br>&gt; if there is a belief that even that is not enough, permutting chunks labeling<br>&gt; at once, instead of independent samples -- that would allow for possibly more<br>&gt; conservative, but more trustful testing.<br>&gt; <br>&gt; watchout for announcements on the updates of <br>&gt; http://www.pymvpa.org/tutorial_significance.html<br>&gt; <br>&gt; &gt;, is the following code (using TransferError) correct?<br>&gt; <br>&gt; &gt;    nd =<br>&gt; &gt;    MCNullDist(permutations=2500,tail='left',enable_states=['dist_samples']<br>&gt; &gt;    )<br>&gt; &gt;    terr = TransferError(clf,null_dist=nd)<br>&gt; &gt;    cv_index = 0<br>&gt; &gt;    splitter = NFoldSplitter(cvtype=1)<br>&gt; &gt;    for wdata, vdata in splitter(dataset):<br>&gt; &gt;       err = terr(vdata,wdata)<br>&gt; &gt;       Error[SubjIndex,cv_index] = err<br>&gt; &gt;       Pvalue[SubjIndex,cv_index] = terr.null_prob<br>&gt; &gt;       Distribution_normalizedMeanSD = nd.dist_samples<br>&gt; &gt;       nd.clean()<br>&gt; <br>&gt; &gt;       cv_index += 1<br>&gt; <br>&gt; &gt;    #===========<br>&gt; <br>&gt; &gt;    In this way, I can get the null distribution for each split (i.e.<br>&gt; &gt;    dist_samples). The prediction error of the cross-validation is the<br>&gt; &gt;    average of prediction error of all splits, I suppose I will need to<br>&gt; &gt;    generate another null distribution for the mean predication error by<br>&gt; &gt;    sampling from these null distributions of all split and then<br>&gt; &gt;    calculating the mean of the new samples and repeat the procedure for,<br>&gt; &gt;    e.g., 1000 times? Is it correct?<br>&gt; <br>&gt; looks and sounds correct. But once again, if you are not really<br>&gt; interested in per-split assessment, just use the construct above ;-)<br>&gt; <br>&gt; -- <br>&gt; =------------------------------------------------------------------=<br>&gt; Keep in touch                                     www.onerussian.com<br>&gt; Yaroslav Halchenko                 www.ohloh.net/accounts/yarikoptic<br>&gt; <br>&gt; _______________________________________________<br>&gt; Pkg-ExpPsy-PyMVPA mailing list<br>&gt; Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org<br>&gt; http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa<br></div>                                               </body>
</html>