analyzing financial data in an introductory statistics course kelly fitzpatrick, cfa assistant...

37
Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris [email protected]

Upload: roderick-palmer

Post on 21-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Analyzing financial data in an Introductory Statistics Course

Kelly Fitzpatrick, CFAAssistant Professor of Mathematics

County College of Morris

[email protected]

Page 2: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Abstract

Students today are very brand savvy; they have their favorite cell phone company, coffee shop, social media outlet or clothing store. Many of these companies are publicly traded on an exchange and students will enjoy analyzing the dataset (prices or returns) of their favorite companies. This webinar will cover how to download financial data from Yahoo Finance and the Bureau of Labor Statistics. We will also cover a gambit of analysis tools that can be used to analyze financial data; from box and whisker plots, correlation and regression analysis to hypothesis testing. We will look at the effects of the Deep Horizon / BP Oil Spill of 2010, differences in Facebook and Apple stock and the domestic and international unemployment rates. Students will enjoy analyzing real world data that is interesting to them.

Page 3: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

#2 Use Real Data#3 Stress conceptual understanding#4 Foster active learning in the classroom#5 Use technology for developing conceptual understanding and analyzing data

Personalize and individualize your

datasets

GAISE Report Recommendations:

Page 4: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Objectives for this webinar

• How to download data from Yahoo Finance• How to download data from Bureau of Labor Statistics• How to analyze stock prices / stock returns• How to analyze the unemployment rates• Using financial data in the introductory statistics class

• Plotting• Detection of outliers• Binomial Probability• Hypothesis Testing• Correlation Analysis• Regression Analysis• Anova

What topic are you most interested in covering today?

Page 5: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

British Petroleum (BP) is the largest oil and gas producer in the United States and the second largest company in the United Kingdom. BP is one of the most widely held stocks in the United Kingdom, with about 30% of the population holding BP stock in their portfolios. Analyze the data below and investigate for yourself the effects that the 2010 oil spill in the Gulf of Mexico has had on the stock price. Price data for BP goes back as far as 1991.

Analyzing the effects of BP Oil Spill

Page 6: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

www.yahoo.com – Finance – Quote Lookup Go – Historical Prices

Page 7: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 8: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 9: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 10: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Scroll down to the bottom of the page and select “Download to Spreadsheet”

Page 11: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Date Open High Low Close Volume Adj Close

12/1/2014 39.62 41.59 34.88 38.36 10892200 36.663708

11/3/2014 42.94 43.08 39.19 39.32 6696400 37.581257

10/1/2014 43.84 44.14 39.45 43.46 7259500 40.939796

9/2/2014 47.57 48.11 43.8 43.95 9599900 41.401382

8/1/2014 48.66 49.39 46.77 47.84 4680900 45.065804

7/1/2014 52.9 53.48 48.7 48.97 4246000 45.574661

6/2/2014 50.76 53.48 49.87 52.75 3447100 49.092575

5/1/2014 50.56 51.56 50.21 50.45 4193500 46.9520454/1/2014 48.31 50.77 47.14 50.62 4637400 46.57114

Page 12: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Formatting issues that need to be addressed

1. Too much information- delete information that is not neededhighlight columns that are not needed and delete them

2. Reverse chronological order- oldest price to most recent priceselect all of the datahome tab – hit sort and filter – oldest to newest

3. Adding the daily returns=(today’s price – yesterdays price)/yesterdays price

4. Save the file in the format you need. CSV is the default

Date Open High Low Close Volume Adj Close12/1/2014 39.62 41.59 34.88 38.36 10892200 36.66370811/3/2014 42.94 43.08 39.19 39.32 6696400 37.58125710/1/2014 43.84 44.14 39.45 43.46 7259500 40.939796

9/2/2014 47.57 48.11 43.8 43.95 9599900 41.4013828/1/2014 48.66 49.39 46.77 47.84 4680900 45.0658047/1/2014 52.9 53.48 48.7 48.97 4246000 45.5746616/2/2014 50.76 53.48 49.87 52.75 3447100 49.0925755/1/2014 50.56 51.56 50.21 50.45 4193500 46.9520454/1/2014 48.31 50.77 47.14 50.62 4637400 46.571143/3/2014 49.39 49.87 46.29 48.1 6344000 44.2527052/3/2014 46.73 51.02 45.83 50.61 5753100 46.5619431/2/2014 48.43 49.2 46.62 46.89 6146900 42.633633

Page 13: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Date Close Returns1/3/2000 53.75 2/1/2000 47.0625 -12%3/1/2000 53.25 13%4/3/2000 51 -4%5/1/2000 54.5625 7%6/1/2000 56.625 4%7/3/2000 52.3125 -8%8/1/2000 55.25 6%9/1/2000 53 -4%

10/2/2000 50.9375 -4%11/1/2000 47.4375 -7%12/1/2000 47.875 1%

1/2/2001 51.5 8%2/1/2001 49.6 -4%3/1/2001 49.62 0%4/2/2001 54.08 9%

1. Deleted unnecessary information

2. Reverse chronological order-check it

