How to Read T Test Output in Sas

In this article, we discuss how to perform a Student'south t-test in SAS.

The Pupil'due south t-test is a method of testing hypotheses about the hateful of one or two groups. With a t-test, one can determine whether the means of two groups are statically different, or whether the mean of one grouping is different from a known value.

In SAS, the easiest way to perform a Student'southward t-test is past using the TTEST procedure (PROC TTEST). With this procedure, one can perform a one-sample t-exam, two-sample t-test, or a paired t-test. Given the input parameters, the TTEST procedure calculates the test statistics, the corresponding p-value, and confidence intervals.

In this article, we kickoff discuss briefly which types of t-tests exist and how to select the right one. Adjacent, we volition show how to use PROC TTEST to perform each blazon of t-examination and how to interpret the results. Nosotros support all our explanations with examples and SAS lawmaking that y'all can use straight in your own projects.

Types of Student's T-Tests

Every bit mentioned earlier, the TTEST procedure can perform different types of t-test (i-sample, two-sample, or paired t-test), but how do you select the correct 1?

The diagram below helps yous cull the right t-test for your situation.

Which Student's T-Test to perform in SAS (one-sample t-test, two-sample t-test, or paired t-test)

To summarize, y'all use the:

  • One-sample t-exam when you lot have 1 sample (i.e. group) and yous want to make up one's mind if its hateful is stastically dissimilar from 0 or whatsoever other known value.
  • Paired t-examination when you have ane group and want to measure the outcome of some event. For example, a medical handling.
  • Two-sample t-test (Satterthwaite method or Welch's t-test) when y'all want to compare 2 groups with dissimilar variances.
  • 2-sample t-exam (Pooled method) when you want to compare 2 groups with the same variance.

Perform a Student's T-Test

The TTEST process in SAS performs t-tests of different types and computes confidence intervals. It also generates some plots (e.g., QQ-plots) that facilitate analyzing the results.

Irrespectively of the type of t-test, i always needs to complete at to the lowest degree the following steps to perform a t-test in SAS:

  1. Beginning the procedure with the PROC TTEST statement.
  2. Define the input dataset with the Data=-option.
  3. Specify the variable that needs to be tested with the VAR statement.
  4. Run the procedure with the RUN argument.

Next, we volition discuss how to modify these steps to perform each type of the Student's t-test.

Perform a One Sample T-Exam

The most bones t-test is the one-sample t-examination which checks whether the mean of a sample is significantly unlike from zero or another known value.

In the examples beneath, we will analyze the weight of breams (of species of fish).

SAS Dataset 1

Exam the Sample Mean Against Zero

The image below shows the default hypothesis of a i-sample t-test. In other words, it checks whether the sample mean (µ) is significantly different from zero.

To check in SAS whether the mean of a sample is significantly different from zero, y'all only need to provide the name of the input dataset and the variable you desire to test. You do this with the DATA=-selection and the VAR statement.

Additionally, yous can use the Alpha=-option to specify the confidence level. For instance, yous can use Blastoff=0.01 for a 99% confidence level. By default, SAS performs the t-test with a confidence level of 95%.

In the example below, we use the TTEST process to determine if the hateful weight of the Bream species differs from 0. To select only the Bream species, we use the WHERE=-option to filter the input data.

            proc ttest            data=sashelp.fish            (            where=(Species =            "Bream"            )            )            alpha=0.05;            var            weight;            run;

The image beneath shows the report that PROC TTEST generates.

Perform One Sample T Test in SAS with Default H0

Highlighted in ruddy, we meet the degrees of freedom (DF = 33), the value of the exam statistic (t Value = 17.67), and the p-value. Since the p-value is lower than our confidence level of 0.05, nosotros refuse the null hypothesis and conclude that the mean weight of the bream species is significantly different from zero.

Test the Sample Mean Against Another Known Value

Alternatively, we could specify a more realistic null hypothesis for the hateful weight of a fish, east.g. 600 grams.

To specify the null hypothesis of a one-sample t-test in SAS, you can employ the H0=-pick. With this option, you tin can define the known value against which SAS tests the sample hateful.

In the example below, nosotros utilise the H0=-pick to test whether the mean weight is equal to 600 grams.

            proc ttest            data=sashelp.fish            (            where=(Species =            "Bream"            )            )            alpha=0.05            H0=600;            var            weight;            run;

The image beneath shows the results of our new hypothesis. (Unfortunately, SAS doesn't add the null hypothesis to the report).

Perform One Sample T Test in SAS with Specified H0

Because the p-value (0.4683) is higher than our confidence level of 0.05, we don't refuse the null hypothesis and conclude that the mean weight is not statistically different from 600 grams.

Also the degrees of freedom, the value of the examination statistic, and the p-value, the study as well contains the confidence intervals for the hateful and the standard deviation. Additionally, the PROC TTEST procedure creates some extra plots to facilitate your analysis.

Histogram of One Sample T Test

One of the main assumptions of the t-test is that your data (eastward.g., the weight of fish) follows a normal distribution. To check this assumption, you tin can utilize the Q-Q plot. If all information points are close to the main diagonal, then it follows a normal distribution and, therefore, meets the supposition.

For example, the Q-Q plot below confirms that the weight of bream fish is normally distributed.

QQ Plot of One Sample T-Test

Perform a 2 Sample T-Test

The second type of t-test is the two-sample t-exam, also known every bit the independent samples t-test.

The two-sample t-test is a method to check if the sample ways (µ1 and µ2 ) of two independent samples (i.e., unlike groups) are equal. The alternative hypothesis (H1 ) assumes that the means are different. Encounter the image beneath.

Instead, if yous desire to check the means of two variables from the aforementioned group, yous need the paired t-test.

To perform a ii-sample t-examination in SAS, yous use the TTEST procedure in combination with the Course argument. These are the steps:

  1. Outset the TTEST process with the PROC TTEST statement.
  2. Define the input dataset with the Data=-selection.
  3. Specify the variable that defines the two groups/samples with the CLASS statement.
  4. Define the variable y'all want to test with the VAR argument.
  5. Execute the TTEST procedure with the RUN statement.

A prerequisite to performing the 2-sample t-test is that the input dataset is ordered by the variable that defines the groups (i.east., the variable of the Form statement). One way you lot can gild a dataset is with the SORT procedure.

Too an ordered dataset, SAS also requires that the data contains exactly two groups. If your data doesn't run into this requirement, then ii errors can occur:

1. Fault: The CLASS variable does not take ii levels. In this case, y'all might want to perform a 1-sample t-test.

2. Mistake: The Form variable has more than two levels . In this case, you might want to perform the ANOVA test which determines if (more than two) groups are statistically different. Alternatively, you can change the Grade statement for the Past statement, and do a one-sample t-test for all groups independently.

In the example beneath, we use the TTEST procedure to compare the average weight of two fish species. We utilise a confidence level of 95% (Alpha=0.05).

            proc sort            information=sashelp.fish     out=work.fish            (            where=(Species            in            (            "Bream"            "Parkki"            )            )            keep=Species Weight);            by            Species;            run;            proc ttest            data=piece of work.fish     alpha=0.05;     class Species;            var            weight;            run;

How to Translate the Results of a Two-Sample T-Exam

The next epitome shows the output of a two-sample t-test in SAS.

Perform a Two Sample T-Test in SAS

In order to draw the correct conclusion and (non) reject the null hypothesis, you need to follow the next steps:

  1. Check the results of the Equality of Variances test.
  2. Select the correct method to draw a conclusion.

If the p-value of the Equality of Variances test is greater than your significance level (e.yard., 0.05), then nosotros presume that the variances are equal and you should utilize Pooled method to draw the correct conclusion. Otherwise, the Satterthwaite method (i.e., the Welch'southward t-test) is the one you need.

So, in our example, the p-value of the Equality of Variance test is lower than 0.05, and hence pregnant. Therefore, we should apply the Satterthwaite method to draw conclusions most the 2-sample t-exam. Since the p-value of the Satterthwaite is too lower than 0.05, we reject the naught hypothesis and conclude that the means of the two groups are statistically different.

Besides the test statistics, p-values, and confidence intervals, the TTEST process as well generates ii plots. These plots might help you to support your conclusion (the histogram) or examination the normality supposition (the Q-Q plot).

Perform a Paired T-Examination

The tertiary type of t-exam is the paired t-test.

In contrast to the two-sample t-test, the paired t-exam determines whether the means of two variables of the same group are equal. This type of examination is frequently used to compare the means earlier and after a certain outcome. For example, a medical treatment.

Instead, if yous want to exam the means of the same variable from unlike groups, you lot need the two-sample t-test.

To perform a paired t-test in SAS, you demand to follow these steps:

  1. Start the TTEST process with the PROC TTEST argument.
  2. Define the input data with the DATA=-choice.
  3. Specify the two variables with the PAIRED statement. (You must split the 2 variables with in asterisk (*)).
  4. Run the TTEST process with the RUN argument.

Note that you can't apply the Grade argument in a paired t-test. If you want to test multiple groups, y'all either need the By statement or the ANOVA test.

In the example below, we create a dataset of 10 students. Each student has taken two exams; one before taking a certain course, and one after taking the course. We want to know if taking the course has a significant (positive) effect on the examination scores.

            data            work.test_scores;            infile            datalines dlm=",";            input            studentID testscore_1 testscore_2;     datalines;            i,            70,            74            ii,            56,            62            3,            eighty,            81            4,            60,            54            five,            78,            82            6,            56,            65            7,            80,            73            8,            77,            79            9,            60,            64            10,            78,            72            ;            run;            proc ttest            data=piece of work.test_scores;     paired testscore_2            * testscore_1;            run;
SAS Dataset 2

The images below prove the output of the TTEST procedure of the paired t-exam.

Dont Reject H0 Paired T-Test in SAS

Based on the p-value of 0.5476, we don't turn down the null hypothesis and therefore conclude that taking the course hasn't had a (positive) result on the test scores.

The post-obit plots evidence the differences between the test score from diverse perspectives and might assistance you lot to support your determination.

Histogram of Paired T-Test in SAS

The image to a higher place shows clearly why nosotros didn't reject the goose egg hypothesis, namely a zero difference lies within the 95% confidence interval.

The adjacent plot likewise shows that the test scores on average haven't changed much.

Plot of Paired Profiles in SAS
Agreement Plot of T-Test in SAS

One of the main assumptions of the paired t-test is that the differences are normally distributed. We can check this assumption with the Q-Q plot. If the differences are on or near the principal horizontal line, so nosotros conclude that the differences follow a normal distribution.

QQ Plot of Paired T-Test in SAS

The next instance shows a state of affairs where the test scores earlier and after taking the course are significantly different.

            data            work.test_scores2;            infile            datalines dlm=",";            input            studentID testscore_1 testscore_2;     datalines;            i,            seventy,            82            ii,            56,            64            3,            80,            81            four,            60,            67            five,            78,            85            vi,            56,            69            7,            80,            76            viii,            77,            82            ix,            60,            66            10,            78,            83            ;            run;            proc ttest            data=work.test_scores2;     paired testscore_2            * testscore_1;            run;
SAS Dataset 3
Reject H0 Paired T-Test in SAS

In this case, nosotros do reject the goose egg hypothesis of the paired t-test and conclude that taking the form has had a (positive) result on the test scores.

The plot of the Distribution of Difference (see beneath) supports this determination equally the zero difference doesn't prevarication within the 95% confidence interval.

Histogram of Paired T-Test in SAS

The Paired Profiles and Agreement plots as well demonstrate that there is a articulate departure between the two exam scores.

Plot of Paired Profiles in SAS
Agreement Plot of T-Test in SAS

The Q-Q plot confirms that the differences follow a normal distribution. Therefore, one of the chief assumptions holds and we tin can trust our conclusion nigh rejecting the zip hypothesis.

QQ Plot of Paired T-Test in SAS

warnkebaccumare.blogspot.com

Source: https://sasexamplecode.com/how-to-perform-a-students-t-test-in-sas-examples/

0 Response to "How to Read T Test Output in Sas"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel