How to run SPM and Non Parametric SPM together
Closed this issue · 4 comments
Hi Todd
I have recently used this code to plot the difference between two different time normalised force plate loads (variableA 100% 1RM; variableB 40% 1RM). I don't know how to do this any other way, so I just create variableA and variableB and run it.
Is it possible to this using with non parametric and compare parametric and non-parametric and get the two SPM outputs? ( like the example you have). Ideally, if I can just do it similar to this method then its easier for me to follow.
%(1) Compute confidence intervals:
alpha = 0.003;
ci2 = spm1d.stats.ci_pairedsample(variableA, variableB, alpha, 'meanA', 'tailB');
disp(ci2);
%(2) Plot:
close all
figure('position', [0 0 1000 300])
myxlim = [0 size(variableA,2)-1];
% plot hypothesis test:
subplot(223)
spmi = spm1d.stats.ttest_paired(variableA, variableB).inference(alpha);
spmi.clusters{:,:}
spmi.plot();
spmi.plot_threshold_label();
spmi.plot_p_values();
xlabel('Normalised Movement Time (%)' ,'FontSize',10,'FontWeight','bold','Color','k');
hold on;
%plot CI (possibility 3)
subplot(221)
ci2.plot()
xlim(myxlim)
xlabel('Normalised Movement Time (%)' ,'FontSize',10,'FontWeight','bold','Color','k');
ylabel('Power (W)' ,'FontSize',10,'FontWeight','bold','Color','k');
yline(0,'-.k');
best regards
David
You can calculate confidence intervals non-parametrically using spm1d.stats.nonparam.ci_pairedsample
like in this example and you can run a non-parametric paired t test using spm1d.stats.nonparam.ttest_paired
like in this example.
If that does not answer your question, please add some comments to your MATLAB code that indicate what you would like to calculate / plot. For example:
% plot hypothesis test:
subplot(223)
spmi = spm1d.stats.ttest_paired(variableA, variableB).inference(alpha);
% QUESTION: how can I run a non-parametric paired t test?
Hi Todd
Thanks for the quick reply, sorry if I was not clear
%(1) Compute confidence intervals:
alpha = 0.003;
ci2 = spm1d.stats.ci_pairedsample(variableA, variableB, alpha, 'meanA', 'tailB');
disp(ci2);
%(2) Plot:
close all
figure('position', [0 0 1000 300])
myxlim = [0 size(variableA,2)-1];
% plot hypothesis test:
subplot(223)
spmi = spm1d.stats.ttest_paired(variableA, variableB).inference(alpha);
spmi.clusters{:,:}
spmi.plot();
spmi.plot_threshold_label();
spmi.plot_p_values();
xlabel('Normalised Movement Time (%)' ,'FontSize',10,'FontWeight','bold','Color','k');
hold on;
%plot CI (possibility 3)
subplot(221)
ci2.plot()
xlim(myxlim)
xlabel('Normalised Movement Time (%)' ,'FontSize',10,'FontWeight','bold','Color','k');
ylabel('Power (W)' ,'FontSize',10,'FontWeight','bold','Color','k');
yline(0,'-.k');
% QUESTION: how can I run a parametric t-test and non-parametric paired t test (with 95% confidence intervals) so I can get these outputs in the format below by copying the data into variableA and variableB?.
Top Left- Parametric 95% Confidence intervals
Bottom Left- SPM output
Top right- Non-parametric 95% confidence intervals
Bottom right- Non-parametric SPM output
Best regards
David
I believe the following script will produce the result you're after:
% load dataset:
dataset = spm1d.data.uv1d.tpaired.PlantarArchAngle();
[yA,yB] = deal( dataset.YA, dataset.YB );
% specify variables and constants
variableA = yA;
variableB = yB;
alpha = 0.003;
iterations = -1; % -1 implies all iterations
% plot:
close all
figure('position', [0 0 1000 600])
subplot(221)
ci = spm1d.stats.ci_pairedsample(variableA, variableB, alpha, 'meanA', 'tailB');
ci.plot()
subplot(222)
ci = spm1d.stats.nonparam.ci_pairedsample(variableA, variableB, alpha, 'meanA', 'tailB', 'iterations', iterations);
ci.plot()
subplot(223)
spmi = spm1d.stats.ttest_paired(variableA, variableB).inference(alpha);
spmi.plot();
subplot(224)
snpmi = spm1d.stats.nonparam.ttest_paired(variableA, variableB).inference(alpha, 'iterations', iterations);
spmi.plot();
Many thanks Todd