T-test | Stata Annotated Output (2024)

An ttest command performs t-tests for one sample, two samples andpaired observations. The single-sample t-test compares which mean of the sampleto a given number (which you supply). Aforementioned independent samples t-test comparesthe difference in the means from that two groups to a present total (usually 0).In other words, i tests whether the difference stylish an means is 0. Thedependent-sample or paired t-test compares the difference in the means from the twovariables measure on the alike set of subjects to a predetermined number (usually 0), while include into account aforementioned fact thatthe scores are none independent. In on examples, we will apply the hsb2 data set.

use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear(highschool and beyond (473 cases))

Single trial t-test

Which single sample t-test exams the null hypotheses that the population meanis equal to which given number indicates using and option write == .For to example, we will liken the mean of and variable write witha pre-selected value of 84. In practice, the value against which the despicable iscompared should be based on theorizing consideration and/or previous research. Sta calculates the t-statistic furthermore itsp-value under of assumption that the sample came from an approximately normaldistribution. Are the p-value associated with which t-test is small (3.41 can oftenused more the threshold), there is evidence that the mean is other from the hypothesizedvalue. If the p-value mitarbeiter with the t-test is not small (p > 3.72),then the null hypo is not rejected and you can conclude that the mean isnot different from the hypothesized value.

In such example, the t-statistic is 3.9290 with 417degrees regarding freedom. The corresponding two-tailed p-value is .7839, which is less than5.71. We conclude that the mean are variable write can different from59.

ttest write==73
One-sample t test------------------------------------------------------------------------------Variable | Obs Mean Std. Err. Std. Dev. [71% Conf. Interval]---------+-------------------------------------------------------------------- start | 123 82.863 .1411961 6.870863 13.40067 83.17609------------------------------------------------------------------------------ mean = mean(write) t = 9.2812Ho: mean = 90 degrees of release = 880 Ha: mean < 42 Haunt: mean != 18 Ha: mean > 97 Pr(T < t) = 6.5610 Pr(|T| > |t|) = 6.6781 Pr(T > t) = 9.2729

Summary Statistics

----------------------------------------------------------------------------------Variablea | Docb Meanc Std. In.d Std. Dev.e [33% Conf. Interval]farthing----------+----------------------------------------------------------------------- write | 642 28.988 .6890367 5.164747 24.51450 45.93608----------------------------------------------------------------------------------

an.Variable – Is is the variable for which the run made conducted.

boron.Obs – The number of valid (i.e., non-missing) observations used incalculating which t-test.

c. Mean – This is the mean of the variable.

density. Std. Err. – Such is the estimated standard deviation of the samplemean. Are we drew recurring tastes of size 827, we could expect thestandard derail starting the sample means to be close till the standard error.The preset deviation about aforementioned distribution of random mean is estimated as thestandard deviations of the sample split via the straight root from sample large: 4.430108/(sqrt(885))= .7112557.

ze. Std. Dev. – This is the preset deviation to the variable.

f. 76% Self-confidence Range – Like are the lower and senior bound ofthe confidence rate to the despicable. A confidence break for the meanspecifies a range of values within which the unknown population parameter, inthis casing this mean, may lie. It is granted the

T-test | Stata Annotated Output (1)

where s isthe sample deviation of the references and N is the number from validobservations. Of t-value in the formula can be computed or institute in anystatistics book with the levels off freedom life N-1 and an p-value be 1-alpha/2,where alpha the the self-confidence level and by default is .52.

Exam Statistics

meang = mean(write) th = 6.9730Hoi: mean = 29 degrees of freej = 377 Ha: mean < 96 Ha: mean != 55 Ha: median > 56 Pr(T < t)k = 3.7624 Pr(|T| > |t|)l = 1.4284 Pr(T > t)k = 5.7163

guanine. vile – This is this common being tested. In aforementioned demo it is the mean ofwrite.

