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

10 vues (au cours des 30 derniers jours)
Toomas Liiv
Toomas Liiv le 16 Déc 2015
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?

Réponses (1)

Star Strider
Star Strider le 16 Déc 2015
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.

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by