Hypothesis Testing Mutual Funds
- Andrew Cole
- Feb 26, 2020
- 3 min read
The stock market is a rapidly moving beast with various equities and indexes acting and reacting upon one another. One of the strongest places to look for constant returns to the investor is in index funds: portfolios comprised of multiple equities which track the movement of a financial market index. These funds allow relatively affordable and easy access to a wide array of professionally-selected equities. Index funds always follow their own benchmark index, which measures the overall statistical change among relative markets, so the advantages of purchasing certain index funds can be tested against the overall performance of the benchmark index funds.
One of the largest industry-tethered index funds is the Health Care Select Sector SPDR fund (Ticker: XLV) whose benchmark fund is the S&P500 (Ticker: .INX). The XLV tracks healthcare stocks within the S&P500 weighted by market cap. The XLV is significantly larger than any of its competitors (trading volume) while remaining at a relatively cheap price. The XLV also has some big name players within it, all exclusive to the S&P 500, so it’s market-cap heavy composition usually tracks its benchmark index strongly.
In order to determine why the XLV is a worthy investment in comparison with the INX fund I will statistically test the size of average daily percent change in each. The INX fund is important as a benchmark for comparison to the performance of the XLV fund.
Gathering Data
Market data was pulled from alphavantage.co’s API using a requested client key for both XLV and INX. Data was converted to JSON format and then moved into a pandas DataFrame. An average daily percent increase (or decrease) was calculated using closing prices among respective funds dating back to Dec 1999(INX) and Jan 2000(XLV).
url = f"https://www.alphavantage.co/query?function={function}&symbol={symbol}&outputsize=full&apikey={alpha_key}"
response = requests.get(url)
xlv_file = response.json()
xlv_values = xlv_file['Time Series (Daily)']
xlv_df['day_pct_change'] = (xlv_df['close']-xlv_df['open'])/xlv_df['open']*100

Hypothesis Testing
To see if there was any advantage in the XLV’s performance vs. the INX I conducted a series of statistical hypothesis tests.
H0: There is no statistical difference between the mean daily percent change among XLV and INX funds.
H1: There is a statistical difference between the mean daily percent change among XLV and INX funds.
The daily percent changes for the population (INX) and sample (XLV) were first calculated using a large amount of samples, each containing a random-state sample-size of 50. These means were appended to a list for standardization and then plotted onto the below histogram. As we can see with the initial eye-test, there does not appear to be a statistical difference in means among the XLV fund and the S&P 500.

Because the sample size was so big (n > 5000) and the variance is known when following a normal distribution, we are able to perform a Z-test statistic in order to determine whether the population (INX) and the sample (XLV) means are different. The z-stat was calculated as follows:
x_hat = sum(xlv_avg_percent_moves)/len(xlv_avg_percent_moves)
mu = sum(sp_avg_percent_moves)/len(xlv_avg_percent_moves)
sigma = statistics.stdev(sp_avg_percent_moves)
n = 5017
z_stat = (x_hat - mu)/sigma/math.sqrt(n)
Z-statistic: -0.0022345097341326977
This is a very low z-stat which represents that the XLV’s sample mean percent change is extremely close to being 0 standard deviation’s away from the S&P 500’s mean change. As such, the null hypotheses fails to be rejected. As we mentioned before, the XLV is comprised of some extremely market-cap heavy equities which will result in usually close adherence towards the performance of the S&P500 benchmark, and the resulting z-statistic follows as such.
Digging Deeper – Components of the XLV
The XLV contains approximately 10% of the equities within the overall S&P 500. As such, the heavy weight of the XLV relative to the benchmark index lends itself towards the close tracking of the XLV on the INX. Moving inwards, the XLV’s largest component is the Johnson & Johnson equity (which is also the 9th heaviest equity in the INX). Similarly to the XLV, the Johnson & Johnson equity (JNJ) daily percent change should therefore map the S&P’s average daily movement as well.
To gather the data on the JNJ equity performance history, the same process was repeated as was done for the INX and XLV data.
H0: There is no statistical difference between the mean daily percent change among JNJ and INX funds.
H1: There is a statistical difference between the mean daily percent change among JNJ and INX funds.

Once again, the z-statistic produced was significantly small (.0003). Once again we fail to reject the null hypothesis of a present difference between JNJ and INX equity movements. This result inherently makes sense per the weighting principles of both the XLV and INX funds.
Comentários