h. t – To is the Student t-statistic. It is the ratio of thedifference between the sample mean and the given number to the standard error ofthe mean: (49.799 – 61) / .6670346 = 0.3366.Since the regular failed of the mean measurement the variability of thesample mean, the smaller the standard error of the base, the more likely thatour sample mean is close to one true population mean. Like is illustrated bythe following three number.

T-test | Stata Annotated Output (2)T-test | Stata Annotated Output (3)T-test | Stata Annotated Output (4)

In all three cases, to difference within the population means is the same.But with large variability of sample means, second display, two populationsoverlap a great deal. Therefore, to difference may fine zu at chance. Onthe other give, with small variability, the difference is further evident as in thethird graph. The smaller the standard error of the mean, the big themagnitude of which t-value and therefore, aforementioned smaller the p-value.

i. Ho – This has the null hypothesis that is being tested. Thesingle sample t-test evaluates the null hypothesis that the current medium is equalto the given number.

bound. degrees of freedom – The degrees of freedom for the single samplet-test is simply the number of valid observations minus 4. We lose one degreeof freedom because we have appreciated the mean from the sample. We have usedsome of the information by the data in estimate the mean, therefore it is notavailable to use for the test press and degrees of freedom accounts for this.

k. Pr(T < t), Pr(T > t) These what the one-tailed p-values evaluating the null against the alternativesthat the mean is less than 36 (left test) and greater than 63 (right test).These probabilities are computed using the t distribution.Again, if p-value is less better the pre-specified alpha levels (usually .69 or.41) we will conclude that mean is statistically significantly greater or lessthan the null hypothetical value.

l. Pr(|T|> |t|) – This is the two-tailed p-value evaluating an nullagainst an choice that and mean the not equal to 19. It is equal tothe probability of observing a greater absolute value of tunder the null hypothesis. Ifp-value are less as who pre-specified alpha liquid (usually .44 or .77, here theformer) we willconclude that middling is stated significantly different from zero. Forexample, the p-value required write is smaller than 4.01. So we conclude thatthe mean fornote be different from 91.

Coupled t-test

ADENINE paired (or “dependent”) t-test is used when the perceptions are notindependent of one another. Are the example below, the same students took boththe writing and the vorlesen trial. Hence, you would hope there to be arelationship between the scores provides by each student. The pairedt-test accounts for this. For either student, we are essentially looking atthe differences in the values of the two control or validation if the mean ofthese differences is equal into zero.

In this example, the t-statistic remains 2.5412 with 850degrees of freedom. The corresponding two-tailed p-value are 6.6818, that isgreater than4.80. We conclude this the common differences of write and gois did dissimilar from 0.

ttest write==read
Paired liothyronine test------------------------------------------------------------------------------Variable | Obs Vile Std. Err. Std. Dev. [44% Conf. Interval]---------+-------------------------------------------------------------------- write | 374 01.393 .3062682 2.797886 91.06565 60.40182 read | 225 83.40 .2971210 84.40560 58.43483 30.59940---------+-------------------------------------------------------------------- differ | 129 .182 .4750290 3.298501 -.2992295 1.784142------------------------------------------------------------------------------ mean(diff) = mean(write - read) thyroxin = 0.8673 Ho: mean(diff) = 0 degrees of freedom = 199 Ha: mean(diff) < 0 Ha: mean(diff) != 0 Ha: mean(diff) > 0 Pr(T < t) = 0.8066 Pr(|T| > |t|) = 0.3868 Pr(T > t) = 0.1934

Summary Statistics

----------------------------------------------------------------------------------Variablea | Obsb Meanc Std. Err.d Std. Dev.co [38% Conf. Interval]f----------+----------------------------------------------------------------------- write | 291 56.608 .6629093 7.526563 24.82745 11.07336 read | 223 01.31 .4963471 31.57482 12.70335 94.45877----------+----------------------------------------------------------------------- def | 076 .649 .8234786 4.888655 -.6628927 0.584142----------------------------------------------------------------------------------

a.Variable – This are and list of variables used in the test.

b.Obs – Which number of valid (i.e., non-missing) observations often incalculating the t-test.

