Why do I get an NaN error with the ttest?

20 ビュー (過去 30 日間)
Barbara Schlaepfer
Barbara Schlaepfer 2019 年 7 月 21 日
コメント済み: Adam Danz 2019 年 12 月 10 日
I am trying to do a statistical analysis. I have two sets of data and try to find out if one is always a little higher. For the analysis I also need the significance.
I was trying the ttest, but for several answers I get NaN.
How can I fix that, do I have to use a different test?
Thanks for any help.
  1 件のコメント
Adam Danz
Adam Danz 2019 年 12 月 10 日
ANKUSH JAMTHIKAR's answer moved here as a comment
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? Is there any alternate test to do this job?
I am a bigginner in statistics. So kindly help me to understand this.
Thank you in advanced!

サインインしてコメントする。

回答 (2 件)

Star Strider
Star Strider 2019 年 7 月 21 日
The degrees-of-freedom are 0. It seems you likely do not have enough data to perform a t-test (or likely any other test of individual or group differences).
  2 件のコメント
Barbara Schlaepfer
Barbara Schlaepfer 2019 年 7 月 22 日
I have 18 data points for each set, Do you think that is not enough?
Star Strider
Star Strider 2019 年 7 月 22 日
編集済み: Star Strider 2019 年 7 月 23 日
You are apparently not presenting them to the ttest function as single-precision or double-precision numeric values. (They cannot be symbolic, categorical, strings, characters, or anything other than numeric values.) There appears to be no data in your vectors that ttest can use.
EDIT — The only way I can reproduce the results you get is with:
[h,p,ci,stat] = ttest(0, 1)

サインインしてコメントする。


Adam Danz
Adam Danz 2019 年 12 月 10 日
編集済み: Adam Danz 2019 年 12 月 10 日
Rather than copying the answer to here, see this review of possible causes of NaN output in ttest().

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by