3. Created the return column4. Delete the first entry5. Save the file in the format

you need Date Close Returns

2/1/2000 47.0625 -12%3/1/2000 53.25 13%4/3/2000 51 -4%5/1/2000 54.5625 7%

Editing the Source File

Page 14: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 15: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

BP PricesMean 52$

Standard Deviation 10$

BP ReturnsMean 0%

Standard Deviation .07 = 7%

Page 16: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Critical Value Test:If calculated r > cv data is ND

.97 17< .993 conclude data is NOT ND

Page 17: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

P(x=E) .50 (1-.5)

5𝟓𝑪𝟎

The Binomial Probability Formula

If there is a 50% chance that BP will have a positive day, what is the probability that the stock will trade down 5 days in a row?

The probabili

ty of success

Success

Part

FailurePart

The Combinati

on Rule

P(x=all failure)3.13

%

Page 18: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Breakeven

If a stock’s return is down (negative) 30% in one month and the following month the stock’s return is up (positive) 30% are you back to your original value?

1. Yes

2. No

Page 19: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Analyzing the Unemployment Rates

• This is a “house hold survey”, door to door, n = 50,000• Reported monthly on the first Friday of the month• Seasonally adjusted

Three questions are asked:

1. Are you currently employed?

2. Are you not employed but actively looking for work?

3. Are you not employed and not actively looking for work? (not in the labor force)

Students, stay at home moms, discouraged workers are considered not in the labor force

Page 20: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Calculating the Unemployment Rate

1. 18,000 are employed and currently working

2. 2,000 are not employed but looking

3. 30,000 are not in the labor force- stay at home moms, students, discouraged workers

4. The rate of unemployment will be = 2,000/(18,000+2,000) = .10 = 10%

Page 21: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

www.bls.gov - Data Tools – Top Pics

Page 22: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 23: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 24: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 25: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Labor Force Statistics from the Current Population SurveyOriginal Data Value

Series Id: LNS14000000

Seasonally Adjusted

Series title: (Seas) Unemployment Rate

Labor force status: Unemployment rate

Type of data: Percent or rate

Age: 16 years and over

Years: 2005 to 2015

Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

2005 5.3 5.4 5.2 5.2 5.1 5.0 5.0 4.9 5.0 5.0 5.0 4.9

2006 4.7 4.8 4.7 4.7 4.6 4.6 4.7 4.7 4.5 4.4 4.5 4.4

2007 4.6 4.5 4.4 4.5 4.4 4.6 4.7 4.6 4.7 4.7 4.7 5.0

2008 5.0 4.9 5.1 5.0 5.4 5.6 5.8 6.1 6.1 6.5 6.8 7.3

2009 7.8 8.3 8.7 9.0 9.4 9.5 9.5 9.6 9.8 10.0 9.9 9.9

2010 9.8 9.8 9.9 9.9 9.6 9.4 9.4 9.5 9.5 9.4 9.8 9.3

2011 9.2 9.0 9.0 9.1 9.0 9.1 9.0 9.0 9.0 8.8 8.6 8.5

2012 8.3 8.3 8.2 8.2 8.2 8.2 8.2 8.0 7.8 7.8 7.7 7.9

2013 8.0 7.7 7.5 7.6 7.5 7.5 7.3 7.2 7.2 7.2 7.0 6.7

2014 6.6 6.7 6.6 6.2 6.3 6.1 6.2 6.1 5.9 5.7 5.8 5.6

2015 5.7 5.5 5.5 5.4 5.5 5.3 5.3

Unformatted Dataset- Original File

Page 26: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Year Average1995 5.61996 5.41997 4.91998 4.51999 4.22000 4.02001 4.72002 5.82003 6.02004 5.52005 5.12006 4.62007 4.62008 5.82009 9.32010 9.62011 8.92012 8.12013 7.42014 6.2

Editing the Source File

1. Deleted unnecessary information2. Reverse chronological order-check

it3. Created the average column,

simplify dataset4. Save the file in the format you

need

Page 27: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Looking at Boxplots for different time periods

1950s 1960s 1970's 1980s 1990s 2000s5.21 5.54 4.98 7.18 5.62 3.973.28 6.69 5.95 7.62 6.85 4.743.03 5.57 5.6 9.71 7.49 5.782.93 5.64 4.86 9.6 6.91 5.995.59 5.16 5.64 7.51 6.1 5.544.37 4.51 8.48 7.19 5.59 5.084.13 3.79 7.7 7 5.41 4.614.3 3.84 7.05 6.18 4.94 4.62

6.84 3.56 6.07 5.49 4.5 5.85.45 3.49 5.85 5.26 4.22 9.28

Page 28: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 29: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Hypothesis Testing

Determine at a 5% significance level if the average monthly Unemployment rate from year 2010 is greater then the historical average of 5.7%.

