Paired t_test_2 code problem
显示 更早的评论
Hi,
I hope this is something basic that someone can quickly point out my error. I am currently on Octave but the problem transfers to matlab also.
I am trying to perform a paired t-test on two data groups sorted by a variable. To test my code I have created a short test spreadsheet that I know the answer to so I can compare.
Below is the code I have used to separate into two groups, it worked fine when I had equal groups in my array but now they are uneven (10 and 9).
Can anyone tell me how I can arrange by the vairable in column 2 and assign to x and y accordingly?
clear
cd "/home/james/mystuff"
filename= 'testttest.csv'
num = csvread(filename);
Xpos=num(:,1);
G=reshape(num, 11,4);
x=G(:,1);
y=G(:,2);
[pval,t,df] = t_test_2(x,y)
The layout in the spreadsheet is two columns, 1st is the dependent variable and the 2nd is the independent.
3 个评论
Thorsten
2013-2-20
The function in the statistics toolbox is called ttest. Try
[h p ci stats] = ttest(x, y)
Jimmy
2013-2-20
Tom Lane
2013-2-20
You mention a paired t-test. In my experience this is a test on the difference between the two samples. I don't understand how you could have a paired t-test when the two samples have different sizes.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!