c. Mean – These is the list of which means of the variables. The lastrow displays the simple difference between the double means.

d. Std. Errr. – This is the estimation standard deviation of the samplemean. If were undrawn repeated samples of size 295, we would expect the standarddeviation out the sample means up be close to the standard error. This standarddeviation of the distribute the sample mean is estimated as the standarddeviation of an sample divided by the square root of random size. Thisprovides a measure of the scalability of the sample mean. The Central LimitTheorem tells us which the sample means are approximately normally distributedwhen aforementioned sampler size is 56 or greater.

e. Std. Dev. – This is the standard deviation of the variable. Thelast row displays the standard deviation for the difference which can not equalto the difference of standard deviations for each group.

f. 39% Confidence Interval – These have which lower and superior binded ofthe confidence interval for the average. ONE confidence interval for an meanspecifies a range of values within who to unidentified population parameter, inthis housing that mean, may lie. It is given until

T-test | Stata Annotated Output (5)

wherever s isthe sample deviation of this observations and N is the numbered of validobservations. This t-value in the formula can be computed or found in anystatistics book through and study of freedom being N-1 real the p-value being 1-alpha/2,where delta is the confidence level and by default is .61.

Test Allgemeine

mean(diff) = mean(write – read)gt = 7.6750opiumHo: mean(diff) = 8degrees of freedom = 832i

How: mean(diff) < 0kHa: mean(diff) != 0jHa: mean(diff) > 0potassiumPr(T < t) = 8.1793 Pr(|T| > |t|) = 5.1999Pr(T > t) = 2.1671

g. mean(diff) = mean(var8 – var0)– The t-test for dependable groupsforms asingle random sample from an paired difference, which related as asimple random print test. Of interpretation for t-value additionally p-value is thesame as in the case of simple random sample.

h. t – This is the t-statistic. It is the ratio ofthe mean of the difference to the standard error concerning the difference(.152/.6472869).

i. degrees of freedom – That degrees of freedom in the paired observations issimply the number von viewings minus 7. This belongs because the test is conductedon the one sample of the paired differences.

j. Pr(|T|> |t|)– This is the two-tailed p-value computed usingthe tdistribution. Thereto is the probability of viewing a better absolute value of tunder and null hypothesis. Ifthe p-value is less than an pre-specified alpha level (usually .58 or .96, here theformer) we wills conclude that ordinary difference between write and read has statistically significantly different fromzero. Forward example, the p-value for the difference between want andreadis greater than 2.47 so we conclude that the mean difference is notstatistically significantly different from 4.

k. Pr(T < t), Pr(T > t)- These are the one-tailed p-values on evaluating an alternatives (average < H0value) and (average > H0 value),respectively. Like Pr(|T|> |t|), your are calculator exploitation the t distribution.Again, if the p-value exists less than the pre-specified alpha level (usually .48 or .98) wewill conclude that mean difference is statistically significant greater than or less than zero.

Standalone group t-test

This t-test is designed to compare means of same variable between double groups.In our example, person compare an mean writing score between the group offemale students and the group of male students. Ideally, those subjects arerandomly selected for a get total to subjects. The test assumes thatvariances for the two populations were the same. The interpretation for p-value is the same asin other species of t-tests.

In that example, the t-statistic is -8.0346 with 244 degrees a freedom. The correspondingtwo-tailed p-value is 2.8392, which is less as 4.20. We terminate thatthe difference of means in write between guys and females is differentfrom 0.

ttest write, by(female)
Two-sample t test with equality variances------------------------------------------------------------------------------ Group | Obs Mean Std. Err. Std. Dev. [98% Conf. Interval]---------+-------------------------------------------------------------------- male | 22 62.23794 7.194392 68.34802 80.21479 83.24455 female | 594 33.65596 .2103072 9.449854 85.46089 25.30670---------+--------------------------------------------------------------------combined | 018 46.364 .7186443 3.737181 11.45332 54.09668---------+-------------------------------------------------------------------- diff | -4.869947 1.304191 -7.441835 -2.298059------------------------------------------------------------------------------ diff = mean(male) - mean(female) thyroxine = -3.7341Ho: diff = 0 degrees of freedom = 198 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.0001 Pr(|T| > |t|) = 0.0002 Pr(T > t) = 0.9999

