How to implement tinv manually? Without Statistics and Machine Learning Toolbox

As an exercise, I am trying to implement ttests manually, without using the Statistics and Machine Learning Toolbox.
Now, I wish to determine the confidence interval. For this, the critical t-value is needed.
My question is, is there any way to do this without the Statistics and Machine Learning Toolbox? More exactly, how to implement tinv?

답변 (1개)

Thank you for the endorsement!
You have to have all these functions in your workspace simultaneously, and with them, you can use fzero to get the critical t-statistic from the probability (alpha) and degrees-of-freedom (v):
% % Variables:
% % t: t-statistic
% % v: degrees of freedom
tdist2T = @(t,v) (1-betainc(v/(v+t^2),v/2,0.5)); % 2-tailed t-distribution
tdist1T = @(t,v) 1-(1-tdist2T(t,v))/2; % 1-tailed t-distribution
t_inv = @(alpha,v) fzero(@(tval) (max(alpha,(1-alpha)) - tdist1T(tval,v)), 5); % T-Statistic Given Probability ‘alpha’ & Degrees-Of-Freedom ‘v’
Example:
alpha = 0.025;
v = 10;
T = t_inv(alpha, v) * [-1 1]
T_STB = tinv(alpha, v) % Statistics Toolbox Function
The Statistics Toolbox uses the one-tailed t-test to calculate the t-statistic, so I used it here as well.
T =
-2.2281 2.2281
T_STB =
-2.2281
If you’re doing parameter confidence intervals using polyfit, also give polyparci a look.

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2015년 12월 16일

답변:

2015년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by