ttest returns NaN even though matrices are finite and does not contain nan?

6 Ansichten (letzte 30 Tage)
I have 2 matrices: sample1 - 17*80 and sample2 - 17*80
find(isnan(sample1)==1) and find(isnan(sample2)==1) are empty matrices.
Similarly, find(isfinite(sample1)==0) and find(isfinite(sample2)==0) are empty matrices.
[h,p] = ttest(sample1, sample2) results into a 1*80 vector, each value = NaN.
Why does it happen so??
  2 Kommentare
Katerina Merculy
Katerina Merculy am 13 Apr. 2018
I have the same problem and vextors are not the same, they even have different number of rows and I compare ttest(mean(sample1),mean(sample2)) Have you decided this question?
Stephen23
Stephen23 am 13 Apr. 2018
@Katerina Merculy: please upload your data in a .mat file.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Anthony Peng
Anthony Peng am 19 Sep. 2017
Are the two vectors the same? If they have the same values in them, it will return NaN.
  3 Kommentare
ANKUSH JAMTHIKAR
ANKUSH JAMTHIKAR am 10 Dez. 2019
I have two binary vectors with same elements. I mean, if X and Y are the two binary vectors, then X=Y. Now when I am running ttest(X,Y), it is giving me h=NaN and p=NaN. Does anyone know, how to handel this issue?
I am a bigginner in statistics. So kindly help me to understand this.
Thank you in advanced!
Adam Danz
Adam Danz am 10 Dez. 2019
Bearbeitet: Adam Danz am 10 Dez. 2019
@Katerina Merculy, you're getting NaN values because mean(sample1) and mean(sample2) result in scalar values which is interpretted as a 1-sample ttest (not a paired ttest) and you need at least 2 values to carry out the test. Instead of inputting the mean, input the raw values.
@ANKUSH JAMTHIKAR, when the x and y inputs to ttest(x,y) are exactly equal, you should expect a NaN results.
For more detail on both problems, see this answer which explains in detail why NaN results occur in ttest().

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by