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 Comments

The function in the statistics toolbox is called ttest. Try
[h p ci stats] = ttest(x, y)
I think thats a difference between matlab and octave. [pval,t,df] = t_test_2(x,y) is the equivalent unless someone can tell me otherwise. I get an output for pval, t and df, they just arent right.
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.

Sign in to comment.

Answers (0)

Categories

Products

Tags

Asked:

on 20 Feb 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!