tinv function giving wrong values
조회 수: 18 (최근 30일)
이전 댓글 표시
I used tinv(0.95,16) and it returned 1.746, which is the value for 90% confidence interval at a df of 16. In order to get the correct value of 2.12 I would need to use 0.975 with df of 16.
Am I using it wrong or is the database wrong?
댓글 수: 0
채택된 답변
Walter Roberson
2017년 2월 6일
Are you sure?
>> tcdf(2.12,16)
ans =
0.975004535643448
>> tcdf(1.746,16)
ans =
0.950010376153097
The Maple software packages agrees with these.
댓글 수: 2
추가 답변 (1개)
Publius
2021년 2월 19일
I know that this is a bit of an old post, but I've been stuck on this for a while, and wanted to be able to help someone else down the line. I noticed the same thing. My professor said that for the first number, we should enter (1-(1-conf/100)/2). For example, for a 95% confidence interval with 16 degrees of freedom,
tinv(1-(1-95/100)/2,16)
Of course this can be simplified to
tinv(1-(1-.95)/2,16)
This worked for me for all values of confidence interval to return the "expected" value that is in our notes. I'm really not familiar with the statistics behind this and other tails, but this was the thing that worked for me. Hope this helps someone else.
댓글 수: 1
Catherine Mauck
2022년 2월 15일
Thank you for this comment! I hope I can add some additional context to explain as well, for anybody who is not well-versed in stats. I am teaching really basic statistics for a specific, non-mathematical application (a lab science), and need students to be able to reproduce in MATLAB the act of looking up the corresponding t value in the textbook's table -- the problem was it didn't match, as pointed out above.
The values of t in the table that the textbook I teach from are two-tailed, which they define as meaning "95% confidence specifies the regions containing 2.5% of the area on either side of the curve extremes. For a one-tailed test, we would use values of t listed for 90% confidence, because each wing outside of t for 90% confidence contains 5% of the area of the curve."
So taking @Jacob Snider's workaround, the t value for a 2T test at 95% confidence (x = 0.95) would be produced like this:
dataArray = [3.29, 3.22, 3.30, 3.23];
df = numel(dataArray) - 1;
conf = @(x) 1 - (1 - x)/2;
t_crit = tinv(conf(0.95),df);
For the data above, this gives a critical t value of 3.182(4) which matches the 2T 95% t in my text's table.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!