R Code for Student’s T-test:t.test(data, alternative = c(“greater"), mu = 5.7, conf.level = 0.95)

One Sample t-test

data: datat = 61.8571, df = 10, p-value = 1.482e-14alternative hypothesis: true mean is greater than 5.795 percent confidence interval: 9.521025 Infsample estimates:mean of x 9.636364

If the p-value < alpha reject the Null 0 < .05 Reject the NullConclude: The average monthly unemployment rate in 2010 greater than the historical mean.

Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Average

2010 9.8 9.8 9.9 9.9 9.6 9.4 9.4 9.5 9.5 9.4 9.8 9.3 9.6

Page 30: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Which Country has the highest unemployment rate

in 2014?

1. Italy2. France3. Greece4. Spain

Page 31: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Reference- “The Economist”, August 30th 2014, page 76-77

Country UnemploymentRate InterestRate10Year MiseryIndex Country UnemploymentRate InterestRate10Year MiseryIndexUnited States 6.2 2.38 8.58 Russia 4.9 9.35 14.25

China 4.1 4.02 8.12 Sweden 7.1 1.49 8.59Japan 3.7 0.5 4.2 Switzerland 3.2 0.56 3.76Britain 6.4 2.5 8.9 Turkey 8.8 9.08 17.88Canada 7 2.05 9.05 Australia 6.4 3.33 9.73

Euroarea 11.5 0.91 12.41 HongKong 3.3 1.93 5.23Austria 5 1.14 6.14 India 8.8 8.55 17.35Belgium 8.5 1.23 9.73 Malaysia 2.8 3.95 6.75France 10.2 1.25 11.45 Pakistan 6.2 13.33 19.53

Germany 6.7 0.91 7.61 Singapore 2 2.3 4.3Greece 27.2 5.67 32.87 SouthKorea 3.4 3.04 6.44

Italy 12.3 2.39 14.69 Taiwan 4 1.62 5.62Netherlands 8.2 1.1 9.3 Thailand 1.2 3.33 4.53

Spain 24.5 2.15 26.65 Brazil 4.9 11.46 16.36CzechRepublic 7.4 1.21 8.61 Chile 6.5 4.31 10.81

Denmark 5.1 1.23 6.33 Columbia 9.2 6.62 15.82Hungry 7.9 4.33 12.23 Mexico 5.2 7.75 12.95Norway 3.3 2.35 5.65 Venezuela 7.1 15.81 22.91Poland 11.9 3.06 14.96 Isreal 6.2 2.49 8.69

SouthAfrica 25.5 7.76 33.26

Unemployment Rate Interest Rate 10Year Misery IndexGlobal Average 7.83 4.11 11.94

Page 32: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 33: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Analyzing a portfolio of stocksData is from 1/2013 to 4/2013- daily returns

Apple Disney Facebook GeneralElectic Target Walmart-1.26 0.22 -0.82 -1.12 2.28 -0.64-2.79 1.91 3.56 0.47 0.7 0.38-0.59 -2.34 2.29 -0.33 1.19 -0.960.27 -0.41 -1.22 -1.09 -1.08 0.28-1.56 0.04 5.26 0.24 -0.76 -0.031.24 0.02 2.32 1.05 0.22 -0.31-0.61 -0.41 1.34 -0.19 -0.4 0.39

Apple Disney Facebook GeneralElectic Target WalmartApple 1.00 0.10 0.04 0.08 -0.13 0.01Disney 0.10 1.00 0.08 0.43 0.16 0.11

Facebook 0.04 0.08 1.00 0.11 -0.07 -0.16GeneralElectic 0.08 0.43 0.11 1.00 0.15 0.11

Target -0.13 0.16 -0.07 0.15 1.00 0.47Walmart 0.01 0.11 -0.16 0.11 0.47 1.00

Raw Data

Correlation Matrix

Page 34: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu
Page 35: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Regression Analysis-Anova

You want to predict the price of Target what stock will give you the best results?

lm(y~x) = lm(Target~Facebook) r = -.07

Coefficients:

Estimate t-value p-value

(Intercept) 0.24096

prices[, 3] -0.03158 -0.551 0.5836

Regression Line:

= .24096 - .03158 (returns of Facebook)

Analysis of Variance TableSum Sq

prices[, 3] 0.337Residuals 72.035Regression Identity: SST = SSR+SSE 72.372= .337 + 72.035

lm(y~x) = lm(Target~Walmart) r=.47

Coefficients:

Estimate t-value p-value

(Intercept) 0.1337

prices[, 6] 0.6349 4.285 6.17e-05

Regression Line:

= .1337 + .6349 (returns of Walmart)

Analysis of Variance Table Sum Sq prices[, 6] 15.940Residuals 56.431Regression Identity: SST = SSR+SSE 72.372= 15.94 + 56.431

Page 36: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Top 20 Jobs for New Graduates

Where do you think the job of “Statistician” ranks in the list of the top 20 jobs for new graduates based on mean salary, share of occupation that is under the age of 35 and projected job growth?

1. 1st to 5th

2. 6th to 10th

3. 11th to 15th

4. 16th to 20th

Page 37: Analyzing financial data in an Introductory Statistics Course Kelly Fitzpatrick, CFA Assistant Professor of Mathematics County College of Morris Kfitzpatrick@ccm.edu

Jobs for statisticians are expected to grow 27% more than double the

average of all other jobs.