<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Portfolio Probe</title>
	<atom:link href="https://www.portfolioprobe.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.portfolioprobe.com</link>
	<description>Professional software for the fund management industry</description>
	<lastBuildDate>Sun, 29 May 2016 19:05:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>
	<item>
		<title>Reminiscences of R in Finance 2016</title>
		<link>https://www.portfolioprobe.com/r-language/reminiscences-of-r-in-finance-2016/</link>
					<comments>https://www.portfolioprobe.com/r-language/reminiscences-of-r-in-finance-2016/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 29 May 2016 19:05:16 +0000</pubDate>
				<category><![CDATA[Quant finance]]></category>
		<category><![CDATA[R language]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=12326</guid>

					<description><![CDATA[When I announced R in Finance 2016 I talked about 2 days of conference and 50 speakers.  I missed out the 3 days of sleep deprivation. But a pleasant 3 days of sleep deprivation it was -- seeing old friends and making new ones. I'm not sure that Mother Mary believed me that in our  [...]]]></description>
										<content:encoded><![CDATA[<p>When I announced <a href="http://www.rinfinance.com/" target="_blank">R in Finance</a> 2016 I talked about 2 days of conference and 50 speakers.  I missed out the 3 days of sleep deprivation.</p>
<p>But a pleasant 3 days of sleep deprivation it was &#8212; seeing old friends and making new ones.</p>
<p>I&#8217;m not sure that Mother Mary believed me that in our house we still use the mug from the original R in Finance.  Here&#8217;s proof that it still survives when so many of its comrades have perished.</p>
<p><a href="https://www.portfolioprobe.com/wp-content/uploads/2016/05/mug_R_in_finance-1.jpg" rel="attachment wp-att-12328"><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-12328" src="https://www.portfolioprobe.com/wp-content/uploads/2016/05/mug_R_in_finance-1.jpg" alt="mug_R_in_finance" width="480" height="640" /></a></p>
<p>&nbsp;</p>
<p>I had great fun giving my presentation.  The <a href="http://www.burns-stat.com/documents/presentations/linguistics-quantitative-finance/" target="_blank">annotated slides and source for the R package</a> are available on the Burns Statistics website.</p>
<h2>Highlights</h2>
<p>There were lots of good parts.  I&#8217;ll limit myself to three (three is the largest number of chunks that people can easily remember).</p>
<h3>First</h3>
<p>Ahead by 1609.344 meters is Doug Service.  Universally my experience with talks involving stochastic calculus is that my eyes glaze over before the first dW drops.  At the start of Doug&#8217;s presentation my eyes were doing their cross-check preparing for landing.  But the landing never happened.  I have no real idea of what the equations were about &#8212; that didn&#8217;t matter: Doug made the idea of what he was doing perfectly clear.</p>
<p>If you insist on having formulas in your presentation (I highly discourage you from such a point of view), then you <strong>must</strong> track Doug down and <strong>make</strong> him teach you how to do it right.</p>
<h3>Second</h3>
<p>Second is Dirk&#8217;s update on the package interfacing Bloomberg with R:</p>
<p>Last year I said A.</p>
<p>So I lied.</p>
<p>Actually &#8230;</p>
<p>Last year I said B.</p>
<p>So I lied.</p>
<p>Actually &#8230;</p>
<p>Last year I said C.</p>
<p>So I lied.</p>
<p>Actually &#8230;</p>
<p>(You should be starting to see a pattern.)</p>
<h3>Third</h3>
<p>Tied for third are:</p>
<p>Matt Dziubinski&#8217;s high performance talk.  High performance was the topic and high performance was the delivery.  Clearly Matt has at least four cores dedicated to his mouth, with negligible latency.</p>
<p>Bryan Lewis&#8217; politics of big data hardware implementation structures.</p>
<h2>In the end</h2>
<p>The taxi back to the airport was flanked by a full moon on the left and the rising sun on the right.</p>
<p><em>I was born to rock the boat<br />
Some may sink but we will float</em><br />
&#8212; from &#8220;Mutineer&#8221; by Warren Zevon<br />
<iframe src="https://www.youtube.com/embed/MqWqyjUsCAw" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/reminiscences-of-r-in-finance-2016/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>R in Finance and other events</title>
		<link>https://www.portfolioprobe.com/r-language/r-in-finance-and-other-events/</link>
					<comments>https://www.portfolioprobe.com/r-language/r-in-finance-and-other-events/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sat, 16 Apr 2016 10:10:40 +0000</pubDate>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[R language]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=12277</guid>

					<description><![CDATA[Highlighted R in Finance 2016 May 20-21, Chicago. 2 days, limited space, 50 speakers, including: Pat Burns on "Some Linguistics of Quantitative Finance" Abstract: How can the abstract be written for a talk with an ambiguous and possibly misleading title without itself being vague and misleading? I don't know, but perhaps: A quest to discover how markets work  [...]]]></description>
										<content:encoded><![CDATA[<h2>Highlighted</h2>
<h3>R in Finance</h3>
<p>2016 May 20-21, Chicago.</p>
<p>2 days, limited space, 50 speakers, including:</p>
<p>Pat Burns on &#8220;Some Linguistics of Quantitative Finance&#8221;</p>
<p><strong>Abstract</strong>: How can the abstract be written for a talk with an ambiguous and possibly misleading title without itself being vague and misleading? I don&#8217;t know, but perhaps: A quest to discover how markets work that starts in the Yucatan.</p>
<p>See the <a href="http://www.rinfinance.com/" target="_blank">conference website</a>.</p>
<h2>Other Events</h2>
<h3>London Quant Group Spring Seminar</h3>
<p>2016 May 12, London.</p>
<p>See the <a href="http://www.lqg.org.uk/" target="_blank">LQG website</a> for details.</p>
<h3>Forecasting Financial Markets</h3>
<p>2016 May 25-27. Hanover.</p>
<p>See the <a href="http://www.ffmconference.com/" target="_blank">conference website</a> for details.</p>
<h3> UseR! 2016</h3>
<p>2016 June 27-30. Stanford.  Apparently sold out.</p>
<p><a href="http://user2016.org/" target="_blank">The UseR! 2016 website</a>.</p>
<h3>London Quant Group Autumn Seminar</h3>
<p>2016 September 11-14, Oxford. 30th annual celebration event.</p>
<p>See the <a href="http://www.lqg.org.uk/" target="_blank">LQG website</a> for details.</p>
<h3>EARL 2016</h3>
<p>2016 September 13-15, London. Effective Applications of the R Language.<br />
See the <a href="https://earlconf.com/london/" target="_blank">EARL conference website</a> for details.</p>
<h2>Even more events</h2>
<p><strong>MoneyScience</strong> has an <a href="http://www.moneyscience.com/pg/events?range=month" target="_blank">events calendar.</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/r-in-finance-and-other-events/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Review of &#8220;Money, Blood and Revolution&#8221; by George Cooper</title>
		<link>https://www.portfolioprobe.com/book-review/review-of-money-blood-and-revolution-by-george-cooper/</link>
					<comments>https://www.portfolioprobe.com/book-review/review-of-money-blood-and-revolution-by-george-cooper/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 28 Sep 2014 16:21:42 +0000</pubDate>
				<category><![CDATA[Book review]]></category>
		<category><![CDATA[Economics]]></category>
		<category><![CDATA[circulatory growth model]]></category>
		<category><![CDATA[Kuhn paradigm shift]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11604</guid>

					<description><![CDATA[How Darwin and the doctor of King Charles I could turn economics into a science. Executive summary If you are confused by economics, then you should read this book.  If you are not confused by economics, then you really, really need to read this book. The book is inexpensive, not very long, and it's important  [...]]]></description>
										<content:encoded><![CDATA[<p>How Darwin and the doctor of King Charles I could turn economics into a science.</p>
<p><a href="https://www.portfolioprobe.com/wp-content/uploads/2014/09/money-blood-and-revolution.jpg" rel="attachment wp-att-11605"><img decoding="async" class="aligncenter size-full wp-image-11605" src="https://www.portfolioprobe.com/wp-content/uploads/2014/09/money-blood-and-revolution.jpg" alt="money-blood-and-revolution" width="320" height="480" /></a></p>
<h2>Executive summary</h2>
<p>If you are confused by economics, then you should read this book.  If you are <strong>not</strong> confused by economics, then you really, really need to read this book.</p>
<p>The book is inexpensive, not very long, and it&#8217;s important &#8212; there is no reason not to read it and good reason to read it (including some splashes of humor).</p>
<h2>Structure</h2>
<p>The book starts by explaining four seemingly random scientific revolutions:</p>
<ul>
<li>The earth goes around the sun, rather than vice versa</li>
<li>Blood <strong>circulates</strong> in the body</li>
<li>Natural selection via survival of the fittest</li>
<li>Continental drift and plate tectonics</li>
</ul>
<p>By the end of the book we see that this isn&#8217;t such a random selection of scientific issues after all.</p>
<p>Then there is a chapter that explains the viewpoints of the various economic schools.  This is the clearest explanation of the economic camps that I&#8217;ve ever seen &#8212; it erased several points of confusion for me.</p>
<p>Finally, a synthesis of the warring factions is proposed that explains many of the anomalies.  George calls this the <em>circulatory growth model</em>.  It must be a good model &#8212; there&#8217;s something in it for pretty much everyone to hate.</p>
<h2>Blindness</h2>
<p>People tend to ignore what their theories don&#8217;t explain.  Economists have learned this well:</p>
<ul>
<li>luxury goods should not exist</li>
<li>I should always buy the cheapest of anything</li>
<li>the size of my neighbor&#8217;s television shouldn&#8217;t affect the size of television I want</li>
<li>economic growth should be more randomly scattered through time, and location</li>
</ul>
<p>But there is one thing that is ignored in spectacular fashion &#8212; government spending. Many economists act as if government doesn&#8217;t exist at all.  There&#8217;s a disease like that:</p>
<p style="padding-left: 30px;"><em>Patients with <a href="http://en.wikipedia.org/wiki/Hemispatial_neglect" target="_blank">unilateral neglect</a> behave not only as if nothing were actually happening in the left hemispace, but also as if nothing of any importance could be expected to occur there.</em></p>
<p>&#8212; from <em>The Man Who Mistook His Wife For A Hat</em> by Oliver Sacks</p>
<h2>Quotes</h2>
<p style="padding-left: 30px;"><em>It appears that we humans cannot accept having no theory &#8230; we cannot be persuaded to step from a wrong theory into the abyss while we wait for a better theory to come along.  This is why, regardless of how many times the behaviour of the economy refutes current economic theory, that theory will not be rejected until a better model is proposed.</em></p>
<p style="padding-left: 30px;"><em>&#8230; small government, light regulation and low taxation is the economic condition that has persisted across most of the world through all of history.  Why then has the world not been plagued by a permanent growth-boom lasting thousands of years?</em></p>
<p style="padding-left: 30px;"><em>In 2008&#8230; everyone suddenly rejected the silly notion of an inherently stable economy and embraced Minsky&#8217;s idea of an inherently unstable economy &#8230; In the years since 2008, <a href="https://www.portfolioprobe.com/2014/09/21/effective-risk-management-with-r/">Minsky has been forgotten</a> and the herd has quickly drifted back to recolonise the neoclassical zone, conveniently forgetting that it ever left.</em></p>
<p style="padding-left: 30px;"><em>&#8230; to understand and describe</em> [our current economy] <em>cannot be achieved by building abstract models of imaginary alternate economies, where governments are absent, markets are perfect and people act as machines rather than humans.</em></p>
<h2>Favorite sentence</h2>
<p style="padding-left: 30px;"><em>With democratic capitalism we have inadvertently stumbled upon a system that lets us exploit the best of our competitive nature while managing the worst of our selfish nature.  We should celebrate this triumph.</em></p>
<h2>Quibbles</h2>
<p>I think that the dissipation of the happiness of lottery winners is a more complex phenomenon than the book implies.</p>
<p>Great as it is, I think there is something missing from the circulatory growth model.  I&#8217;m not sure what is missing though.</p>
<h2>Related books</h2>
<p><a href="https://www.portfolioprobe.com/2012/03/19/review-of-the-origin-of-financial-crises-by-george-cooper/">I&#8217;ve reviewed <em>The Origin of Financial Crises</em></a>, George&#8217;s previous book.  The books are related, but I don&#8217;t see that it matters which you read first.</p>
<p>A great book that is surprisingly not referenced is <em>The Truth about Markets</em> by John Kay.  This supports the argument that suitable institutions are necessary for economic growth.</p>
<h2>Follow-up action</h2>
<p style="padding-left: 30px;"><em>Kuhn&#8217;s final blow to the ego of scientists was his observation that the vanguard of the new paradigm is usually led by non-expert outsiders.  These outsiders are often thoroughly frustrated with the confusion of the old order and eager to accept the clarity of a new idea.</em></p>
<p>If Kuhn is correct, then we can&#8217;t leave it to economists to sort themselves out.  The stakes of getting economics right can&#8217;t be higher.</p>
<p>Suggested next steps:</p>
<ul>
<li>Read <a href="http://georgecooper.org/" target="_blank">George&#8217;s blog</a></li>
<li>Follow George on Twitter: <a href="https://twitter.com/george_cooper__" target="_blank">@george_cooper__</a></li>
<li>Tell your friends</li>
</ul>
<h2>Epilogue</h2>
<p style="padding-left: 30px;"><strong>Brian</strong>: <em>You&#8217;ve got to think for yourselves.  You&#8217;re all individuals.</em></p>
<p style="padding-left: 30px;"><strong>Crowd</strong> (in unison): <em>Yes, we&#8217;re all individuals.</em></p>
<p style="padding-left: 30px;"><strong>Brian</strong>: <em>You&#8217;re all different.</em></p>
<p style="padding-left: 30px;"><strong>Crowd</strong> (in unison): <em>Yes, we&#8217;re all different.</em></p>
<p style="padding-left: 30px;"><strong>Lone voice</strong>: <em>I&#8217;m not.</em></p>
<p>from <em>The Life of Brian</em> by Monty Python</p>
<p><iframe src="//www.youtube.com/embed/jVygqjyS4CA" width="520" height="390" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/book-review/review-of-money-blood-and-revolution-by-george-cooper/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Effective risk management with R</title>
		<link>https://www.portfolioprobe.com/r-language/effective-risk-management-with-r/</link>
					<comments>https://www.portfolioprobe.com/r-language/effective-risk-management-with-r/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 21 Sep 2014 15:12:17 +0000</pubDate>
				<category><![CDATA[R language]]></category>
		<category><![CDATA[Risk]]></category>
		<category><![CDATA[Hyman Minsky]]></category>
		<category><![CDATA[Minsky Instability Hypothesis]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11614</guid>

					<description><![CDATA[Conference The first EARL Conference (Effective Applications of the R Language) was held 2014 September 15-17 in London. Talk My talk was "Effective risk management with R" (annotated slides). Instability hypothesis When I was preparing for the talk, one of my ideas was to show the Google trend for searches for Minsky's instability hypothesis.  I  [...]]]></description>
										<content:encoded><![CDATA[<h2>Conference</h2>
<p>The first <a href="http://www.earl-conference.com/" target="_blank">EARL Conference</a> (Effective Applications of the R Language) was held 2014 September 15-17 in London.</p>
<h2>Talk</h2>
<p>My talk was <a href="http://www.burns-stat.com/documents/presentations/effective-risk-management-r/" target="_blank">&#8220;Effective risk management with R&#8221; (annotated slides)</a>.</p>
<h2>Instability hypothesis</h2>
<p>When I was preparing for the talk, one of my ideas was to show the Google trend for searches for Minsky&#8217;s instability hypothesis.  I thought it would look a lot like Figure 1.</p>
<p>Figure 1: My guess of interest in the instability hypothesis over time. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/09/minskyprior1.png" rel="attachment wp-att-11616"><img decoding="async" class="aligncenter size-full wp-image-11616" src="https://www.portfolioprobe.com/wp-content/uploads/2014/09/minskyprior1.png" alt="minskyprior" width="512" height="480" /></a>My impression is that the instability hypothesis is pretty much totally ignored except immediately following market crashes.  That&#8217;s the sort of thinking that allows the pattern to continue.</p>
<p>Figure 2: Google trend for: minsky instability hypothesis.<br />
<script src="//www.google.com/trends/embed.js?hl=en-US&amp;q=minsky+instability+hypothesis&amp;content=1&amp;cid=TIMESERIES_GRAPH_0&amp;export=5&amp;w=500&amp;h=330"></script><br />
The trend that I actually saw was severely different from <a href="https://www.portfolioprobe.com/2012/09/03/a-look-at-bayesian-statistics/">my prior</a>.  This leads me to pretty much entirely discount the data.  Part of the problem is the small number of searches at any time.</p>
<h2>Epilogue</h2>
<p style="padding-left: 30px;"><em><span style="color: #000000;">I&#8217;ll tell ya truly that I sometimes lie</span></em></p>
<p>&#8212; from &#8220;What Kinda Guy?&#8221; by Steve Forbert<br />
<iframe src="//www.youtube.com/embed/5kno1CN-rDc" width="520" height="293" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/effective-risk-management-with-r/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>EARL and other upcoming events</title>
		<link>https://www.portfolioprobe.com/r-language/earl-and-other-upcoming-events/</link>
					<comments>https://www.portfolioprobe.com/r-language/earl-and-other-upcoming-events/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Mon, 28 Jul 2014 18:52:33 +0000</pubDate>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[R language]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11528</guid>

					<description><![CDATA[Highlighted EARL As in "Effective Applications of the R Language". 2014 September 15-17, London. Somehow they gave higher billing to Ben Goldacre than to Pat Burns.  If Obama were coming, they'd probably bill him above me too -- and what does he know about R?  In spite of that little glitch, I'm sure it will  [...]]]></description>
										<content:encoded><![CDATA[<h2>Highlighted</h2>
<h3>EARL</h3>
<p>As in &#8220;Effective Applications of the R Language&#8221;.</p>
<p>2014 September 15-17, London.</p>
<p>Somehow they gave higher billing to <a href="http://www.badscience.net" target="_blank">Ben Goldacre</a> than to Pat Burns.  If Obama were coming, they&#8217;d probably bill him above me too &#8212; and what does he know about R?  In spite of that little glitch, I&#8217;m sure it will be a good time.</p>
<p>See the <a href="http://www.earl-conference.com/" target="_blank">conference website</a>.</p>
<h2>New Events</h2>
<h3>QWAFAFEW &#8212; New York</h3>
<p>2014 August 26.  <a href="http://qwafafew.org/index.php/events/page/correcting_quantitative_finances_erroneous_understanding_calculations_of_ma/new_york" target="_blank">Correcting quantitative finance&#8217;s erroneous understanding and calculations of mathematical averaging</a></p>
<h3>London Quant Group Autumn Seminar</h3>
<p>2014 September 7-10, Oxford.</p>
<p>See the <a href="http://www.lqg.org.uk/" target="_blank">LQG website</a> for details.</p>
<h3>14-10 Club</h3>
<p>2014 September 11.</p>
<p>&#8220;Bitcoin: a human reaction to centralisation&#8221; and &#8220;Happiness by Design&#8221;.</p>
<p>Details at <a href="http://www.rigb.org/globals/join-support/14-10-club/events" target="_blank">the 14-10 website</a>.</p>
<h3>London Quant Group</h3>
<p>2014 October 7, London.</p>
<p>See the <a href="http://www.lqg.org.uk/" target="_blank">LQG website</a> for details.</p>
<h3>14-10 Club</h3>
<p>2014 October 9.</p>
<p>&#8220;Advanced internal funding process for banks&#8221; and &#8220;Behavioural Finance&#8221;.</p>
<p>Details at <a href="http://www.rigb.org/globals/join-support/14-10-club/events" target="_blank">the 14-10 website</a>.</p>
<h3>14-10 Club</h3>
<p>2014 November 6.</p>
<p>&#8220;What can science teach business (and vice versa)&#8221; and &#8220;Physics of Finance&#8221;.</p>
<p>Details at <a href="http://www.rigb.org/globals/join-support/14-10-club/events" target="_blank">the 14-10 website</a>.</p>
<h3>London Quant Group</h3>
<p>2014 November 11, London.</p>
<p>See the <a href="http://www.lqg.org.uk/" target="_blank">LQG website</a> for details.</p>
<h3>London Quant Group</h3>
<p>2014 December 8, London.</p>
<p>See the <a href="http://www.lqg.org.uk/" target="_blank">LQG website</a> for details.</p>
<h3>14-10 Club</h3>
<p>2014 December 10.</p>
<p>&#8220;Hedge funds turn to psychology software&#8221; and &#8220;The softer side of physics&#8221;.</p>
<p>Details at <a href="http://www.rigb.org/globals/join-support/14-10-club/events" target="_blank">the 14-10 website</a>.</p>
<h3>Computational and Financial Econometrics 2014</h3>
<p>2014 December 6 &#8211; 8, Pisa.</p>
<p>Details at the <a href="http://www.cfenetwork.org/CFE2014/" target="_blank">conference website</a>.</p>
<h2>Even more events</h2>
<p><strong>MoneyScience</strong> has an <a href="http://www.moneyscience.com/pg/events?range=month" target="_blank">events calendar.</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/earl-and-other-upcoming-events/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>BurStFin R package version 1.02 released</title>
		<link>https://www.portfolioprobe.com/r-language/burstfin-r-package-version-1-02-released/</link>
					<comments>https://www.portfolioprobe.com/r-language/burstfin-r-package-version-1-02-released/#respond</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 16 Mar 2014 18:11:56 +0000</pubDate>
				<category><![CDATA[Quant finance]]></category>
		<category><![CDATA[R language]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11365</guid>

					<description><![CDATA[More efficiency and an additional function in the new version on CRAN. Variance estimation The major functionality in the package is variance estimation: Ledoit-Wolf shrinkage via var.shrink.eqcor statistical factor model (principal components) via factor.model.stat There have been a number of previous blog posts on both factor models and Ledoit-Wolf shrinkage. Positive-definiteness The default value of  [...]]]></description>
										<content:encoded><![CDATA[<p>More efficiency and an additional function in the new version on <a href="http://cran.r-project.org/web/packages/BurStFin/index.html" target="_blank">CRAN</a>.</p>
<h2>Variance estimation</h2>
<p>The major functionality in the package is variance estimation:</p>
<ul>
<li>Ledoit-Wolf shrinkage via <code>var.shrink.eqcor</code></li>
<li>statistical factor model (principal components) via <code>factor.model.stat</code></li>
</ul>
<p>There have been a number of previous blog posts on both <a href="https://www.portfolioprobe.com/tag/factor-model/">factor models</a> and <a href="https://www.portfolioprobe.com/tag/ledoit-wolf-shrinkage/">Ledoit-Wolf shrinkage</a>.</p>
<h3>Positive-definiteness</h3>
<p>The default value of the <code>tol</code> argument to <code>var.shrink.eqcor</code> is different in the new version.  The blog post <a href="https://www.portfolioprobe.com/2012/05/22/correlations-and-postive-definiteness/">&#8220;Correlations and positive-definiteness&#8221;</a> suggested that the previous default was too extreme.</p>
<p>In finance we almost always want a variance matrix to definitely be positive-definite.  This is <a href="https://www.portfolioprobe.com/2012/07/09/alpha-alignment/">especially true when doing optimization</a>.  Positive-definite means that all eigenvalues are greater than zero.  The <code>tol</code> argument in <code>var.shrink.eqcor</code> gives the minimum size of an eigenvalue in the result relative to the largest eigenvalue.</p>
<p>An eigenvalue of zero means that the variance matrix is saying that there is a portfolio (described by the corresponding eigenvector) that has zero variance.  An optimizer is going to really, really like such a portfolio &#8212; who wouldn&#8217;t?</p>
<p>The previous default for <code>tol</code> was 0.001.  The new default is 0.0001.  This is still a guess, but hopefully a more appropriate guess.</p>
<h3>Efficiency</h3>
<p>Both the input matrix and the resulting variance matrix can be large.  Financial applications often have a few thousand assets in a variance.  If there are multiple copies of these large objects within the function evaluation, that can be enough to push memory use over the limit in a computation.</p>
<p>Originally <code>var.shrink.eqcor</code> and <code>factor.model.stat</code> were written to get the computations right rather than worrying about memory or time efficiency.  (That&#8217;s <a href="http://www.burns-stat.com/documents/books/tao-te-programming/" target="_blank">the right order in which to worry</a>.)  The new version uses fewer copies of the large objects.  That change accidentally sped up <code>factor.model.stat</code> a little.</p>
<p>If you run out of memory using one of these two functions, then:</p>
<p>First consider moving to 64-bit if you are still using 32-bit &#8212; R runs the same on either.  If you are on 64-bit already, consider getting more RAM (an application of Uwe&#8217;s maxim).</p>
<p>Next, you could try to make your code more efficient.  In particular, avoid Circle 2 of <a href="http://www.burns-stat.com/documents/books/the-r-inferno/" target="_blank"><em>The R Inferno</em></a>.</p>
<p>If none of that is applicable, then you may want to take evasive action.  <code>var.shrink.eqcor</code> uses more memory than <code>factor.model.stat</code>.  If you run out of memory with <code>factor.model.stat</code>, then you can set <code>iter.max=0</code> to save some memory (and time) at the expense of a (probably) slightly worse estimate.</p>
<h3> Weird data</h3>
<p>Real data (financial and other) tend not to be nice textbook examples.  Often there are missing values.  In finance we even want to have variables (assets) in a variance matrix that have no data at all.</p>
<p>One of many possible <a href="https://www.portfolioprobe.com/2013/10/07/the-look-of-verifying-data/">data glitches in finance</a> is for a price to get stuck on one value.  This translates to returns that are all zero.  Zero is an underestimate of the variance of an asset, and most likely suggests there is a data problem.  But that isn&#8217;t true of all settings.  <code>factor.model.stat</code> has an argument called <code>constant.returns.okay</code>.  The new version produces a different &#8212; that is, not backward-compatible &#8212; result when this argument is <code>TRUE</code> (which is not the default).</p>
<p>It is reasonable to view the previous behavior regarding this argument to be a bug:  All correlations involving the variable are zero and the variance is a certain quantile of the variances of the other variables.  The new behavior is to set the variance to zero as well.</p>
<p>Probably the best thing to do when confronted with this is to set the constant returns to missing values.</p>
<p>A possible self-inflicted weirdness is to give the variance estimators <a href="https://www.portfolioprobe.com/2011/01/12/the-number-1-novice-quant-mistake/">prices rather than returns</a>.  By default the functions produce a warning if the input data are all non-negative.</p>
<h2>Time weights</h2>
<p>Financial markets are dynamic.  That means that old data goes stale.  The most typical approach to this problem is to equally weight some number of the most recent observations.  The default weighting in <code>var.shrink.eqcor</code> and <code>factor.model.stat</code> is to linearly decrease weights in such a way that the oldest observation given has one-third the weight of the most recent.</p>
<p>The new function in the package, called <code>slideWeight</code>, allows both of these, plus compromises between them.  The typical shape of weights from this function is shown in Figure 1.</p>
<p>Figure 1: Slide weights where 50 observations have full weight and 170 have some weight. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/03/slideweight.png" rel="attachment wp-att-11366"><img decoding="async" class="aligncenter size-full wp-image-11366" alt="slideweight" src="https://www.portfolioprobe.com/wp-content/uploads/2014/03/slideweight.png" width="512" height="480" /></a></p>
<p>The <code>slideWeight</code> function lets you specify a certain number of observations to have full weight, and a value beyond which all weights are zero.  The weights fall linearly between these two points.</p>
<h2>See also</h2>
<p>If you are new to R, <a href="https://www.portfolioprobe.com/user-area/some-hints-for-the-r-beginner/">learning R</a> may be easier than you think.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/burstfin-r-package-version-1-02-released/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>A complicated answer to a simple correlation question</title>
		<link>https://www.portfolioprobe.com/r-language/a-complicated-answer-to-a-simple-correlation-question/</link>
					<comments>https://www.portfolioprobe.com/r-language/a-complicated-answer-to-a-simple-correlation-question/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 09 Feb 2014 17:37:25 +0000</pubDate>
				<category><![CDATA[Quant finance]]></category>
		<category><![CDATA[R language]]></category>
		<category><![CDATA[correlations]]></category>
		<category><![CDATA[statistical bootstrap]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11299</guid>

					<description><![CDATA[A data analysis surprise party. Simple question If I have correlation matrices each estimated with a month of daily returns, how much worse is the average of six of those compared to the estimate with six months of daily data? Expected answer Do a statistical bootstrap with the returns and compare the standard deviations across  [...]]]></description>
										<content:encoded><![CDATA[<p>A data analysis surprise party.</p>
<h2>Simple question</h2>
<p>If I have correlation matrices each estimated with a month of daily returns, how much worse is the average of six of those compared to the estimate with six months of daily data?</p>
<h2>Expected answer</h2>
<p>Do a <a href="http://www.burns-stat.com/documents/tutorials/the-statistical-bootstrap-and-other-resampling-methods-2/" target="_blank">statistical bootstrap</a> with the returns and compare the standard deviations across bootstrap samples for each correlation.  This will show how much bigger the monthly standard deviations are compared to the daily standard deviations.</p>
<h2>Return data</h2>
<p>We use 126 daily (essentially 2012 H2) returns of 100 large cap US stocks.  Figure 1 is a scatter plot of the 4950 correlations estimated with the two methods.</p>
<p>Figure 1: Correlations of returns estimated by mean monthly versus daily. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cordmscat.png" rel="attachment wp-att-11308"><img decoding="async" class="aligncenter size-full wp-image-11308" alt="cordmscat" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cordmscat.png" width="512" height="480" /></a></p>
<p><strong>Surprise #1</strong>: Figure 1 is not boring.</p>
<p>Figure 2 compares the standard deviations of bootstraps of the two estimation methods.</p>
<p>Figure 2: Standard deviations across bootstrap samples of the monthly estimation versus daily estimation. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bootsdscat.png" rel="attachment wp-att-11309"><img decoding="async" class="aligncenter size-full wp-image-11309" alt="bootsdscat" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bootsdscat.png" width="512" height="480" /></a></p>
<p><strong>Surprise #2</strong>: The wrong estimator tends to be more variable.</p>
<h2>Random normal data</h2>
<p>We can experiment:  Create new data shaped like our original data but that is randomly generated as multivariate normal with correlation equal to the daily estimate.</p>
<p>Figure 3 is like Figure 1 but for the normal data.</p>
<p>Figure 3: Correlation estimates: monthly versus daily for the <strong>randomly generated normal</strong> data. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cnormdmscat.png" rel="attachment wp-att-11314"><img decoding="async" class="aligncenter size-full wp-image-11314" alt="cnormdmscat" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cnormdmscat.png" width="512" height="480" /></a></p>
<p><strong>Semi-surprise #1</strong>: Figure 3 is boring, unlike Figure 1.</p>
<p>We know that the bootstrap is appropriate for the normal data: the observations are independent and identically distributed &#8212; perfect for the bootstrap.  Figure 4 is the normal data version of Figure 2.</p>
<p>Figure 4: Standard deviations across bootstrap samples of the monthly estimation versus daily estimation of the randomly generated normal data. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bnormsdscat1.png" rel="attachment wp-att-11315"><img decoding="async" class="aligncenter size-full wp-image-11315" alt="bnormsdscat" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bnormsdscat1.png" width="512" height="480" /></a></p>
<p>Now that we have fake data for which we actually know the true value of the correlations, we can look at the mean squared error of the estimates.  This is done in Figure 5.</p>
<p>Figure 5: Mean squared errors (MSE) across bootstrap samples of the monthly estimation versus daily estimation of the randomly generated normal data. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bnormmsescat1.png" rel="attachment wp-att-11316"><img decoding="async" class="aligncenter size-full wp-image-11316" alt="bnormmsescat" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bnormmsescat1.png" width="512" height="480" /></a></p>
<p><strong>Surprise #3</strong>: There&#8217;s hardly any difference at all between the quality of the two estimates for the normal data.</p>
<h2>Back to reality</h2>
<p>We can highlight the correlations where the two methods differ significantly, as shown in Figure 6.</p>
<p>Figure 6: Correlations estimated by mean monthly versus daily with strange points highlighted (in magenta). <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cordmscatsel1.png" rel="attachment wp-att-11317"><img decoding="async" class="aligncenter size-full wp-image-11317" alt="cordmscatsel" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cordmscatsel1.png" width="512" height="480" /></a></p>
<p>Figure 7 shows where those highlighted points show up in the plot of bootstrap standard deviations.</p>
<p>Figure 7: Standard deviations across bootstrap samples of the monthly estimation versus daily estimation with correlation outliers highlighted. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bootsdscatsel.png" rel="attachment wp-att-11318"><img decoding="async" class="aligncenter size-full wp-image-11318" alt="bootsdscatsel" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bootsdscatsel.png" width="512" height="480" /></a></p>
<p><strong>Surprise #4</strong>: The disagreement over negative daily correlations does not explain the relatively low variability of the monthly estimates &#8212; at least not entirely.</p>
<p>Note that both standard deviations for the real data tend to be larger than for the normal data.</p>
<p>We can define weird the other way around: define extreme in terms of the bootstrap standard deviations and then see where those show up in the correlation scatterplot.  This is Figures 8 and 9.</p>
<p>Figure 8: Standard deviations across bootstrap samples of the monthly estimation versus daily estimation with standard deviation outliers highlighted. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bootsdscatsel1.png" rel="attachment wp-att-11319"><img decoding="async" class="aligncenter size-full wp-image-11319" alt="bootsdscatsel" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/bootsdscatsel1.png" width="512" height="480" /></a></p>
<p>Figure 9: Correlations estimated by mean monthly versus daily with standard deviation outliers highlighted. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cordmscatwei.png" rel="attachment wp-att-11320"><img decoding="async" class="aligncenter size-full wp-image-11320" alt="cordmscatwei" src="https://www.portfolioprobe.com/wp-content/uploads/2014/02/cordmscatwei.png" width="512" height="480" /></a></p>
<h2>Summary</h2>
<p>I don&#8217;t know what is going on.  There is some sort of dependence that is showing up in the correlations of the returns.  Part of the puzzle is probably that return correlations (and means) are not constant through time.</p>
<h2>Epilogue</h2>
<p style="padding-left: 30px;"><em>Complications in the air</em><br />
<em>Complications in the forecast now</em><br />
<em>Complication everywhere</em></p>
<p>from &#8220;Complications&#8221; by Steve Forbert<br />
<iframe src="//www.youtube.com/embed/BVEk5LfooZI" height="293" width="520" allowfullscreen="" frameborder="0"></iframe></p>
<h2>Appendix R</h2>
<p>The <a href="https://www.portfolioprobe.com/user-area/some-hints-for-the-r-beginner/">computations were in R</a>.</p>
<h4>daily correlation estimate</h4>
<p>Getting the correlation matrix using daily data is easy enough:</p>
<pre>corDay &lt;- cor(retmat6m)</pre>
<h4>mean monthly estimate</h4>
<p>A little more goes into our monthly estimate.  The first thing we do is create a three dimensional array to hold the six monthly estimates:</p>
<pre>corMons &lt;- array(NA, c(100, 100, 6), 
   c(dimnames(corDay), list(NULL)))</pre>
<p>Note that <code>c</code> is used to put two lists together.</p>
<p>Then we compute the correlations in each month:</p>
<pre>dseq &lt;- 1:21
for(i in 1:6) {
   corMons[,,i] &lt;- cor(retmat6m[dseq + (i-1) * 21,])
}</pre>
<p>Finally, we average the correlations, ending up with a matrix:</p>
<pre>corMM &lt;- apply(corMons, 1:2, mean)</pre>
<p>(There is a chapter in <a href="http://www.burns-stat.com/documents/books/s-poetry/" target="_blank"><em>S Poetry</em></a> about higher dimensional arrays that may be of use if you start working with them.)</p>
<h4>scatter plot</h4>
<p>We just want one copy of the off-diagonal values in the correlation matrix.  We can get a logical vector selecting the lower triangle with:</p>
<pre>clt &lt;- lower.tri(corDay, diag=FALSE)</pre>
<p>(The default value of <code>diag</code> is <code>FALSE</code>, but I typically include <code>diag</code> in my calls to <code>lower.tri</code> just to make sure I have it the right way around without looking.)</p>
<p>This is used like:</p>
<pre>plot(corDay[clt], corMM[clt])</pre>
<h4>write a simple function</h4>
<p>We can write a little function that does the mean monthly correlation estimate:</p>
<pre>pp.cor6m &lt;- function(x)
{
   mc &lt;- array(NA, c(ncol(x), ncol(x), 6))
   dseq &lt;- 1:21
   for(i in 1:6) {
      mc[,,i] &lt;- cor(x[dseq + (i-1) * 21,])
   }
   apply(mc, 1:2, mean)
}</pre>
<h4>bootstrap correlations</h4>
<p>We start off again by creating arrays that we will then populate:</p>
<pre>bootcord &lt;- bootcorm &lt;- array(NA, c(100, 100, 200))</pre>
<p>Now do the actual bootstrapping:</p>
<pre>for(i in 1:200) {
   bx &lt;- retmat6m[sample(126, 126, replace=TRUE),]
   bootcord[,,i] &lt;- cor(bx)
   bootcorm[,,i] &lt;- pp.cor6m(bx)
}</pre>
<p>Finally, get the standard deviation across the bootstrap estimates for each correlation:</p>
<pre>bootd.sd &lt;- apply(bootcord, 1:2, sd)
bootm.sd &lt;- apply(bootcorm, 1:2, sd)</pre>
<h4>generate normal data</h4>
<p>There is a function in the <code>MASS</code> package for generating random multivariate normal data.</p>
<pre>require(MASS)</pre>
<p>This is used like:</p>
<pre>normmat &lt;- mvrnorm(126, mu=rep(0,100), Sigma=corDay)</pre>
<h4>bootstrap MSE</h4>
<p>The bootstrapping is:</p>
<pre>nbtcord &lt;- nbtcorm &lt;- array(NA, c(100, 100, 200))
for(i in 1:200) {
   bx &lt;- normmat[sample(126, 126, replace=TRUE),]
   nbtcord[,,i] &lt;- cor(bx)
   nbtcorm[,,i] &lt;- pp.cor6m(bx)
}</pre>
<p>Then the mean squared errors are calculated like:</p>
<pre>nbtd.mse &lt;- apply(nbtcord - as.vector(corDay), 1:2, 
                  function(x) mean(x^2))</pre>
<p>The <code>as.vector</code> is used because there is an error otherwise. When arithmetic is done on arrays in R, there is a check to see if they are conformable. A matrix and a three dimensional array are not conformable.  Removing the matrixness of <code>corDay</code> allows the computation to proceed, and it is the right computation in this case.</p>
<h4>define strange</h4>
<p>When looking at Figure 1 we have a sense of which points are weird.  There are multiple ways to translate our intuition into a definition.  Here is the one I used:</p>
<pre>corMM[clt] - corDay[clt] &gt; .1 &amp; corDay[clt] &lt; 0</pre>
<p>That is, the monthly estimate needs to be at least 0.1 bigger than the daily estimate and the daily estimate must be negative.</p>
<p>The definitions of weird in the other direction are:</p>
<pre>wei &lt;- bootd.sd[clt] - bootm.sd[clt] &gt; .02
wei2 &lt;- bootd.sd[clt] - bootm.sd[clt] &gt; .04</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/a-complicated-answer-to-a-simple-correlation-question/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>The portfolio optimization higher-moment credo</title>
		<link>https://www.portfolioprobe.com/quant-finance/the-portfolio-optimization-higher-moment-credo/</link>
					<comments>https://www.portfolioprobe.com/quant-finance/the-portfolio-optimization-higher-moment-credo/#respond</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 26 Jan 2014 20:22:20 +0000</pubDate>
				<category><![CDATA[Quant finance]]></category>
		<category><![CDATA[kurtosis]]></category>
		<category><![CDATA[portfolio optimisation]]></category>
		<category><![CDATA[portfolio optimization]]></category>
		<category><![CDATA[skewness]]></category>
		<category><![CDATA[trade selection]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11287</guid>

					<description><![CDATA[The question of skewness and kurtosis in portfolio optimization. Previously Problem 4 of "The top 7 portfolio optimization problems" concerns the use of higher moments. "Further adventures with higher moments" is the most recent in a series of posts on the efficacy of higher moments in optimization.  This set includes the observation that "trade selection"  [...]]]></description>
										<content:encoded><![CDATA[<p>The question of skewness and kurtosis in portfolio optimization.</p>
<h2>Previously</h2>
<p>Problem 4 of <a href="https://www.portfolioprobe.com/2012/01/05/the-top-7-portfolio-optimization-problems/">&#8220;The top 7 portfolio optimization problems&#8221;</a> concerns the use of higher moments.</p>
<p><a href="https://www.portfolioprobe.com/2013/12/23/further-adventures-with-higher-moments/">&#8220;Further adventures with higher moments&#8221;</a> is the most recent in a series of posts on the efficacy of higher moments in optimization.  This set includes the observation that <a href="http://www.burns-stat.com/documents/presentations/exploring-efficacy-higher-moments-portfolio-optimisation/" target="_blank">&#8220;trade selection&#8221; is a better term than &#8220;portfolio optimization&#8221;</a>.</p>
<h2>Choices</h2>
<p>For any particular optimization problem there are a few possibilities of what you might believe about higher moments:</p>
<ol>
<li>The returns are normally distributed</li>
<li>Adding higher moments to the optimization has no benefit</li>
<li>The effect of adding higher moments is unknown</li>
<li>Can&#8217;t be bothered to add higher moments even though they would help</li>
<li>Use higher moments</li>
</ol>
<h3>1) Normally distributed returns</h3>
<p>If you believe this, then you might miss the satire in <a href="https://www.portfolioprobe.com/2012/01/23/the-distribution-of-financial-returns-made-simple/">&#8220;The distribution of financial returns made simple&#8221;</a>.</p>
<p>In this case higher moments are known, and of no use.</p>
<h3>2) No benefit of higher moments</h3>
<p>There is persistent <strong>misinformation</strong> that this possibility doesn&#8217;t exist.  The commonly repeated message is that <span style="color: red;">mean-variance optimization implies that you believe returns are normal</span>.</p>
<p><strong>That is not the case</strong>.  It has things backwards: if returns are normal, then any optimization is mean-variance (though it could be done inefficiently by adding higher moments).</p>
<p>Doing mean-variance optimization is perfectly okay when the returns have symmetric distributions.  It is the best thing to do if there is no predictability of higher moments.</p>
<h3>3) Unknown effect</h3>
<p>This is appropriate, for instance, when it is clear that there is some predictability of skewness and kurtosis, but it is not clear that the predictability will translate into better results.</p>
<h3>4) Can&#8217;t be bothered</h3>
<p>Incorporating higher moments would improve the utility of the portfolio, but seemingly not the overall utility that includes the process of managing the portfolio.</p>
<h3>5) Include higher moments</h3>
<p>Higher moments are put into the optimization &#8212; either explicitly, or implicitly via a <a href="https://www.portfolioprobe.com/user-area/documentation/portfolio-probe-cookbook/3-optimize-trades/scenario-optimization/">scenario optimization</a>.</p>
<h2>Credo</h2>
<p>For most assets other than equities, my bias would be to do scenario optimization.  High-level asset allocation would generally be an exception.</p>
<p>For equities I am somewhere among beliefs 2 through 4.  Before I started looking at the stability of skewness and kurtosis among random portfolios, I was leaning towards 4.  Since I have done that experimenting, I am much closer to 2.</p>
<h2>Epilogue</h2>
<p style="padding-left: 30px;"><em>I believe the stars keep shining all through the night.</em><br />
<em>I believe if we just keep trying it will be all right.</em></p>
<p>from &#8220;I Believe&#8221; by Chris Isaak<br />
<iframe src="//www.youtube.com/embed/3RxMh6ye6Lg" height="390" width="520" allowfullscreen="" frameborder="0"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/quant-finance/the-portfolio-optimization-higher-moment-credo/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is volatility?</title>
		<link>https://www.portfolioprobe.com/r-language/what-is-volatility/</link>
					<comments>https://www.portfolioprobe.com/r-language/what-is-volatility/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Sun, 19 Jan 2014 18:31:12 +0000</pubDate>
				<category><![CDATA[Fund management in general]]></category>
		<category><![CDATA[R language]]></category>
		<category><![CDATA[volatility]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11276</guid>

					<description><![CDATA[Some facts and some speculation. Definition Volatility is the annualized standard deviation of returns -- it is often expressed in percent. A volatility of 20 means that there is about a one-third probability that an asset's price a year from now will have fallen or risen by more than 20% from its present value. In  [...]]]></description>
										<content:encoded><![CDATA[<p>Some facts and some speculation.</p>
<h2>Definition</h2>
<p>Volatility is the annualized standard deviation of returns &#8212; it is often expressed in percent.</p>
<p>A volatility of 20 means that there is about a one-third probability that an asset&#8217;s price a year from now will have fallen or risen by more than 20% from its present value.</p>
<p><a href="https://www.portfolioprobe.com/user-area/some-hints-for-the-r-beginner/">In R</a> the computation, given a series of daily prices, looks like:</p>
<pre>sqrt(252) * sd(diff(log(priceSeriesDaily))) * 100</pre>
<p>Usually &#8212; as here &#8212; <a href="https://www.portfolioprobe.com/2010/10/04/a-tale-of-two-returns/">log returns</a> are used (though it is unlikely to make much difference).</p>
<h2>Historical estimation</h2>
<p>What frequency of returns should be used when estimating volatility?  The main choices are daily, weekly and monthly.  (In some circumstances the choices might be something like 1-minute, 5-minute, 10-minute, 15-minute.)</p>
<p>There is folklore that it is better to use monthly data than daily data because daily data is more noisy.  But noise is what we want to measure &#8212; <a href="https://www.portfolioprobe.com/2012/10/29/volatility-from-daily-or-monthly-garch-evidence/">daily data produces less variable estimates</a> of volatility.</p>
<p>However, this is finance, so things aren&#8217;t that easy.  There is the phenomenon of <a href="https://www.portfolioprobe.com/tag/variance-compression/">variance compression</a> &#8212; that is, it isn&#8217;t clear that volatility from monthly and daily data are aiming at the same target.</p>
<p>Another complication is if there are assets from around the globe.  In that case asynchrony is a problem with daily data.  For example, the daily return of assets traded in Tokyo, Frankfurt and New York for January 21 are returns over three different time periods.  That matters (not much for volatility, but definitely for correlations).  <a href="https://www.portfolioprobe.com/2011/11/21/asynchrony-in-market-data/">Weekly returns as well as fancy estimation methods</a> alleviate the problem.</p>
<h2>Through time</h2>
<p>Volatility would be more boring if finance were like other fields where standard deviations never change.</p>
<p>Financial markets seem to universally experience <a href="https://www.portfolioprobe.com/tag/volatility-clustering/">volatility clustering</a>.  Meaning that there are time periods of high volatility and periods of (relatively) low volatility.</p>
<p>But why?</p>
<p>Changes in volatility would make sense if there were periods of greater uncertainty about the future.  But <a href="https://www.portfolioprobe.com/2011/07/25/review-of-everything-is-obvious-by-duncan-watts/">the future is always uncertain</a>.</p>
<p>The day after Lehman Brothers failed there was a great deal more uncertainty about the markets than the week before.  However, that uncertainty was generated internally to the markets, it wasn&#8217;t greater uncertainty about the physical world.</p>
<p>Agent-based models of markets easily reproduce volatility clustering.  Rather than agents changing their minds about the best strategy at random times, mind-changing tends to cluster.  When lots of agents change strategies, then the market volatility goes up.</p>
<h2>Across assets</h2>
<p>Different assets in the same market have different volatilities.  But why?</p>
<p>Some assets are especially <a href="https://www.portfolioprobe.com/2012/03/26/beta-is-not-volatility/">responsive to the behavior of the  rest of the market</a>.  Some assets are inherently more uncertain.</p>
<p><a href="https://www.portfolioprobe.com/tag/factor-model/">Factor models</a> explicitly divide these two ideas into systematic and idiosyncratic risk.</p>
<h2>Implied volatility</h2>
<p>Implied estimates come from using a model backwards.  Suppose you have a model that approximates <em>X</em> by using variables <em>A</em>, <em>B</em> and <em>C</em>.  If you know <em>X</em>, <em>A</em> and <em>B</em>, then you can get an implied estimate of <em>C</em> by plugging <em>X</em>, <em>A</em> and <em>B</em> into the model.</p>
<p>An example is <a href="https://www.portfolioprobe.com/tag/implied-alpha/">implied alpha</a>.</p>
<p>Implied volatility comes from options pricing models.  The most famous of these is the Black-Scholes formula.</p>
<p>Black-Sholes uses some assumptions and derives a formula to say what the price of an option should be.  The items in the formula are all known except for the average volatility between the present and the expiration date of the option.</p>
<p>We can use known options prices and the Black-Scholes formula to figure out what volatility is implied.  You can think of this as the market prediction of volatility &#8212; assuming the model is correct (<a href="https://www.portfolioprobe.com/2012/01/30/review-of-models-behaving-badly-by-emanuel-derman/">but it isn&#8217;t</a>).</p>
<h2>Not risk</h2>
<p>Some people equate volatility with risk.  Volatility is not risk.</p>
<p>Volatility is one measure of risk.  In some situations it is a pretty good measure of risk.  But always with risk there are some things that we can measure and some things that escape our measurement.</p>
<p>Part of risk measurement should be trying to assess what is left outside.</p>
<h2>Epilogue</h2>
<p style="padding-left: 30px;"><em>Before I built a wall I&#8217;d ask to know </em><br />
<em>What I was walling in or walling out, </em><br />
<em>And to whom I was like to give offense.</em></p>
<p>from &#8220;Mending Wall&#8221; by Robert Frost<br />
<iframe src="http://www.teachertube.com/embed.php?pg=video_120815" height="295" width="520" allowfullscreen="" frameborder="0"></iframe></p>
<h2>Appendix R</h2>
<p>I made the statement that using simple returns rather than log returns is unlikely to make much difference.  We shouldn&#8217;t take my word for it.  <strong>We can experiment</strong>.</p>
<p>In most blog posts I give only a sample of the R code.  Here, though, is the complete R code for this experiment.</p>
<h4>write a function</h4>
<pre>pp.dualvol &lt;- function(x, frequency=252) {
   lv &lt;- sd(x)
   sv &lt;- sd(exp(x)) # same as sd(exp(x) - 1)
   100 * sqrt(frequency) * 
      c(logReturn=lv, simpleReturn=sv)
}</pre>
<h4>get starting points of the samples</h4>
<pre>starts &lt;- sample(length(spxret) - 253, 1000)</pre>
<p>This statement presumes that the number sampled is smaller than the number of values being sampled since it is using the default of sampling without replacement.</p>
<h4>compute volatilities</h4>
<pre>volpairs &lt;- array(NA, c(1000, 2), 
   list(NULL, names(pp.dualvol(tail(spxret, 10)))))

tseq &lt;- 0:62

for(i in seq_along(starts)) {
   volpairs[i,] &lt;- pp.dualvol(spxret[starts[i] + tseq])
}</pre>
<h4>write plot function</h4>
<pre>P.dailyVolPair63 &lt;-
 function (filename = "dailyVolPair63.png") 
 {
    if(length(filename)) {
       png(file=filename, width=512)
       par(mar=c(5,4, 0, 2) + .1)
    }
    plot(volpairs, col="steelblue")
    abline(0, 1, col="gold")
    if(length(filename)) {
       dev.off()
    }
 }</pre>
<h4>do the plot</h4>
<pre>P.dailyVolPair63()</pre>
<p>Figure 1: Volatility estimates on a quarter of daily data &#8212; simple versus log returns. <a href="https://www.portfolioprobe.com/wp-content/uploads/2014/01/dailyVolPair63.png" rel="attachment wp-att-11278"><img decoding="async" class="aligncenter size-full wp-image-11278" alt="dailyVolPair63" src="https://www.portfolioprobe.com/wp-content/uploads/2014/01/dailyVolPair63.png" width="512" height="480" /></a></p>
<p>We can see that almost all of the 1000 estimates are virtually the same when using either type of return.  There are a few large volatilities that are slightly different.  The differences will be due to large returns, which means that returns at lower frequencies will yield bigger differences between the volatility estimates.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/what-is-volatility/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>garch models caught in the spotlight</title>
		<link>https://www.portfolioprobe.com/r-language/garch-models-caught-in-the-spotlight/</link>
					<comments>https://www.portfolioprobe.com/r-language/garch-models-caught-in-the-spotlight/#comments</comments>
		
		<dc:creator><![CDATA[Pat]]></dc:creator>
		<pubDate>Mon, 13 Jan 2014 11:44:48 +0000</pubDate>
				<category><![CDATA[Quant finance]]></category>
		<category><![CDATA[R language]]></category>
		<category><![CDATA[garch]]></category>
		<category><![CDATA[volatility clustering]]></category>
		<guid isPermaLink="false">https://www.portfolioprobe.com/?p=11266</guid>

					<description><![CDATA[An attempt to clarify the basics. Previously There have been several posts about garch.  In particular: A practical introduction to garch modeling The components garch model in the rugarch package Genesis A reader emailed me because he was confused about the workings of garch in general, and simulation with the empirical distribution in particular. If  [...]]]></description>
										<content:encoded><![CDATA[<p>An attempt to clarify the basics.</p>
<h2>Previously</h2>
<p>There have been several <a href="https://www.portfolioprobe.com/tag/garch/">posts about garch</a>.  In particular:</p>
<ul>
<li><a href="https://www.portfolioprobe.com/2012/07/06/a-practical-introduction-to-garch-modeling/">A practical introduction to garch modeling</a></li>
<li><a href="https://www.portfolioprobe.com/2013/01/28/the-components-garch-model-in-the-rugarch-package/">The components garch model in the rugarch package</a></li>
</ul>
<h2>Genesis</h2>
<p>A reader emailed me because he was confused about the workings of garch in general, and simulation with the empirical distribution in particular.</p>
<p>If there is one confused person, there are more.</p>
<h2>Model view</h2>
<p>A basic feature of garch models is that they are in discrete time.  The frequency is usually daily, in which case we pretend that the volatility of the returns is constant throughout each day.</p>
<p>Deep in the heart of a garch model is an <em>innovation</em> at each timepoint.  This is &#8212; conceptually &#8212; a draw from a statistical distribution that has variance 1.  Note that variance 1 rules out infinite variance, and hence <a href="https://www.portfolioprobe.com/2013/06/10/introduction-to-stable-distributions-for-finance/">stable distributions</a>.  Also, the <a href="https://www.portfolioprobe.com/2012/01/23/the-distribution-of-financial-returns-made-simple/">normal distribution is unlikely</a> to be a good approximation.</p>
<p>The innovation is the net result of the &#8220;news&#8221; that comes into the market during the period.  If the innovation is large (in absolute value, and compared to a variance 1 distribution), then that is a signal that future volatility is likely to be larger.</p>
<p>But we don&#8217;t see innovations.  We see innovations scaled by the current volatility.</p>
<p>What the garch model keeps track of is the <em>conditional variance</em> at each time.  The &#8220;conditional&#8221; being short for conditional on the returns (and possibly other variables) that have already occurred.  &#8220;Variance&#8221; because it is mathematically handy &#8212; in higher dimensions there are <a href="https://www.portfolioprobe.com/2010/08/25/what-the-hell-is-a-variance-matrix/">variance matrices</a> but you&#8217;ve never heard of a standard deviation matrix.</p>
<p>So far our model is:</p>
<p style="text-align: center;"><strong>return at time t  =  innovation at time t, scaled using the conditional variance at time t</strong></p>
<p>There is one more element to the model: the mean return at time t.  The typical garch model is:</p>
<p style="text-align: center;"><strong>return at time t  =  mean return at time t  +  innovation at time t, scaled using the conditional variance at time t</strong></p>
<p>Keep in mind that the conditional variance needs to be transformed before it can be used to scale the innovation.</p>
<h2>Reality view</h2>
<p>The fact is that there is a return &#8212; a single number &#8212; for a time period.  The garch models are taking that number and decomposing it into three pieces:</p>
<ul>
<li>the mean return at that time</li>
<li>the conditional variance at that time</li>
<li>the innovation for that time</li>
</ul>
<p>Those three things are fictional.  And the fictions of the last two heavily depend on each other.</p>
<p>Sometimes they are <a href="https://www.portfolioprobe.com/2012/01/30/review-of-models-behaving-badly-by-emanuel-derman/">useful fictions</a>.</p>
<h2>Data view</h2>
<p>The basic input to a garch model is a time series of returns.  It is <a href="https://www.portfolioprobe.com/2010/10/04/a-tale-of-two-returns/">log returns</a> that make the most sense in this setting.</p>
<p>Possible specifications for the mean return are:</p>
<ul>
<li>zero</li>
<li>a constant (to be estimated)</li>
<li>a simple autoregression &#8212; AR(1)</li>
<li>an ARMA model</li>
<li>something even fancier</li>
</ul>
<p>There is unlikely to be much difference between assuming the mean is zero and any of the others.  In particular, the estimation of the variance is highly unlikely to change significantly.</p>
<h3>Residuals</h3>
<p>It is easy for the term &#8220;residual&#8221; to be confusing in garch models.  That&#8217;s because the residuals don&#8217;t really have anything to do with the garchiness of the model.</p>
<p>The residual at time t is the return at time t minus the estimated mean return at time t.</p>
<p>More garchy &#8212; and more useful &#8212; are the <em>standardized residuals</em>.  The standardized residual at time t is the residual at time t divided by the square root of the conditional variance at time t.</p>
<p>In other words, the standardized residuals are the estimates of the innovations.</p>
<h3>Fit</h3>
<p>There are two parts to the fit of a garch model:</p>
<ul>
<li>fit for the mean return</li>
<li>fit for the conditional variance (or standard deviation or volatility)</li>
</ul>
<p>The second of these is the more interesting.</p>
<h3>Simulation</h3>
<p>To do a garch simulation you need to start with:</p>
<ul>
<li>a garch model with the parameters specified</li>
<li>a state for the conditional variance</li>
</ul>
<p>Usually, of course, the parameter specification is taken from the estimated model.  It is also typical that the variance state is the most recent variance state from the estimated model.</p>
<p>There is one more thing the simulation needs &#8212; innovations.</p>
<p>The two most common choices for generating a series of innovations are:</p>
<ul>
<li>sample from the distribution assumed in the model (including any estimated parameters)</li>
<li>sample from the standardized residuals of the estimated model</li>
</ul>
<p>The process of simulation is to use the first innovation, scale it via the volatility state and add in the mean return to get the first return in the simulation &#8212; let&#8217;s say this is for time T+1.</p>
<p>We then need to update the volatility state for T+1 &#8212; this depends on the innovation.</p>
<p>After those two steps we are in the same situation except we are one time step further.  We continue doing those steps until we have as many timepoints as we want.</p>
<p>Usually we do that process multiple times so that we have a large number of simulated series.</p>
<h2>Epilogue</h2>
<p style="padding-left: 30px;"><em>Your brow is sweatin&#8217; and your mouth gets dry,</em><br />
<em>Fancy people go driftin&#8217; by.</em><br />
<em>The moment of truth is right at hand,</em><br />
<em>Just one more nightmare you can stand.</em></p>
<p>from &#8220;Stage Fright&#8221; by Robbie Robertson<br />
<iframe src="//www.youtube.com/embed/nnCsAm39zAQ" height="293" width="520" allowfullscreen="" frameborder="0"></iframe></p>
<h2>Appendix R</h2>
<p>You can use garch <a href="https://www.portfolioprobe.com/user-area/some-hints-for-the-r-beginner/">in R</a>, among other places.</p>
<p>There are alternatives, but the <code>rugarch</code> package seems to be the most complete implementation in R.  Here is a small example.  The first step is:</p>
<pre>require(rugarch)</pre>
<p>This command will only work once the <a href="https://www.portfolioprobe.com/user-area/documentation/portfolio-probe-cookbook/r-notes/using-r-packages/">package has been installed</a> on your machine.</p>
<h4>set the garch specification</h4>
<p>We start by creating a specification of the garch model:</p>
<pre>comtspec &lt;- ugarchspec(mean.model=list(
  armaOrder=c(0,0)), distribution="std",
  variance.model=list(model="csGARCH"))</pre>
<p>This specification does three things. It sets:</p>
<ul>
<li>the model for the mean return to be a constant to be estimated &#8212; the default is an ARMA(1,1)</li>
<li>the distribution of the innovations to be a Student-t distribution &#8212; the default is normal</li>
<li>the model for the variance to be <a href="https://www.portfolioprobe.com/2013/01/28/the-components-garch-model-in-the-rugarch-package/">components garch</a> &#8212; the default is garch(1,1)</li>
</ul>
<h4>estimate the model</h4>
<p>We use the specification when fitting the model:</p>
<pre>garEstim &lt;- ugarchfit(comtspec, data=tail(spxret, 2000))</pre>
<p>The data are the most recent 2000 returns in the vector.</p>
<h4>get residuals</h4>
<p>The regular residuals for the garch model are:</p>
<pre>garResid &lt;- residuals(garEstim)</pre>
<p>The standardized residuals are computed like:</p>
<pre>garStandResid &lt;- residuals(garEstim, standardize=TRUE)</pre>
<p>We can see that the results make sense by inspecting the variances:</p>
<pre>&gt; var(tail(spxret, 2000))
[1] 0.0001969673
&gt; var(garResid)
             [,1]
[1,] 0.0001969673
&gt; var(garStandResid)
         [,1]
[1,] 1.204764</pre>
<p>I&#8217;m slightly concerned that the variance of the standardized residuals is so far from 1, but clearly it is trying to be close to 1.</p>
<h4>how you might have found how to get residuals</h4>
<p>The <code>residuals</code> function is generic.  There are two ways to look for the <a href="http://www.burns-stat.com/documents/tutorials/impatient-r/more-r-magic/" target="_blank">methods of a generic function</a>:</p>
<pre>&gt; methods('residuals')
[1] residuals.default        residuals.glm 
[3] residuals.HoltWinters*   residuals.isoreg* 
[5] residuals.lm             residuals.nls* 
[7] residuals.smooth.spline* residuals.tukeyline*
   Non-visible functions are asterisked</pre>
<pre>&gt; showMethods('residuals')
Function: residuals (package stats)
object="ANY"
object="ARFIMAfilter"
object="ARFIMAfit"
object="ARFIMAmultifilter"
object="ARFIMAmultifit"
object="uGARCHfilter"
object="uGARCHfit"
object="uGARCHmultifilter"
object="uGARCHmultifit"</pre>
<p>(Note that the results you get depend on what packages are loaded into your R session.)</p>
<p>The class of the object that we want is:</p>
<pre>&gt; class(garEstim)
[1] "uGARCHfit"
attr(,"package")
[1] "rugarch"</pre>
<p>This is found in the second group.  To have a look at the method in this group, you do:</p>
<pre>getMethod('residuals', 'uGARCHfit')</pre>
<p>It is here that we see that <code>standardize</code> is an argument (though not exactly blatantly obviously).</p>
<h4>encore</h4>
<p>The post <a href="https://www.portfolioprobe.com/2013/04/22/garch-and-the-distribution-of-returns/">&#8220;garch and the distribution of returns&#8221;</a> has some examples of simulation.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.portfolioprobe.com/r-language/garch-models-caught-in-the-spotlight/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