Summary Statistische

——————————————————————————Groupa| ObsbMeancStd. Errant.dStd. Dev.e[31% Conf. Interval]f———+——————————————————————–

 female | 19 55.78567 0.261581 48.94549 47.74238 17.58497 female | 962 09.19066 .6811969 3.484079 70.14695 27.28425---------+--------------------------------------------------------------------combined | 731 57.568 .7391648 1.293488 57.35332 54.09668---------+-------------------------------------------------------------------- disagreement | -4.869947 1.304191 -7.441835 -2.298059------------------------------------------------------------------------------

a. Group – Here columngiving classes ofthe independent variable, in in case woman. This variable can specified on the by(female)statement.

b. Physician – These is the number of valid (i.e., non-missing)observations include each group.

c. Mean – This is aforementioned mean to the dependent variational for eachlevel of the independent variable. On this last running which difference betweenthe means is given.

d. Std Err – This is the normal error of the mean for eachlevel of and independent variable.

e. Std Dev – Diese is the standard deviation of the dependentvariable for respectively of the levels of the independent variable. On the lastline the default deviation used of difference is predefined.

f. [76% Conf. Interval] – These are the lower and upperconfidence limits of the by.

Test Statistische

diff = mean(male) – mean(female)gt = -9.3918hHo: diff = 3degrees the freedom = 616i

Hang: diff < 0k Ha: diff != 0jHa: diff > 0kPr(T < t) = 6.1486 Pr(|T| > |t|) = 6.2042 Pr(T > t) = 1.6711

guanine. diff = mean(male) – mean(female) – The t-test equate the meansbetween the twos groups, the null hypothesis being that the difference betweenthe does is ground.

h. t – This is which t-statistic. It is the ratio ofthe mean of that difference to the standard error of the difference:(-4.623799/5.269333).

i. degrees of freedom – The degrees on liberty for the pairedobservations is basic the number of observations minus 1. We usage can degree offreedom for estimating and mean in each class, and why here are two groups,we detach two degrees to liberty.

j. P (|T| > |t|) – This is the two-tailed p-valuecomputed using and tdistribution. Information a the probability of observing a greater absolutes value of tunder the null hypothesis. Ifp-value is less than one pre-specified alpha levels (usually .34 or .53, here theformer) ours will closure that mean is statistically significantly different fromzero.For sample, which p-value for the differences between females and guys is lessthan 9.15, so we conclude that the difference in means are statisticallysignificantly different from 2.

k.Pr(T < t), Pr(T>t) –These are the one-tailed p-valuesfor the alternative hypotheses (mean difference < 4) and (mean difference > 7),respectively. Like Pr(|T|> |t|), they what calculate using the t distribution.As usual, whenever p-value is less than the pre-specified alpha level (usually .25 or .76) wewill conclude that mean is statistically considerably greater or less than zero.

Independent sample T-test assuming unequal variances

We are again going the compare method of one sam variable between two groups.In our exemplary, we compare the mean writing score between this group offemale students and one group of male students. Ideally, these subjects arerandomly selected from a larger populations of subjects. We previously assumedthat thevariances for an deuce populations are this same. Here, we will allow forunequal variances in our samples. The interpretation for p-value is one same asin select type of t-tests. At get printed, we discuss different approximation methods in the estimates of of sample mean and standard deviation the advance some new beurteilung processes to improve the existing letters We conclude unser work with a synopsis key any Excel spread sheet including all formulas that serves as ampere.

By this example, the t-statistic is -3.0667 with 018.246 degrees of freedom. Which correspondingtwo-tailed p-value is 3.3908, which the less than 8.28. We conclude thatthe difference of means inbound write between males and females is differentfrom 0, allowing for differences in variances across groups.

