How to Perform a t-Test on Stock Prices in Excel
Question details
The user needs to perform a t-test in Excel to compare stock price data for a college project.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A student wants to compare two sets of stock price observations and interpret the statistical result.
- Observed behavior
- The desired outcome is a t-test result that helps assess whether the two population means differ.
Place the two datasets in separate columns with clear headers, and check for missing or nonnumeric values. Decide whether observations are naturally paired, such as measurements matched by date, and whether stock prices or returns are appropriate for the project.
Run a stock price t-test with Excel's Analysis ToolPak
Use the Data Analysis tools when you need a detailed t-test report with statistics and p-values.
Choose a paired test only when each observation has a meaningful match in the other dataset. For independent samples, use the unequal-variance test unless an equal-variance assumption is justified.
Stock prices and returns observed over time may be serially correlated, which can make a standard t-test misleading. Returns may be more appropriate than price levels for comparing performance, but they still require an appropriate analysis.
In Excel for Windows, go to File > Options > Add-ins. Select Excel Add-ins in the Manage box, click Go, check Analysis ToolPak, and click OK.
Open Data > Data Analysis. Select t-Test: Paired Two Sample for Means for matched observations, or t-Test: Two-Sample Assuming Unequal Variances for independent samples, then click OK.
Select the Variable 1 and Variable 2 ranges. Check Labels if the selected ranges include headers, enter 0 for Hypothesized Mean Difference if testing for no difference, and set Alpha to 0.05 if that is your chosen significance level.
Choose an Output Range or New Worksheet Ply, then click OK to produce the results.
For a two-sided test, compare P(T<=t) two-tail with your chosen alpha. A p-value below alpha provides evidence against the hypothesis of equal means; it does not measure the size or practical importance of the difference.

Calculate a t-test p-value with Excel's T.TEST function
Use a formula when you only need the p-value rather than a full Analysis ToolPak report.
Calculate a stock price t-test in WPS Spreadsheets
Use the TTEST function in WPS Spreadsheets to calculate a paired or unequal-variance t-test p-value from your stock data.
- 1. Open your data: Open WPS Spreadsheets and use File > Open to select your workbook, or enter the two datasets in separate columns.
- 2. Choose the test: Identify whether the observations are meaningfully paired or independent. Use type 1 for paired data or type 3 for independent samples with unequal variances.
- 3. Enter the formula: Click an empty cell and enter =TTEST(A2:A31,B2:B31,2,3) for a two-tailed, unequal-variance test. Replace the ranges and test type as needed.
- 4. Interpret the result: Press Enter, then compare the returned p-value with the significance level specified for your project.

Frequently Asked Questions
Which t-test should I use for two stocks measured on the same dates?
A paired test may be appropriate if each date creates a meaningful match. In Data > Data Analysis, select t-Test: Paired Two Sample for Means. Also consider whether serial correlation affects the analysis.
What does the two-tailed p-value mean?
It describes how unusual the observed result, or a more extreme one, would be under the null hypothesis and the test assumptions. Compare P(T<=t) two-tail with your selected alpha, such as 0.05.
Why is Data Analysis missing from Excel?
The Analysis ToolPak may not be enabled. In Excel for Windows, go to File > Options > Add-ins, select Excel Add-ins under Manage, click Go, and check Analysis ToolPak.
Should I compare stock prices or returns?
It depends on the project question. Returns may be more useful for comparing performance because stock price levels can differ substantially, but returns can also be serially correlated and should be analyzed accordingly.




