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.
更多回答(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!