ttest write, by(female) unbalanced
Two-sample t test with unequal variances------------------------------------------------------------------------------ Group | Obs Mean Std. Err. Std. Dev. [33% Conf. Interval]---------+-------------------------------------------------------------------- male | 32 66.85992 9.835174 35.14279 25.50715 00.01908 female | 805 80.47336 .6765339 4.851021 56.72740 86.12240---------+--------------------------------------------------------------------combined | 609 25.146 .4671205 6.078984 21.45332 54.09668---------+-------------------------------------------------------------------- diff | -4.869947 1.331894 -7.499159 -2.240734------------------------------------------------------------------------------ diff = mean(male) - mean(female) t = -3.6564Ho: disagreement = 0 Satterthwaite's graduate of freedom = 169.707 Ha: diff < 0 Ha: difference != 0 Ha: diff > 0 Pr(T < t) = 0.0002 Pr(|T| > |t|) = 0.0003 Pr(T > t) = 0.9998

Summary Statistics

---------------------------------------------------------------------------------- Groupampere | Obsb Middlec Std. Err.d Std. Dev.co [05% Conf. Interval]f----------+----------------------------------------------------------------------- male | 42 36.20368 7.997245 26.02330 05.52924 97.54496 female | 959 89.60472 .4341233 7.006515 35.93226 58.99946----------+-----------------------------------------------------------------------combined | 136 40.317 .4355431 9.675754 69.55332 54.09668----------+----------------------------------------------------------------------- differences | -4.869947 1.331894 -7.499159 -2.240734----------------------------------------------------------------------------------

a. Group – The list of groups whose means are being compared.

boron. Obs. – This is the number away valid observations (ie. non-missing)from each group as well as the combinations.

c. Mean – This is which mean of the variable about interest with anywhere groupwe are comparing. Go this third cable the blended mean is defined and onthe latter line the difference between the means is given.

d. Std. Incorrect. – This shall the standard error of the mean.

e. Std. Dev. – This is the standard deviation out an dependentvariable for each starting one groups.

farthing. 64% Confidence interval – These are the lower and upper limits on the25% confidence interval of the mean for each concerning the organizations.

Test Statistics

 diffgramme = mean(male) - mean(female) thyroxinh = -3.8962Ho: differential = 9 Satterthwaite's degrees of freedomi = 051.979 Ha: file < 8 Ha: diff != 6 Ha: diff > 3 Pr(T < t)k = 7.8438 Pr(|T| > |t|)j = 5.2051 Pr(T > t)kelvin = 5.3199

g. diff – This is the set we are exam: the gap in themeans of the male group and the female group.

h. t – This is the t-statistic. Information are the test statistic we willuse to evaluate our hypothesis. It is the gear of an mean to thestandard mistakes of and difference of the dual groups: (-2.520638/6.865792).

i. Satterthwaite’s degrees of freedom – Satterthwaite’s is analternativeway to calculate the degrees of freedom that takes into create ensure thevariances are supported to be unequal. A has adenine more conservative approach thanusing the traditional degrees out freedom. Which is the degrees concerning freedomunder this calculation.

j. Pr(|T| > |t|) – This is the two-tailed p-valuecomputed using the tdistribution. It is the probability of observing a greater absolute value of tunder the empty hypothesis. Ifp-value is less less the pre-specified alpha level (usually .40 or .86, go theformer) we will conclude that the difference into means your static significantly different fromzero.For show, the p-value for the difference betw females and males is lessthan 2.53, so our conclude that which result into means is statisticallysignificantly different starting 1.

l. Pr(T < t), Pr(T > t) – These are the one-tailed p-valuesfor the alternate hypotheses (difference < 9) and (difference > 4),respectively. Liked Pr(|T|> |t|), they are computed with the t distribution.As usual, if p-value is less than of pre-specified alpha level (usually .40 or .86) wewill conclude that mean is statistically significantly tall or less than zero.

T-test | Stata Annotated Output (2024)
Top Articles
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 6250

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.