Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 580

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 583

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 586

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 589

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 592

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673
{"id":319,"date":"2011-01-05T19:23:08","date_gmt":"2011-01-06T01:23:08","guid":{"rendered":"http:\/\/www.calculatinginvestor.com\/"},"modified":"2011-03-24T14:59:56","modified_gmt":"2011-03-24T19:59:56","slug":"fama-french-25-portfolio-averages","status":"publish","type":"page","link":"http:\/\/www.calculatinginvestor.com\/octave-code\/fama-french-25-portfolio-averages\/","title":{"rendered":"Fama-French 25 Portfolio Return Averages"},"content":{"rendered":"

Note:\u00a0\u00a0<\/strong>This page contains links to the data sources and the Octave source code which I used to generate the plots in my Visualizing the Small Cap and Value Effects <\/a>post.<\/em><\/p>\n

Data:<\/strong><\/p>\n

The data used to generate the plots comes from Kenneth French’s website<\/a>.\u00a0<\/p>\n

The\u00a0data was copied from the file named:\u00a0“25 Portfolios Formed on Size and Book-to-Market<\/em>”\u00a0\u00a0 Copy all rows of the value weighted return data (the first data set in the file, do not include the column headers) into a text file and save as “25_Portfolios_5x5_monthly.txt”.\u00a0 This file should be stored in the same directory from which you plan to run the Octave script.<\/p>\n

Code:<\/strong><\/p>\n

The Octave Code is shown here.\u00a0<\/p>\n

The code will prompt you for the date range to plot.\u00a0 The data starts in 1926, but there is some missing data prior to 1932 so January 1932 is the earliest date that should be used in the plotting.<\/p>\n

There is some commented out code in the file that can be modified if you wish to plot arithmetic averages rather than geometric averages.<\/p>\n

\r\nclear all; % clear data from Octave\r\nclose all; % close all open plot windows\r\n\r\n% Load Fama-French Data\r\nff_data = load('25_Portfolios_5x5_monthly.txt');\r\n\r\n% Starting point changed to January 1932 to avoid missing data\r\nff_data = ff_data(67:end,:); % start after NAs end\r\n\r\n% Remove date column\r\nr = ff_data(:,2:end);\r\n\r\n% Prompt for User Input to get plotting range\r\nstartyear = input('Enter Starting Year between 1932 and 2010: ')\r\nstartmonth = input('Enter Starting Month 1-12: ')\r\nendyear = input('Enter Ending Year between 1932 and 2009: ')\r\nendmonth = input('Enter Ending Month 1-12: ')\r\nplottitle = input('Enter Title for Plot: ','s')\r\n\r\n% Calculate starting and ending row\r\nstart = 12*(startyear - 1932) + startmonth;\r\nendpoint = 12*(endyear-1932) + endmonth;\r\n\r\n% Extract Desired Data\r\nr = r(start:endpoint,:);\r\n\r\n% Calculate Arithmetic Mean for each of 25 portfolios over range\r\narithmeans = mean(r);\r\n\r\n% Calculate Geometric Mean for each of 25 portfolios over selected range\r\ngeoreturns = r.\/100 + 1;\r\ngeomeans = 100*(exp(mean(log(georeturns)))-1);\r\n\r\n% Select if Geometric or Arithmetic mean is used by adjusting comments\r\n%meanreturns = arithmeans; % uncomment to use arithmetic means\r\nmeanreturns = geomeans; % uncomment to use geometric means\r\n\r\n% Expand 5x5 data to 10x10 for use in surface plot function\r\nreturns = [meanreturns ; meanreturns];\r\nreturns = reshape(returns,10,5);\r\nreturns = [returns;returns]\r\nreturns = reshape(returns,10,10);\r\n\r\n% Define x and y values\r\nx = [0 0.999 1 1.999 2 2.999 3 3.999 4 5];\r\ny = [0 0.999 1 1.999 2 2.999 3 3.999 4 5];\r\n\r\n% Create x-y mesh for surface plot\r\n[xx,yy] = meshgrid(x,y);\r\n\r\n% Generate Plot\r\nsurf(xx,yy,returns)\r\nxlabel('Size','fontsize',20)\r\nylabel('Value','fontsize',20)\r\n%zlabel('Arithmetic Average Monthly Return (%)','rotation',90,'fontsize',20)\r\nzlabel('Geometric Average Monthly Return (%)','rotation',90,'fontsize',20)\r\ntitle(plottitle,'fontsize',36)\r\naxis([0 5 0 5 min(0,min(meanreturns)-.1) max(2,max(meanreturns)+0.01)])\r\ntext(4.5,0.5,meanreturns(21),'LG','horizontalalignment','center','fontsize',18)\r\ntext(4.5,4.5,meanreturns(25),'LV','horizontalalignment','center','fontsize',18)\r\ntext(0.5,4.5,meanreturns(5),'SV','horizontalalignment','center','fontsize',18)\r\ntext(0.5,0.5,meanreturns(1),'SG','horizontalalignment','center','fontsize',18)\r\n\r\n% Color range set from 0 to 1.6 rather than allowing autoscale.\r\n% This is done for easier comparison between plots, but colors will\r\n% max out for values above 1.6 or below 0.\r\n% For arithmetic averages, I think a range of 0 to 2 works better\r\ncaxis([0 1.6]);\r\nview(50, 25);\r\nreplot\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Note:\u00a0\u00a0This page contains links to the data sources and the Octave source code which I used to generate the plots in my Visualizing the Small Cap and Value Effects post. Data: The data used to generate the plots comes from Kenneth French’s website.\u00a0 The\u00a0data was copied from the file named:\u00a0“25 Portfolios Formed on Size and […]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":145,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/319"}],"collection":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":20,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/319\/revisions"}],"predecessor-version":[{"id":737,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/319\/revisions\/737"}],"up":[{"embeddable":true,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/145"}],"wp:attachment":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/media?parent=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}