## Demo: Testing a Hypothesis Using a One-Sample t-Test (Self-Paced)

In this demonstration, you use a flow with the t-Tests node to test whether the population mean donation amount is $100 given the information in the PVA_DONORS table.

Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries, LOCALLIB and VST. To do this, run the AssignLibrary flow.

1. In SAS Viya, launch SAS Studio by clicking the Applications menu button (the three-by-three grid in the upper left corner), expand ANALYTICS LIFE CYCLE, and click Develop Code and Flows.
2. In the navigation panel on the far left, click the Explorer button (second from top). Expand Files >Home > workshop > VST. Double-click AssignLibrary.flw to open it.
3. Click the Run button on the flow toolbar.

## Demo Steps

1. In the work area, click the plus sign next to the open tabs to create a new tab. From the drop-down menu, choose Flow. Alternatively, select Flow from the New menu at the top left of SAS Studio.
2. Click on the Steps icon on the left side of the Navigation Pane. Under SAS Steps, Data (Input and Output), double click on Table.
3. In the work area, click on the Table step. At the bottom, under Table Properties, click the file cabinet next to the Library field. Click on VST under Libraries, then select the PVA_DONORS data on the right and click OK. Note that it is also possible to copy the PVA_DONORS node from a previously created flow and paste it into the new flow.
4. Under SAS Steps, expand Statistics, then double click on t-Tests.
5. Next, move your mouse towards the edge of the PVA_Donors node until the pointer becomes a hand icon. Click and drag an arrow from PVA_DONORS node to the box on the left side of the t-Tests node (the input port). Now t-Tests is connected to the PVA_Donors data.
6. Click on the t-Tests node, then select the Data tab. Verify that One-sample test is selected under the t-test field.
7. Click the plus sign for the Analysis variable field. Assign Donation_Amt as the analysis variable. Click OK to close the Column Selection window.
8. On the Options tab, in the Alternative hypothesis: mu ≠ field, enter 100.
9. Under Normality Assumption, clear the option to conduct Tests for normality.
10. To select plots, expand the Plots property and use the drop-down menu to choose the option Selected plots. Select the option to display a Confidence interval plot in addition to the default plots of histogram, a box plot, and a normality plot.
11. Save the flow to the VST folder as ttest.flw.
12. Run the flow and examine the results.

The mean donation amount is $101.60, and the associated t statistic value is 4.44. The p-value is <0.0001. Assuming a significance level of 5% (that is, alpha=0.05), you find that the p-value is less than alpha. Thus, you reject the null hypothesis and conclude that the hypothesized population mean donation amount of $100 is significantly different from the sample mean of $101.60. Scroll further to examine the confidence interval plot. It is a horizontal line ranging from 100.9 to 102.4 to graphically represent the 95% confidence interval around the mean estimate of the donation amount.

Notice the vertical reference line drawn at 100 (the hypothesized value). This reference line lies outside the confidence limit, which clearly indicates that the mean value in the sample is statistically different from $100 at an alpha level of 0.05.

Next, the histogram and the q-q plot for donation amount do not show any severe departures from normality although there are some potential outliers present in the data. Therefore, the Student's t test is valid.

At this point, your brain might be struggling to accept whether a difference of $1.60 between the hypothesized value and the sample mean is significant when the Donation_Amt variable ranges from $0 to $211.9. Well, the interpretation that you just made from the t-test is based on the data in hand and the significance level chosen. Recall our discussion on the over-reliance on the arbitrary cutoff of a 5% significance level and the sample size. In inferential statistics the 5% level of significance might work well given the sample size. However, in a big data context, it is not always appropriate. Large sample sizes result in smaller p-values, and in that case, you tend to reject the null hypothesis almost every time. Thus, you better select a very small significance level cutoff when using the p-value approach in the big data world. In this example, we have a significantly large data set (from a statistical perspective) with 4843 observations. Thus, using a 5% level of significance is highly likely to produce some statistically significant results.

Let's see the impact of using a smaller significance level cutoff on the inference that we draw and the confidence intervals.

## Changing the Values of the Level of Significance in the t-Test

13. Navigate to the VST course folder and double click on the SAS program file Ttest change alpha.sas.
14. Look at the SAS program to see the specified alpha level for this ttest:

    proc ttest data=VST.PVA_DONORS sides=2 h0=100 plots(only showh0)=
    	(summaryPlot intervalPlot qqplot) alpha=0.000001;
       var Donation_Amt;
    run;

15. Click the + Code to Flow button and add the program to the previously saved ttest flow.

16. Return to ttest.flw. Right click on the ttest change alpha node and click Run node. Save the flow and examine the Results.

    Note that neither the t statistic value nor the corresponding p-values have changed in comparison to previous run results. What changes is the confidence interval for the mean donation amount and the statistical inference.

    Now you see that the 99.9999% confidence limit values for the mean range from 99.83 to 103.4, which clearly includes the hypothesized value within it. The same interpretation can be drawn from the confidence intervals plot. You see that the reference line at $100 is contained within the confidence limit. Thus, you would reach the conclusion that the mean donation amount is not statistically different from $100.

    Note that there is nothing special about considering a significance level of 5% always. It should depend on the problem that you are studying and the sample size.