<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Quantitative Finance Collector]]></title> 
<link>http://www.mathfinance.cn/index.php</link> 
<description><![CDATA[Quantitative Finance Collector is a blog on Quantitative finance analysis, financial engineering methods in mathematical finance focusing on derivative pricing, quantitative trading and quantitative risk management.]]></description> 
<language>en-US</language> 
<copyright><![CDATA[Quantitative Finance Collector]]></copyright>
<item>
<link>http://www.mathfinance.cn/r-optimization-test/</link>
<title><![CDATA[R Optimization Test]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 23 Jul 2012 10:12:36 +0000</pubDate> 
<guid>http://www.mathfinance.cn/r-optimization-test/</guid> 
<description>
<![CDATA[I have tested several R optimization functions before: nlm, optim(Nelder-Mead), optim(BFGS), optim(SANN), nlminb, optim (L-BFGS-B) for a eight-parameter <a href="http://en.wikipedia.org/wiki/Vasicek_model" target="_blank" rel="nofollow">Vasicek</a> interest rate model, overall I find that for my setting, nlminb is the best and all R functions finish within seconds. For detail please read the old post at <a href="http://www.mathfinance.cn/R-optimization-function-test/" target="_blank">R optimization function test</a><br/><br/><img src="http://www.mathfinance.cn/attachment/1285862465_3940a390.png" width=500 height=229></img><br/><br/>Pat at <a href="http://www.portfolioprobe.com/" target="_blank" rel="nofollow">Portfolio Probe</a> recently had a wonderful test on some heuristic optimization methods, including simulated annealing, traditional genetic algorithm, evolutionary algorithms. By using R packages and functions - Rmalschains, GenSA, genopt, DEoptim, soma, rgenoud, GA, NMOF and SANN method of optim, he finds that the Rmalschains and GenSA packages are standing out. Nice one, original article is at <a href="http://www.portfolioprobe.com/2012/07/23/a-comparison-of-some-heuristic-optimization-methods/" target="_blank" rel="nofollow">A comparison of some heuristic optimization methods</a>. <br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/optimization/" rel="tag">optimization</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/r-optimization-test/">R Optimization Test</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/week-in-review-021211/</link>
<title><![CDATA[Week in Review 021211 R Language]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Fri, 02 Dec 2011 10:08:47 +0000</pubDate> 
<guid>http://www.mathfinance.cn/week-in-review-021211/</guid> 
<description>
<![CDATA[Happy last month of 2011. I will fly to Sydney to present a paper at the <a href="http://www.mathfinance.cn/24th-australasian-finance-banking-conference/" target="_blank">24th Australasian Finance & Banking Conference</a> on next Thursday, so we may not have a review next week. However, feel free to contact me <a href="https://twitter.com/#!/a_biao" target="_blank" rel="nofollow">@a_biao</a> for sharing any useful post. This week's review is highly concentrated on <a href="http://www.mathfinance.cn/category/rsplus/" target="_blank">R language</a>.<br/><br/><a href="http://blog.naver.com/widylee/120128541187" target="_blank" rel="nofollow"><strong>R-code for the algorithm of Ait-Sahalia</strong></a>: the Closed-Form expansion for the transition densities of diffusions by Professor Yacine Aït-Sahalia facilitates the Maximum Likelihood Estimation, the related papers and Matlab package can be downloaded directly at his website at <a href="http://www.princeton.edu/~yacine/closedformmle.htm" target="_blank" rel="nofollow">Ait-Sahalia</a>, but in case you are a R user, this is what you need.<br/><br/><a href="http://www.matthewckeller.com/html/memory.html" target="_blank" rel="nofollow"><strong>R Memory Issue</strong></a>: insights on R memory issue, most of us have met it more or less.<br/><br/><a href="http://econometricsense.blogspot.com/2011/11/regression-via-gradient-descent-in-r.html" target="_blank" rel="nofollow"><strong>Regression via Gradient Descent in R</strong></a>: detailed simple example demonstrating how to run a regression via Gradient descent in R: principle and codes.<br/><br/><a href="http://gking.harvard.edu/publications/amelia-ii-program-missing-data-0" target="_blank" rel="nofollow"><strong>Amelia II: A Program for Missing Data</strong></a>: An excellent R package for multiple imputation of missing data. I had a post introducing its first version at <a href="http://www.mathfinance.cn/missing-data-imputation/" target="_blank">missing data imputation</a>.<br/><br/><a href="http://www.amazon.com/gp/product/1593273843/ref=as_li_tf_tl?ie=UTF8&tag=quanfinacodei-20&linkCode=as2&camp=217145&creative=399373&creativeASIN=1593273843"><strong>The Art of R Programming: A Tour of Statistical Software Design</strong></a><img src="http://www.assoc-amazon.com/e/ir?t=quanfinacodei-20&l=as2&o=1&a=1593273843&camp=217145&creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />: the book title tells it, you can't miss it as a R user.<br/><br/><a href="http://devcheatsheet.com/tag/r/" target="_blank" rel="nofollow"><strong>R Cheat Sheets</strong></a>: still having trouble remembering the exact commands in R? here is an excellent collection of R cheet sheets.<br/><br/><a href="http://www.quantcode.com/modules/smartfaq/faq.php?faqid=103" target="_blank" rel="nofollow"><strong>How to interpret Johansens' test results</strong></a>: simple while detailed examples guiding you through the basic knowledge how to interpret Johansenss test results for <a href="http://www.mathfinance.cn/cointegration-pair-trading/" target="_blank">cointegration analysis</a>.<br/><br/><a href="http://cssanalytics.wordpress.com/2011/07/29/improving-trend-following-strategies-with-counter-trend-entries/" target="_blank" rel="nofollow"><strong>Improving Trend-Following Strategies With Counter-Trend Entries</strong></a>: minor adjustments to strategies that can both improve their backtest performance and also reduce the real costs of trading.<br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/week/" rel="tag">week</a> , <a href="http://www.mathfinance.cn/tags/review/" rel="tag">review</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/week-in-review-021211/">Week in Review 021211 R Language</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/necessity-to-explain-cds-regime-switching-model/</link>
<title><![CDATA[Necessity to Explain CDS with A Regime Switching Model]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Thu, 07 Jul 2011 09:56:38 +0000</pubDate> 
<guid>http://www.mathfinance.cn/necessity-to-explain-cds-regime-switching-model/</guid> 
<description>
<![CDATA[Examining the determinants of credit default swap (CDS) spreads is a hot topic, CDS spread has displayed siginificant regime switching behaviour since the break of credit crisis, which can be seen from the old graph in the post <a href="http://www.mathfinance.cn/credit-default-spread-historical-volatility/" target="_blank">Credit Default Spread and Historical Volatility</a><br/><a href="http://www.mathfinance.cn/credit-default-spread-historical-volatility/"><img src="http://www.mathfinance.cn/attachment/1308658785_5339a6ce.png" alt="cds spread volatility" width=500 height=240></img></a><br/><br/>There are sound reasons to believe that CDS spreads keep high in the period of turbulence while stay stably low during most of quiet periods. To investigate if there is possible regime switch phenomenon, I run a three year rolling panel regression using CDSs of over 250 reference entities on several widely accepted explanatory variables including: leverage, volatility, treasury yield and the spread of three month Libor and repo rates, where the last variable is used to proxy liquidity risk. The coefficients for each variable is plotted below<br/><a href="http://www.mathfinance.cn/necessity-to-explain-cds-regime-switching-model/"><img src="http://www.mathfinance.cn/attachment/1310032024_10461235.png" alt="cds spread panel regression results" width=500 height=280></img></a><br/>the coefficients of leverage and treasury yields are changing but without clear regime pattern, on the contrary, the volatility, especially the liquidity effects are suggesting there may exist regime switching and the necessity to employ a Markov regime switch model to explain CDS spreads.<br/><br/>PS: a matlab markov regime switching package can be found <a href="http://www.mathfinance.cn/markov-regime-switching-models/" target="_blank">here</a>; the panel regression is done with the R package PLM at <a href="http://cran.r-project.org/web/packages/plm/vignettes/plm.pdf" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/plm/vignettes/plm.pdf</a> <br/>Tags - <a href="http://www.mathfinance.cn/tags/regime/" rel="tag">regime</a> , <a href="http://www.mathfinance.cn/tags/cds/" rel="tag">cds</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/necessity-to-explain-cds-regime-switching-model/">Necessity to Explain CDS with A Regime Switching Model</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/using-R-in-excel/</link>
<title><![CDATA[Using R in Excel]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 01 Jun 2011 08:20:20 +0000</pubDate> 
<guid>http://www.mathfinance.cn/using-R-in-excel/</guid> 
<description>
<![CDATA[Got to know a very cool tool to use R in Excel named <strong>RExcel</strong>, basically it provides an integration solution such that users can get data, run command in Excel the same way as in R, which is presumably good and convenient to present results to your colleagues.<br/><br/>Check yourself a demo video at <a href="http://rcom.univie.ac.at/RExcelDemo/" target="_blank" rel="nofollow">http://rcom.univie.ac.at/RExcelDemo/</a><br/><br/>The package can be downloaded free at <a href="http://rcom.univie.ac.at/download.html" target="_blank" rel="nofollow">http://rcom.univie.ac.at/download.html</a>&nbsp;&nbsp;<br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/excel/" rel="tag">excel</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/using-R-in-excel/">Using R in Excel</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/download-r-2-13-0-for-windows/</link>
<title><![CDATA[Download R 2.13.0 for Windows]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Fri, 15 Apr 2011 09:10:08 +0000</pubDate> 
<guid>http://www.mathfinance.cn/download-r-2-13-0-for-windows/</guid> 
<description>
<![CDATA[Some of you may hear that <strong>the new release of R 2.13.0 is out</strong>, with some <a href="http://cran.r-project.org/bin/windows/base/CHANGES.R-2.13.0.html" target="_blank" rel="nofollow">Windows-specific changes to R 2.13.0</a>:<br/>file.exists() and unlink() have more support for files > 2GB;<br/>A few more file operations will now work with >2GB files.<br/>which could help us to relieve the worry of <a href="http://www.mathfinance.cn/handling-large-datasets-in-R/" target="_blank">handling large datasets in R</a>. <a href="http://dirk.eddelbuettel.com/blog/2011/04/12/#the_new_r_compiler_package" target="_blank" rel="nofollow">An exciting post</a> shows us how to speed up R code up to 4 times by using the new R compiler package.<br/><br/><strong>Download R 2.13.0 for Windows</strong> at <a href="http://cran.r-project.org/bin/windows/base/" target="_blank" rel="nofollow">http://cran.r-project.org/bin/windows/base/</a>, to help you upgrade or install R for windows, here are a few useful articles:<br/><a href="http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Does-R-run-under-Windows-Vista_003f" target="_blank" rel="nofollow">http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Does-R-run-under-Windows-Vista_003f</a><br/><a href="http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/" target="_blank" rel="nofollow">http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/</a><br/><a href="http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r" target="_blank" rel="nofollow">http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/download-r-2-13-0-for-windows/">Download R 2.13.0 for Windows</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/how-to-vectorize-nested-loop-in-R/</link>
<title><![CDATA[How to Vectorize Nested Loop in R?]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Sat, 12 Mar 2011 14:24:53 +0000</pubDate> 
<guid>http://www.mathfinance.cn/how-to-vectorize-nested-loop-in-R/</guid> 
<description>
<![CDATA[Could any R expert here help me to vectorize my for loop? Thanks in advance for your favor. The reason I am in trouble is the variable inside my "for" function are updated after each loop, which makes me feel difficult to use lapply, sapply or whatever. <br/><br/>Simplifed codes are listed below:<br/><div class="code">for (i in 1:N) &#123; #N could be a large number, AdjS and VarS are initially given and updated for each i<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PredS &lt;- F %*% AdjS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PredY &lt;- H %*% PredS<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PredError &lt;- (Y&#91;i,&#93; - t(PredY))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VarY &lt;- (H %*% VarS) %*% t(H)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InvVarY &lt;- solve(VarY)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KG &lt;- (VarS %*% t(H)) %*% InvVarY<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AdjS &lt;- PredS + PredError<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VarS &lt;- (diag(3) - KG %*% H) %*% VarS<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ll&#91;i&#93; &lt;- PredError %*% InvVarY %*% t(PredError)<br/>&nbsp;&nbsp;&#125;<br/></div><br/><br/>The point is how to vectorize the for loop while allowing AdjS and VarS to be updated. I appreciate your help.<br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/vectorize/" rel="tag">vectorize</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/how-to-vectorize-nested-loop-in-R/">How to Vectorize Nested Loop in R?</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/issues-of-R-client-library-for-Google-prediction-API/</link>
<title><![CDATA[Issues of R Client Library For The Google Prediction API]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Thu, 16 Dec 2010 22:30:53 +0000</pubDate> 
<guid>http://www.mathfinance.cn/issues-of-R-client-library-for-Google-prediction-API/</guid> 
<description>
<![CDATA[The Google Prediction API is a black-box system for building predictive models, it provides pattern-matching and machine learning capabilities. So Google algorithms automatically creates a model from the training models given a set of training data and makes prediction under this model given a set of explanatory variables, read <a href="http://code.google.com/apis/predict/docs/getting-started.html" target="_blank" rel="nofollow">http://code.google.com/apis/predict/docs/getting-started.html</a> for an overview. <br/><br/>I am eager to make my hands dirty after the release of R client library for the Google Prediction API @ <a href="http://code.google.com/p/google-prediction-api-r-client/" target="_blank" rel="nofollow">http://code.google.com/p/google-prediction-api-r-client/</a>, however, as both my office's computer and my laptop are under Windows, there are few issues for the R API package:<br/>1, the original usage example had mistake. I always had a problem when I wanted to train my local data, my.model <- PredictionApiTrain(data="MYPATH/MYFILE.csv"), it says <br/><strong>Error in PredictionApiTrain(data = "test.csv") : 'remote.file' should be character.</strong> <br/>At the beginning of PredictionApiTrain() there are lines:<br/><div class="code">if (missing(remote.file) &#124;&#124; !is.character(remote.file)) <br/>stop(&quot;&#039;remote.file&#039; should be character&quot;)</div><br/>However, remote.file is an argument without default value, function (data, remote.file, verbose = FALSE). Now the example has been changed to my.model <- PredictionApiTrain (data="MYPATH/MYFILE.csv",remote.file="gs://MYBUCKET/MYOBJECT");<br/><br/>2, even when I use PredictionApiTrain <br/>(data="MYPATH/MYFILE.csv",remote.file="gs://MYBUCKET/MYOBJECT"), <br/>trained model my.model is expected, however, R returns <br/><strong>Error in system(command = command, intern = TRUE) : gsutil not found</strong><br/>I did install gsutil as described at <a href="http://code.google.com/apis/storage/docs/gsutil.html" target="_blank" rel="nofollow">http://code.google.com/apis/storage/docs/gsutil.html</a>, and can list my bucket using: python gsutil ls gs://MYBUCKET/MYOBJECT.<br/>The comment I got this afternoon is:<br/><div class="quote"><div class="quote-title">Quotation</div><div class="quote-content">We recommend to run this R client under Linux since this version doesn't support gsutil under Windows using Python.<br/>CygWin is a more recommended environment for running gsutil under Windows. And we will add this feature in future release soon.</div></div><br/>It seems we have to wait for a while before testing this promising application, luckily the ball is moving forward. Please share with us if you find a way out. I am looking forward to it and will update once I successfully try CygWin.<br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/prediction/" rel="tag">prediction</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/issues-of-R-client-library-for-Google-prediction-API/">Issues of R Client Library For The Google Prediction API</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/life-is-short-use-python/</link>
<title><![CDATA[Life Is Short, Use Python]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 24 Nov 2010 12:00:58 +0000</pubDate> 
<guid>http://www.mathfinance.cn/life-is-short-use-python/</guid> 
<description>
<![CDATA[<em>Life is short, use Python</em><img src="http://www.mathfinance.cn/attachment/1290594216_1182a041.gif" align="right" width=211 height=71 alt="python"></img><br/><br/>I started to play with <a href="http://www.python.org/" target="_blank" rel="nofollow">Python</a> two weeks ago due to the limitation of R in terms of handling large data, then a friend of mine suggested me to try Python since I had to do data massage frequently, "Python is the best choice, trust me", he said. Although I was unwilling to learn another new software, I couldn't bear with the low efficiency of R (or of my work) for large data. You may realize my learning curve as: <a href="http://www.mathfinance.cn/excellent-free-csv-splitter/" target="_blank">Excellent free CSV splitter</a> --> <a href="http://www.mathfinance.cn/any-good-way-to-import-large-CSV-file-into-mysql/" target="_blank">MySQL+RMySQL package</a> --> <a href="http://www.mathfinance.cn/handling-large-datasets-in-R/" target="_blank">Several R packages including bigmemory and ff</a>. But to be honest, none of them satisfies me either because of the limitation of the method (slow + malfunction) or of my own computer (short of memory).<br/><br/>I am shocked by python's extreme power and easy-to-use design after nearly two weeks, dealing with a 10GB CSV had never become so easy. More importantly, you can access R from Python almost seamlessly with the package <a href="http://rpy.sourceforge.net/" target="_blank" rel="nofollow">RPY</a>. To get started, I would like to recommend the following readings to all Python newbies like me:<br/>1, commands dictionary <a href="http://mathesaurus.sourceforge.net/matlab-python-xref.pdf" target="_blank" rel="nofollow">Matlab vs R vs Python</a>;<br/>2, free ebook <a href="http://diveintopython.org/" target="_blank" rel="nofollow">Dive Into Python</a>;<br/>3, a text book <a href="http://www.amazon.com/gp/product/1420067184?ie=UTF8&tag=quanfinacodei-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1420067184">Machine Learning: An Algorithmic Perspective</a><img src="http://www.assoc-amazon.com/e/ir?t=quanfinacodei-20&l=as2&o=1&a=1420067184" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> by Prof. Stephen Marsland. <br/><br/>The third book is especially useful for data analysis, as there are lots of Python code examples in the book, the code and dataset are available to download @ the author's website <a href="http://www-ist.massey.ac.nz/smarsland/MLBook.html" target="_blank" rel="nofollow">http://www-ist.massey.ac.nz/smarsland/MLBook.html</a>, take a look before deciding to add it to your shelf.<br/>Tags - <a href="http://www.mathfinance.cn/tags/python/" rel="tag">python</a> , <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/life-is-short-use-python/">Life Is Short, Use Python</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/handling-large-datasets-in-R/</link>
<title><![CDATA[Handling Large Datasets in R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Tue, 26 Oct 2010 23:52:20 +0000</pubDate> 
<guid>http://www.mathfinance.cn/handling-large-datasets-in-R/</guid> 
<description>
<![CDATA[<strong>Handling large dataset in R</strong>, especially CSV data, was briefly discussed before at <a href="http://www.mathfinance.cn/excellent-free-csv-splitter/" target="_blank">Excellent free CSV splitter</a> and <a href="http://www.mathfinance.cn/handling-large-csv-files-in-R/" target="_blank">Handling Large CSV Files in R</a>. My file at that time was around 2GB with 30 million number of rows and 8 columns. Recently I started to collect and analyze US corporate bonds tick data from year 2002 to 2010, and the CSV file I got is 6.18GB with 40 million number of rows, even after removing biases data as in <a href="http://www.mathfinance.cn/biases-in-TRACE-corporate-bond-data/" target="_blank">Biases in TRACE Corporate Bond Data</a>.<br/><br/>How to proceed efficiently? Below is an excellent presentation on <strong>handling large datasets in R</strong> by Ryan Rosario at <a href="http://www.bytemining.com/2010/08/taking-r-to-the-limit-part-ii-large-datasets-in-r/" target="_blank" rel="nofollow">http://www.bytemining.com/2010/08/taking-r-to-the-limit-part-ii-large-datasets-in-r/</a>, a short summary of the presentation:<br/><strong>1</strong>, R has a few packages for big data support. The presentation covers the following: <strong>bigmemory</strong> and <strong>ff</strong>; and also some uses of parallelism to accomplish the same goal using <strong>Hadoop </strong>and <strong>MapReduce</strong>;<br/><strong>2</strong>, the data used in the presentation is 11GB comma-separated values with 120 million rows, 29 columns;<br/><strong>3</strong>, For datasets with size in the range 10GB, bigmemory and ff handle themselves well;<br/><strong>4</strong>, For larger datasets, use Hadoop;<br/><br/><div style="width:425px" id="__ss_5016270"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/bytemining/r-hpc" title="Taking R to the Limit (High Performance Computing in R), Part 2 -- Large Datasets, LA R Users&#39; Group 8/17/10">Taking R to the Limit (High Performance Computing in R), Part 2 -- Large Datasets, LA R Users&#39; Group 8/17/10</a></strong><object id="__sse5016270" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=rhpc-100819231518-phpapp01&stripped_title=r-hpc&userName=bytemining" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5016270" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=rhpc-100819231518-phpapp01&stripped_title=r-hpc&userName=bytemining" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/bytemining">Ryan Rosario</a>.</div></div><br/><br/>BTW, determining the number of rows of a very big file is tricky, you don't have to load the data first and use dim(), which easily leads to short of memory. One way of doing it is readLines(), for example:<br/><div class="code">data &lt;- gzfile(&quot;yourdata.zip&quot;,open=&quot;r&quot;)<br/>MaxRows &lt;- 50000<br/>TotalRows &lt;- 0<br/>while((LeftRow &lt;- length(readLines(data,MaxRows))) &gt; 0 )<br/>TotalRows &lt;- TotalRows+LeftRow<br/>close(data) <br/></div><br/>Tags - <a href="http://www.mathfinance.cn/tags/data/" rel="tag">data</a> , <a href="http://www.mathfinance.cn/tags/csv/" rel="tag">csv</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/handling-large-datasets-in-R/">Handling Large Datasets in R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/R-API-to-interactive-brokers-trader-workstation/</link>
<title><![CDATA[R API to Interactive Brokers Trader Workstation]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 25 Oct 2010 21:14:05 +0000</pubDate> 
<guid>http://www.mathfinance.cn/R-API-to-interactive-brokers-trader-workstation/</guid> 
<description>
<![CDATA[Interactive Brokers via Matlab was mentioned at the old post <a href="http://www.mathfinance.cn/matlab-trading-code/" target="_blank">Matlab trading code</a>, IBrokers: R API to Interactive Brokers Trader Workstation is the R package I realize for algo trading API. Should you are also interested, you can watch the following short video about algo trading in R. You may watch from 15:00 directly.<br/><br/><embed src="http://blip.tv/play/AYKFuSIC" type="application/x-shockwave-flash" width="480" height="367" allowscriptaccess="always" allowfullscreen="true"></embed><br/><br/>The IBrokers package can be found at <a href="http://cran.r-project.org/web/packages/IBrokers/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/IBrokers/index.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/trading/" rel="tag">trading</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/R-API-to-interactive-brokers-trader-workstation/">R API to Interactive Brokers Trader Workstation</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/liquidity-premium-vs-liquidity-of-corporate-bonds/</link>
<title><![CDATA[Liquidity Premium vs Liquidity of Corporate Bonds]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Thu, 14 Oct 2010 16:18:20 +0000</pubDate> 
<guid>http://www.mathfinance.cn/liquidity-premium-vs-liquidity-of-corporate-bonds/</guid> 
<description>
<![CDATA[All else equal, investors should require higher returns on assets whose liquidity is lower, in other words, investors demand a higher expected return, and hence larger liquidity premium, by holding a less liquidity asset. Risk & return co-exist.<br/><br/>Is this really true for corporate bonds? I run a simple regression using R to test my data, where US corporate bonds are downloaded from <a href="http://www.finra.org/Industry/Compliance/MarketTransparency/TRACE/CorporateBondData/" target="_blank" rel="nofollow">TRACE</a> (Trade Reporting and Compliance Engine), CDS data from Datastream, Treasury / Swap interest rate from Federal Reserve Bank, the total number of bonds in my sample is 2409 from year 2004 ~ 2010. Liquidity of a corporate bond is measured as in the paper <em>Corporate Yield Spreads and Bond Liquidity</em> by Chen, Lesmond, and Wei (2007), Journal of Finance,<br/><img src="http://www.mathfinance.cn/attachment/1287059133_67449d35.jpg" width=500 alt="corporate bond liquidity measure"></img><br/>where alpha1 & alpha2 represent bid & ask spread, respectively, by using <a href="http://www.mathfinance.cn/maximum-likelihood-estimation/" target="_blank">maximum likelihood estimation</a> we could estimate the transaction cost alpha2-alpha1 for each bond, obviously the higher the transaction cost, the lower the liquidity.<br/><br/>Then I estimate the long-term liquidity premium by<br/><img src="http://www.mathfinance.cn/attachment/1287059464_890290be.png" width=108 height=37 alt="corporate bond liquidity premium estimation"></img><br/>here y, r, lambda and l are corporate bond yield, risk free rate, credit risk premium and liquidity premium.&nbsp;&nbsp;Finally I rank the corporate bonds by their liquidity premium, and scaled the ranking to be between 0 ~ 1, the higher the number, the lower the liquidity premium. What we would expect is a negative relationship between liquidity & liquidity premium, that is to say, investors would expect a lower liqudity premium by holding a larger liquidity bond, and vice versa.<br/><br/>Below is a simple univariate regression of liquidity on liquidity premium, where swap.liquidity is the liquidity premium estimated using swap rate as risk free. Not only the liquidity premium is significant enough, but also its coefficient sign is intuitive and same as expected<br/><img src="http://www.mathfinance.cn/attachment/1287074371_35316755.jpg" width=514 height=172 alt="corporate bond liquidity premium univariate regression"></img><br/><br/>the regression result shows the liquidity premium is highly significant even after controlling for those typical bond characteristics such as coupon rate, issue amount, age, maturity and the rating, where rating is expressed as from 1 to 7, with 1 being the highest rank "AAA". The larger issue amount, the lower transaction cost (and the higher liquidity); also the higher rating, the lower transaction cost. Overall there is a 140 basis point different in transaction costs between the lowest and highest premium.<br/><img src="http://www.mathfinance.cn/attachment/1287074371_61511d64.jpg" width=522 height=251 alt="corporate bond liquidity premium multiple regression"></img><br/><br/>I think by now we can draw a conclusion based on this empirical analysis: <strong>investors do demand a higher return for less liquidity corporate bond in the market.</strong> <br/>Tags - <a href="http://www.mathfinance.cn/tags/bond/" rel="tag">bond</a> , <a href="http://www.mathfinance.cn/tags/liquidity/" rel="tag">liquidity</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/liquidity-premium-vs-liquidity-of-corporate-bonds/">Liquidity Premium vs Liquidity of Corporate Bonds</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/R-optimization-function-test/</link>
<title><![CDATA[R Optimization Function Test]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Fri, 01 Oct 2010 06:13:07 +0000</pubDate> 
<guid>http://www.mathfinance.cn/R-optimization-function-test/</guid> 
<description>
<![CDATA[Using Kalman Filter for CIR interest rate model parameter estimation was introduced at my previously post <a href="http://www.mathfinance.cn/kalman-filter-finance-revisited/" target="_blank">Kalman Filter finance</a>, soon after that I got a few comments saying the final results are unstable and highly depend on the initial values, that's true, local vs global minimum is never ending.<br/><br/>This post is therefore <strong>a sample test</strong> of the optimization functions in R as I started to move from Matlab to R recently, and R allows us to choose the method we'd like to use for minimization. <br/><strong>Purpose</strong>: to estimate the parameters for <a href="http://en.wikipedia.org/wiki/Vasicek_model" target="_blank" rel="nofollow">Vasicek interest rate model</a>;<br/><strong>Function to be minimized</strong>: similar as in <a href="http://www.mathfinance.cn/kalman-filter-finance-revisited/" target="_blank">Kalman Filter finance</a>, where a <a href="http://en.wikipedia.org/wiki/Cox-Ingersoll-Ross_model" target="_blank" rel="nofollow">CIR model</a> is used instead;<br/><strong>Number of Parameters</strong>: 8<br/><strong>Data</strong>: two years time series of 3 month, 6 month, 1 year and 5 year US interest rate;<br/><strong>R function to be tested</strong>: nlm, optim(Nelder-Mead), optim(BFGS), optim(SANN), nlminb, optim (L-BFGS-B)<br/><br/>The true values are listed in the paper "<em>estimating and testing exponential-affine term structure models by kalman filter</em>", abs.tol and rel.tol are set to be 1e-6 wherever possible, derivative is not given and unconstrained optimization is prefered<br/><img src="http://www.mathfinance.cn/attachment/1285862465_3940a390.png" alt="R optimization function performance" width=500 height=229></img><br/><iframe align="right" src="http://rcm.amazon.com/e/cm?t=quanfinacodei-20&o=1&p=8&l=as1&asins=0521833787&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br/>I intentionally set the starting values far away from the true ones in order to see which one is able to find closest answers, obviously nlminb outperforms all others and returns almost the true values, I change the starting values randomly and still, <strong>nlminb is the best</strong> and all R functions finish within seconds. <br/><br/>Check several alternative <a href="http://cran.r-project.org/web/views/Optimization.html" target="_blank" rel="nofollow">R optimization packages</a> if you are not satisfied.<br/><br/><br/><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/optimization/" rel="tag">optimization</a> , <a href="http://www.mathfinance.cn/tags/filter/" rel="tag">filter</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/R-optimization-function-test/">R Optimization Function Test</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/missing-data-in-R/</link>
<title><![CDATA[Missing Data in R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Sun, 12 Sep 2010 20:59:51 +0000</pubDate> 
<guid>http://www.mathfinance.cn/missing-data-in-R/</guid> 
<description>
<![CDATA[Probably all of us have met the issue of <strong>handling missing data</strong>, from the basic portfolio <a href="http://www.mathfinance.cn/nearest-correlation-matrix/" target="_blank">correlation matrix</a> estimation, to advanced multiple factor analysis, how to <strong>impute missing data</strong> remains a hot topic. Missing data are unavoidable, and more encompassing than the ubiquitous association of the term, irgoring missing data will generally lead to biased estimates. The following ways are often applied to handle the problem:<br/><strong>1, simple deletion strategies</strong>: including pairwise deletion and listwise deletion, the former may lead to inconsistent results, for example, non positive definite correlation or covariance matrices, while the cumulation of deleted cases may be enormous except in the case of very few missing values for the latter method;<br/><strong>2, so called "Working around" strategies</strong>, for example, the Full Information Maximum Likelihood (FIML) integrates out the missing data when fitting the desired model;<br/><strong>3, imputation strategies</strong>, these are the most widely used methods both in academia and industry, replacing missing value with an estimate of the actual value of that case. For instance, ‘hot-deck’ imputation consists of replacing the missing value by the observed value from another, similar case from the same dataset for which that variable was not missing; mean imputation consists of replacing the missing value by the mean of the variable in question; expectation Maximization (EM) arrives at the best point estimates of the true values, given the model (which itself is estimated on the basis of the imputed missings); regression-mean imputation replaces the missing value by the conditional regression mean, and multiple imputation, rather than a single imputed value, multiple ones are derived from a prediction equation.<br/><br/><iframe align="left" src="http://rcm.amazon.com/e/cm?t=quanfinacodei-20&o=1&p=8&l=as1&asins=0471183865&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>I came across an easy-to-use <strong>missing data imputation</strong> named Amelia II developed by professor Gary King from Harvard university, as its webpage introduces: Amelia II "multiply imputes" missing data in a single cross-section (such as a survey), from a time series (like variables collected for each year in a country), or from a time-series-cross-sectional data set (such as collected by years for each of several countries). Amelia II implements bootstrapping-based algorithm that gives essentially the same answers as the standard IP or EMis approaches, is usually considerably faster than existing approaches and can handle many more variables....Unlike...other statistically rigorous imputation software, it virtually never crashes.<br/><br/>Amelia II was developed based on R language, so users have to install <a href="http://www.r-project.org/" target="_blank" rel="nofollow">R</a> before running it, installation of Amelia is staightforward: download and run the exe file, that's it. For me, the beauty of Amelia II is its friendly interface, I don't even need to run R software myself. Double clicking Amelia II shows the following <br/><img src="http://www.mathfinance.cn/attachment/1258663451_2335e137.jpg" alt="missing data imputation" width=500></img><br/>as you can see from the input and output menus, it supports csv files, simply importing a csv file with missing data returns a csv with imputed data, amazing, isn't it?<br/><br/>Downloading the software and help documents at <a href="http://gking.harvard.edu/amelia/" target="_blank" rel="nofollow">http://gking.harvard.edu/amelia/</a>.<br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/missing-data-in-R/">Missing Data in R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/R-reshape-package/</link>
<title><![CDATA[R Reshape Package]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 06 Sep 2010 08:08:10 +0000</pubDate> 
<guid>http://www.mathfinance.cn/R-reshape-package/</guid> 
<description>
<![CDATA[Some of you may know this <strong>R reshape package</strong> already, I have started to play with it after the post <a href="http://www.mathfinance.cn/handling-large-csv-files-in-R/" target="_blank">Handling Large CSV Files in R</a>. It is really an excellent one worthing a new post to introduce formally.<br/><br/><strong>What is reshape package? reshape: Flexibly reshape data, Reshape lets you flexibly restructure and aggregate data using just two functions: melt and cast.</strong> Therefore basically it allows us to massage, re-organize our data as the hierarchy we need with only two steps: first melt the data into a form suitable for easy casting, then cast a molten data frame into the reshaped or aggregated form you want. Sounds tongue twisters? A small example will help you feel clearer.<br/><br/>Suppose you have a matrix of bond data <br/><img src="http://www.mathfinance.cn/attachment/1283709024_9827c526.png" alt="original data for melt" width=528 height=241></img><br/>you are interested in the total amount of bonds of each rating, of each industry, or of each time to maturity, how to proceed? you may be thinking of lapply, sapply or even for loop, that's OK but at the cost of efficiency (coding time & running time) and possible error (personally I often have to modify twice for my sapply code to work, sad...). <br/><br/>It becomes much easier with the <strong>R Reshape package</strong>, <br/><strong>first</strong>, melt the data, newdata <- melt(data, id=c("RATING", "TIME_TO_MATURITY", "INDUSTRY_CODE", "BOND_TYPE"));<br/><strong>second</strong>, cast the data based on your needs, for instance, to get the total amount of each industry, cast(newdata, INDUSTRY_CODE ~ variable, sum) returns you a data.frame like<br/><img src="http://www.mathfinance.cn/attachment/1283709854_305234ae.png" alt="data after cast" width=245 height=276></img><br/><br/>That's it, easy to use, efficient, right? Download the R Reshape package at <a href="http://cran.r-project.org/web/packages/reshape/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/reshape/index.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/package/" rel="tag">package</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/R-reshape-package/">R Reshape Package</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/handling-large-csv-files-in-R/</link>
<title><![CDATA[Handling Large CSV Files in R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 09 Aug 2010 12:40:10 +0000</pubDate> 
<guid>http://www.mathfinance.cn/handling-large-csv-files-in-R/</guid> 
<description>
<![CDATA[A follow-up of my previous post <a href="http://www.mathfinance.cn/excellent-free-csv-splitter/" target="_blank">Excellent Free CSV Splitter</a>. I asked a question at <a href="http://www.linkedin.com/groupItem?view=&gid=90917&type=member&item=26640057&qid=992c16ad-535d-4bba-abaa-a78e32cc5006&goback=.gmp_90917" target="_blank" rel="nofollow">LinkedIn</a> about how to handle large CSV files in R / Matlab. Specifically, <br/><div class="quote"><div class="quote-title">Quotation</div><div class="quote-content">suppose I have a large CSV file with over 30 million number of rows, both Matlab / R lacks memory when importing the data. Could you share your way to handle this issue? what I am thinking is:<br/>a) split the file into several pieces (free, straightforward but hard to maintain);<br/>b) use MS SQL/MySQL (have to learn it, MS SQL isn't free, not straightforward).</div></div><br/><br/><strong>A useful summary of suggested solution</strong>:<br/>1,&nbsp;&nbsp;1) import the large file via "scan" in R;<br/>2) convert to a data.frame --> to keep data formats<br/>3) use cast --> to group data in the most "square" format as possible, this step involves the <a href="http://cran.r-project.org/web/packages/reshape/index.html" target="_blank" rel="nofollow">Reshape</a> package, a very good one. <br/><br/>2, use the <a href="http://cran.r-project.org/web/packages/bigmemory/index.html" target="_blank" rel="nofollow">bigmemory</a> package to load the data, so in my case, using read.big.matrix() instead of read.table(). There are several other interesting functions in this package, such as mwhich() replacing which() for memory consideration, foreach() instead of for(), etc. How large can this package handle? I don't know, the authors successfully load a CSV with size as large as 11GB.<br/><br/>3, switch to a 64 bit version of R with enough memory and preferably on linux. I can't test this solution at my office due to administration constraint, although it is doable, as mentioned in R help document, <br/><div class="quote"><div class="quote-title">Quotation</div><div class="quote-content">64-bit versions of Windows run 32-bit executables under the WOW (Windows on Windows) subsystem: they run in almost exactly the same way as on a 32-bit version of Windows, <strong>except that the address limit for the R process is 4GB (rather than 2GB or perhaps 3GB)</strong>....The disadvantages are that all the pointers are 8 rather than 4 bytes and so small objects are larger and more data has to be moved around, and that far less external software is available for 64-bit versions of the OS. </div></div><br/><br/>Search & trial.<br/><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/csv/" rel="tag">csv</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/handling-large-csv-files-in-R/">Handling Large CSV Files in R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/excellent-R-code-format-package/</link>
<title><![CDATA[Excellent R Code Format Package]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Sun, 04 Jul 2010 16:38:19 +0000</pubDate> 
<guid>http://www.mathfinance.cn/excellent-R-code-format-package/</guid> 
<description>
<![CDATA[I have been looking for this type of package for several days, and luckily found it today. Unquestionable R is powerful, however, R programming is unfriendly as far as I concern, mainly due to the lack of format shortcut, which makes the R codes rather ugly. (It is an absolute advantage of Matlab, for example, ctrl+R for comment, ctrl+T for uncomment, ctrl+I for smart indent, etc.)<br/><br/>FormatR is the package for tidying R source code, although it is less convenient to use than the straightforward shortcuts in Matlab, this package is good enough for me, what is it for? as the title suggest:<div class="quote"><div class="quote-title">Quotation</div><div class="quote-content">formatR: format R code automatically, farewell to ugly R code</div></div><br/><br/>Below is a comparison before and after using FormatR.<br/><strong>Before:</strong><br/><a href="http://yihui.name/en/wp-content/uploads/2010/04/formatR-screenshot1.png" target="_blank"><img src="http://yihui.name/en/wp-content/uploads/2010/04/formatR-screenshot1.png" class="insertimage" alt="Open in new window" title="Open in new window" border="0"/></a><br/><br/><strong>After:</strong><br/><a href="http://yihui.name/en/wp-content/uploads/2010/04/formatR-screenshot2.png" target="_blank"><img src="http://yihui.name/en/wp-content/uploads/2010/04/formatR-screenshot2.png" class="insertimage" alt="Open in new window" title="Open in new window" border="0"/></a><br/><br/>Download the package at <a href="http://cran.r-project.org/web/packages/formatR/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/formatR/index.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/excellent-R-code-format-package/">Excellent R Code Format Package</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/simple-dummy-R-GUI-generator/</link>
<title><![CDATA[Simple Dummy R GUI Generator]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Thu, 01 Jul 2010 11:28:30 +0000</pubDate> 
<guid>http://www.mathfinance.cn/simple-dummy-R-GUI-generator/</guid> 
<description>
<![CDATA[Imagine you finish a dirty coding project and want to present to your boss who is not in a good mood (may not be occasionally), how are you going to start? Show him your hundreads of lines code, point to the lines, explain what the arguments and outputs are? No, it is not a smart way since you are supposed to introduce in a few short sentences. Generating a GUI is probably the quickest / easiest way of understanding what this code does. As the old saying goes: a picture is worth a thousand words, so in a same logic, <strong>a GUI is worth n thousand words</strong>. <br/><br/>However, generating GUI is by no means easy as I know the pain when creating the <a href="http://www.mathfinance.cn/Matlab_GUI_equity_derivative_calculator/" target="_blank">Matlab-GUI equity derivative calculator</a>. It becomes even worse in R language, to be honest, I hate the graph plotting in R, terribly unflexible compared with in Matlab. Luckily I came across a good R GUI package named "<strong>fgui</strong>", it does as its description: Rapidly create a GUI interface for a function you created by automatically creating widgets for arguments of the function. <br/><br/>Very nice indeed, after playing for half an hour, it is simple to use, especially when what you need is just a basic GUI demonstrating to others a rough idea. <strong>One line code is enough</strong>. <br/><br/>For a simple example, I create a European option pricer with <a href="http://www.mathfinance.cn/black_scholes_language/" target="_blank">Black Scholes formula</a>, <br/><div class="code">EuropeanOption &lt;- function (s, k, r, t, vol, CallOption) &#123;<br/>&nbsp;&nbsp;d1 &lt;- (log(s/k)+(r+0.5*vol^2)*t)/(vol*sqrt(t))<br/>&nbsp;&nbsp;d2 &lt;- d1-vol*sqrt(t)<br/>&nbsp;&nbsp;if (CallOption)&#123;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return (s*pnorm(d1)-k*exp(-r*t)*pnorm(d2))<br/>&nbsp;&nbsp;&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return (k*exp(-r*t)*pnorm(-d2)-s*pnorm(-d1))<br/>&nbsp;&nbsp;&#125;<br/>&#125;</div><br/><strong>then generating a GUI for this function is as simple as adding the following code</strong><br/><div class="code">res &lt;- gui(EuropeanOption, argOption=list(CallOption=c(&quot;TRUE&quot;,&quot;FALSE&quot;)))</div><br/><br/>It returns a GUI looks like<br/><a href="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/R-GUI-generator.jpg" target="_blank"><img src="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/R-GUI-generator.jpg" class="insertimage" alt="Open in new window" title="Open in new window" border="0" width="500"/></a><br/>where you are able to set inputs and get outputs. Nice. More advanced GUI is possible by adding more lines.<br/><br/>Interested readers shall download the package "<strong>fgui</strong>" at <a href="http://cran.r-project.org/web/packages/fgui/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/fgui/index.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/gui/" rel="tag">gui</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/simple-dummy-R-GUI-generator/">Simple Dummy R GUI Generator</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/R-sapply-problem/</link>
<title><![CDATA[R Sapply Problem]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 16 Jun 2010 19:07:38 +0000</pubDate> 
<guid>http://www.mathfinance.cn/R-sapply-problem/</guid> 
<description>
<![CDATA[Any expert in R please educates me. I have got a problem about the sapply (or lapply), it made me headache for over two hours.<br/><br/>As "for loop" is very slow in R, we should try best to avoid using it, and to use vectorization instead. sapply is designed for this, for example, instead of:<br/><div class="code">for (i in 1:10) &#123;<br/>z&#91;i&#93; &lt;- mean(x&#91;1:i&#93;)<br/>&#125;</div><br/>we could use<br/><div class="code">z &lt;- sapply(1:10, function(i, x) &#123;mean(x&#91;1:i&#93;)&#125;, x) </div><br/><br/>It went well, but what if besides computing z, I need to update another variable, for example, with loop, it is<br/><div class="code">temp &lt;- 3<br/>for (i in 1:10) &#123;<br/>x&#91;i&#93; &lt;- x&#91;i&#93;-temp<br/>z&#91;i&#93; &lt;- mean(x&#91;1:i&#93;)<br/>temp &lt;- x&#91;i&#93;-z&#91;i&#93;<br/>&#125;</div><br/><br/>in this case, temp is changing every step (it doesn't have to be a function of z[i]). How to vectorize that and use sapply then? since sapply can't return two variables z and temp.<br/><br/><del>I tried to define a matrix and store z in the first column and temp in the second column and return the matrix, however, failed.</del><br/><br/>Many thanks.<br/><br/><br/><strong>PS</strong>, NO, still not correct, working on it...<br/><del>ah, I worked it out, it can be done by passing z itself to sapply, that's good.<br/>the following is a sapply example returning the same result for "for loop" and "sapply".<br/><div class="code">sapply.example &lt;- function(nsim = 10)&#123;<br/>&nbsp;&nbsp;x &lt;- rnorm(nsim)<br/>&nbsp;&nbsp;y &lt;- list()<br/>&nbsp;&nbsp;z.for &lt;- array(0, nsim)&nbsp;&nbsp;<br/>&nbsp;&nbsp;temp &lt;- 3<br/>&nbsp;&nbsp;for (i in 1:nsim) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;x&#91;i&#93; &lt;- x&#91;i&#93;-temp<br/>&nbsp;&nbsp;&nbsp;&nbsp;z.for&#91;i&#93; &lt;- mean(x&#91;1:i&#93;)<br/>&nbsp;&nbsp;&nbsp;&nbsp;temp &lt;- x&#91;i&#93;-z.for&#91;i&#93;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;y$z.for &lt;- z.for<br/><br/>&nbsp;&nbsp;z.sapply &lt;- array(0,2*nsim)<br/>&nbsp;&nbsp;z.sapply&#91;1&#93; &lt;- 3<br/>&nbsp;&nbsp;z.sapply &lt;- sapply(seq(1,2*nsim,by=2), function(i,x,z.sapply) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp &lt;- z.sapply&#91;i&#93;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z.temp &lt;- mean(x&#91;1:((i+1)/2)&#93;)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp &lt;- x&#91;((i+1)/2)&#93;-z.temp<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z.sapply&#91;i&#93; &lt;- temp<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z.sapply&#91;i+1&#93; &lt;- z.temp<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z.sapply&#91;i:(i+1)&#93;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;, x, z.sapply, simplify =TRUE)&nbsp;&nbsp;<br/>&nbsp;&nbsp;y$z.sapply &lt;- z.sapply&#91;seq(2,2*nsim, by=2)&#93;<br/>&nbsp;&nbsp;y<br/>&#125;</div></del><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/R-sapply-problem/">R Sapply Problem</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/r-for-matlab-users/</link>
<title><![CDATA[R for Matlab Users]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Tue, 15 Jun 2010 14:37:52 +0000</pubDate> 
<guid>http://www.mathfinance.cn/r-for-matlab-users/</guid> 
<description>
<![CDATA[My favorite software is <a href="http://www.mathfinance.cn/category/matlab/" target="_blank">Matlab</a>, but partly because <a href="http://www.mathfinance.cn/category/rsplus/" target="_blank">R</a> is free, more and more people & companies choose to use R as a major working language. Nothing wrong with that, I am at the moment changing some of my <a href="http://www.mathfinance.cn/kalman-filter-finance-revisited/" target="_blank">Kalman Filter</a> Matlab codes to R.<br/><br/>One bothering issue is each software has its own coding rules, for example, in Matlab we use a(1,1) but in R we use a[1,1]; in Matlab we have ones(3,2) but in R we dont have such a command but matrix(1,3,2), etc. (I am always wondering why they can't be designed in a similar way). It does bring me trouble sometimes, luckily I came across a web page similar as cheat-sheets, it lists those widely used commands in R and corresponding commands in Matlab, very convenient indeed.<br/><br/>Search before trial & error: <a href="http://mathesaurus.sourceforge.net/octave-r.html" target="_blank" rel="nofollow">http://mathesaurus.sourceforge.net/octave-r.html</a><br/><br/><strong>PS:</strong><br/><a href="http://www.walkingrandomly.com/?cat=36" target="_blank" rel="nofollow">Walking Randomly</a> suggests another excellent PDF manual consisting of 47 pages, fantastic! <a href="http://www.math.umaine.edu/~hiebeler/comp/matlabR.pdf" target="_blank" rel="nofollow">http://www.math.umaine.edu/~hiebeler/comp/matlabR.pdf</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/matlab/" rel="tag">matlab</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/r-for-matlab-users/">R for Matlab Users</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/an-interest-rate-R-package-plan/</link>
<title><![CDATA[An Interest Rate R Package Plan]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 07 Jun 2010 09:26:05 +0000</pubDate> 
<guid>http://www.mathfinance.cn/an-interest-rate-R-package-plan/</guid> 
<description>
<![CDATA[I recently have done some empirical studies on zero-coupon bond modelling and pricing, and plan to create an interest rate R package in order to make it re-usable, as I find there are only two R package on it, one is <a href="http://cran.r-project.org/web/packages/termstrc/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/termstrc/index.html</a>, the other one is <a href="http://cran.r-project.org/web/packages/YieldCurve/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/YieldCurve/index.html</a>, both of them don't cover short interest rate model, unfortunately.<br/><br/>Below is a short plan, help me add it by leaving a comment, thanks.<br/><a href="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/interestrateRpackage-1.gif" target="_blank"><img src="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/interestrateRpackage-1.gif" class="insertimage" alt="Open in new window" title="Open in new window" border="0" width="421" height="687"/></a> <br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/package/" rel="tag">package</a> , <a href="http://www.mathfinance.cn/tags/rate/" rel="tag">rate</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/an-interest-rate-R-package-plan/">An Interest Rate R Package Plan</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/</link>
<title><![CDATA[How to Create an R Package in Windows]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Fri, 04 Jun 2010 13:53:13 +0000</pubDate> 
<guid>http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/</guid> 
<description>
<![CDATA[There are many reasons to create an R package, such as codes protection, convenient usage, etc. However, creating an R package in Unix is not hard, it IS in Windows, as R is designed in a Unix environment which includes a set of compilers, programming utilities, and text-formatting routines while Windows lacks those. I used to build an R library in Unix and thought it was relatively as the same convenient as in Windows, but it turned out I had to spend several hours on it. Silly me.<br/><br/><iframe align="right" src="http://rcm.amazon.com/e/cm?t=quanfinacodei-20&o=1&p=8&l=as1&asins=0470510242&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><strong>Below are the selected steps to create an R package in Windows I summarize</strong>:&nbsp;&nbsp;<br/><strong>1</strong>, you have to download Rtools at <a href="http://www.murdoch-sutherland.com/Rtools/" target="_blank" rel="nofollow">http://www.murdoch-sutherland.com/Rtools/</a>.&nbsp;&nbsp;<br/><br/><strong>2</strong>, depending on your needs, you may download and install LaTex, Microsoft HTML Help Workshop and the Inno Setup installer, available at <a href="http://www.miktex.org" target="_blank" rel="nofollow">http://www.miktex.org</a>, <a href="http://msdn.microsoft.com/en-us/library/ms669985.aspx" target="_blank" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms669985.aspx</a>, and <a href="http://www.jrsoftware.org/" target="_blank" rel="nofollow">http://www.jrsoftware.org/</a>, respectively. For example, Microsoft HTML Help Workshop is for making HTML Help documents, LaTex is for a nicer outlook, especially when your documents have math equations.<br/><br/><strong>3</strong>, double click Rtools.exe to install it and its accompanying tools: minGW, perl. Rtools automatically recognizes the paths of those relevant softwares and add them to the environment variables of your computer.<br/><a href="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/rtool.png" target="_blank"><img src="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/rtool.png" class="insertimage" alt="Open in new window" title="Open in new window" border="0" width="400"/></a><br/><br/><strong>4</strong>, check and change your PATH “environment variables” of your computer if incorrect. To set the path, right click on the “My Computer” icon on your desktop, choose properties and click on the “advanced” tab, click the environmental variables button, click on the path variable and select the edit button. Check carefully whether all the paths are correct, special attention needs to be given to the path of R software.<br/><br/><strong>5</strong>, double check whether all tools are installed correctly by opening a “command prompt” window and typing the following commands: R; gcc –help; perl –help; Tex –help, respectively. You should see a list of options, otherwise re-install or check the path if you see “… is not a recognized as an internal or external command …”<br/><br/><strong>6</strong>, start R and run the command package.skeleton( ) with suitable arguments, read the help <a href="http://stat.ethz.ch/R-manual/R-patched/library/utils/html/package.skeleton.html" target="_blank" rel="nofollow">http://stat.ethz.ch/R-manual/R-patched/library/utils/html/package.skeleton.html</a> for detail. For instance, I write a sample code MonteCarloPi.R to estimate PI by Monte Carlo simulation, we use package.skeleton(name = "MonteCarloPi", code_files = “MonteCarloPi.R”), where MonteCarloPi.R includes function we want to add to the package MonteCarloPi. This function creates the directory tree for the package containing:<br/>DESCRIPTION <<<description of the package<br/>man <<< for documentation<br/>R <<< for R function definitions<br/>src <<< for low-level source code (this is optional for other programming files, such as your c++ codes)<br/>data <<< for package datasets (this is optional)<br/><a href="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/packageskeleton.png" target="_blank"><img src="http://i795.photobucket.com/albums/yy232/tigergb/mathfinance/packageskeleton.png" class="insertimage" alt="Open in new window" title="Open in new window" border="0"/></a><br/><br/><strong>7</strong>, remove the Read-and-delete-me file and modify other files in the above directory with notepad or other tool, for instance, to add the author information and Help explanation.<br/><br/><strong>8</strong>, open a “command prompt” window, change the directory to where your package is, type the command “R CMD build MonteCarloPi” to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. You must run the command in a “command prompt” window instead of in R, otherwise you are expected to see “Error: unexpected symbol in "R CMD"”.<br/><br/><strong>9</strong>, test the package by typing “R CMD check MonteCarloPi_1.0.tar.gz”, go back to step 8 if you see errors.<br/><br/><strong>10</strong>, now you are able to install the package typing “R CMD INSTALL MonteCarloPi_1.0.tar.gz”. Congratulations if you see “…done…” and you will notice there is one more sub-folder “MonteCarloPi” in your R library folder. <br/><br/><div class="code">#MonteCarloPi.R -- PI estimation by Monte Carlo simulation<br/><br/>MonteCarloPi &lt;- function(nsim)&#123;<br/>&nbsp;&nbsp;x &lt;- 2*runif(nsim)-1<br/>&nbsp;&nbsp;y &lt;- 2*runif(nsim)-1<br/>&nbsp;&nbsp;inx &lt;- which((x^2+y^2)&lt;=1)<br/>&nbsp;&nbsp;return ((length(inx)/nsim)*4)<br/>&#125;</div><br/><br/><div class="quote"><div class="quote-title">Quotation</div><div class="quote-content">Reference:<br/><a href="http://cran.r-project.org/doc/manuals/R-exts.html" target="_blank" rel="nofollow">http://cran.r-project.org/doc/manuals/R-exts.html</a></div></div><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/package/" rel="tag">package</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/">How to Create an R Package in Windows</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/missing-data-imputation/</link>
<title><![CDATA[Missing data imputation]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Sat, 12 Dec 2009 20:53:28 +0000</pubDate> 
<guid>http://www.mathfinance.cn/missing-data-imputation/</guid> 
<description>
<![CDATA[Probably all of us have met the issue of <strong>handling missing data</strong>, from the basic portfolio <a href="http://www.mathfinance.cn/nearest-correlation-matrix/" target="_blank">correlation matrix</a> estimation, to advanced multiple factor analysis, how to <strong>impute missing data</strong> remains a hot topic. Missing data are unavoidable, and more encompassing than the ubiquitous association of the term, irgoring missing data will generally lead to biased estimates. The following ways are often applied to handle the problem:<br/><strong>1, simple deletion strategies</strong>: including pairwise deletion and listwise deletion, the former may lead to inconsistent results, for example, non positive definite correlation or covariance matrices, while the cumulation of deleted cases may be enormous except in the case of very few missing values for the latter method;<br/><strong>2, so called "Working around" strategies</strong>, for example, the Full Information Maximum Likelihood (FIML) integrates out the missing data when fitting the desired model;<br/><strong>3, imputation strategies</strong>, these are the most widely used methods both in academia and industry, replacing missing value with an estimate of the actual value of that case. For instance, ‘hot-deck’ imputation consists of replacing the missing value by the observed value from another, similar case from the same dataset for which that variable was not missing; mean imputation consists of replacing the missing value by the mean of the variable in question; expectation Maximization (EM) arrives at the best point estimates of the true values, given the model (which itself is estimated on the basis of the imputed missings); regression-mean imputation replaces the missing value by the conditional regression mean, and multiple imputation, rather than a single imputed value, multiple ones are derived from a prediction equation.<br/><br/>I came across an easy-to-use <strong>missing data imputation</strong> named Amelia II developed by professor Gary King from Harvard university, as its webpage introduces: Amelia II "multiply imputes" missing data in a single cross-section (such as a survey), from a time series (like variables collected for each year in a country), or from a time-series-cross-sectional data set (such as collected by years for each of several countries). Amelia II implements bootstrapping-based algorithm that gives essentially the same answers as the standard IP or EMis approaches, is usually considerably faster than existing approaches and can handle many more variables....Unlike...other statistically rigorous imputation software, it virtually never crashes.<br/><br/>Amelia II was developed based on R language, so users have to install <a href="http://www.r-project.org/" target="_blank" rel="nofollow">R</a> before running it, installation of Amelia is staightforward: download and run the exe file, that's it. For me, the beauty of Amelia II is its friendly interface, I don't even need to run R software myself. Double clicking Amelia II shows the following <br/><img src="http://www.mathfinance.cn/attachment/1258663451_2335e137.jpg" alt="missing data imputation" width=500></img><br/>as you can see from the input and output menus, it supports csv files, simply importing a csv file with missing data returns a csv with imputed data, amazing, isn't it?<br/><br/>Downloading the software and help documents at <a href="http://gking.harvard.edu/amelia/" target="_blank" rel="nofollow">http://gking.harvard.edu/amelia/</a>.<br/>Tags - <a href="http://www.mathfinance.cn/tags/data/" rel="tag">data</a> , <a href="http://www.mathfinance.cn/tags/missing/" rel="tag">missing</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/missing-data-imputation/">Missing data imputation</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/rquantlib/</link>
<title><![CDATA[RQuantlib]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 23 Nov 2009 18:58:05 +0000</pubDate> 
<guid>http://www.mathfinance.cn/rquantlib/</guid> 
<description>
<![CDATA[<a href="http://quantlib.org/index.shtml" target="_blank" rel="nofollow">Quantlib</a> is a free library for modeling, trading, and risk management in real-life providing a comprehensive software framework for <a href="http://www.mathfinance.cn" target="_blank">quantitative finance</a>, it is written in C++, which might be inconvenient for some users. <a href="http://www.mathfinance.cn/jquantlib/" target="_blank">JQuantLib</a> aiming at Java-fans is naturally developed, correspondently, <strong>RQuantlib</strong> connects GNU R software with QuantLib.<br/><br/>The installation is straintforward, I tried it on my Windows, the source code is at <a href="http://cran.r-project.org/web/packages/RQuantLib/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/RQuantLib/index.html</a>, which is self-contained and does not even require a QuantLib (or Boost) installation. Nothing more to say, following the process, users are able to use the library immediately.<br/><br/>So far the function and option types supported by RQuantlib are limited, vanilla and a few popular exotic options, for example, <a href="http://www.mathfinance.cn/american-options/" target="_blank">American option</a>, <a href="http://www.mathfinance.cn/asian-option-monte-carlo/" target="_blank">Asian option</a>, <a href="http://www.mathfinance.cn/Barrier_Option_alculator/" target="_blank">Barrier</a>, Bermudan, Binary option, as well as a range of fixed-income functions, mainly on <a href="http://www.mathfinance.cn/Convertible_bond/" target="_blank">Convertible bond valuation</a>. Hopefully it will grow quickly. <br/><br/>Detailed reference manual is also available at <a href="http://cran.r-project.org/web/packages/RQuantLib/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/RQuantLib/index.html</a>.<br/>Tags - <a href="http://www.mathfinance.cn/tags/quantlib/" rel="tag">quantlib</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/rquantlib/">RQuantlib</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/cointegration-pair-trading/</link>
<title><![CDATA[Test cointegration with R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Sat, 22 Aug 2009 04:04:50 +0000</pubDate> 
<guid>http://www.mathfinance.cn/cointegration-pair-trading/</guid> 
<description>
<![CDATA[<strong>Cointegrated </strong>pairs of securities are crucial for mean reversion trading portfolio construction, <a href="http://www.mathfinance.cn/cointegration-test/" target="_blank">Play with cointegration</a> has several good papers to start with. Should you want to test pairs of securities for <strong>cointegration </strong>using R, here is an excellent webpage with data, code and detailed example, cheers.<br/><br/><a href="http://quanttrader.info/public/testForCoint.html" target="_blank" rel="nofollow">http://quanttrader.info/public/testForCoint.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/cointegration/" rel="tag">cointegration</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/cointegration-pair-trading/">Test cointegration with R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/nonparametric-high-dimensional-time-series-analysis/</link>
<title><![CDATA[Nonparametric High-Dimensional Time Series Analysis ]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 13 May 2009 21:43:59 +0000</pubDate> 
<guid>http://www.mathfinance.cn/nonparametric-high-dimensional-time-series-analysis/</guid> 
<description>
<![CDATA[Functional Gradient Descent (FGD) is a method of <strong>nonparametric time series analysis</strong>, useful in particular for estimating conditional mean, variances and covariances for very high-dimensional time series. FGD is a kind of hybrid of <a href="http://www.mathfinance.cn/nonparametric-density-estimation/" target="_blank">nonparametric statistical function estimation</a> and numerical optimization. In fact, the idea of FGD comes from the fact that boosting can be viewed as an <a href="http://www.mathfinance.cn/tags/optimization/" target="_blank">optimization algorithm</a> in function space. This method employs an iterative refitting of generalized residuals, based on a given statistical procedure called base learner, to approximate the first two conditional moment functions of a multivariate process. An appealing feature of this expansion is that it is a nonlinear nonparametric model that directly nests the Gaussian diagonal VAR model, the Gaussian <a href="http://www.mathfinance.cn/tags/garch/1/" target="_blank">GARCH model</a> and the multivariate CCC-GARCH as simple, starting special cases. The FGD model is fitted using conventional <a href="http://www.mathfinance.cn/maximum-likelihood-estimation/" target="_blank">maximum likelihood</a> together with a cross-validation strategy that determines the appropriate number of additive terms in the final expansions. <br/><br/>Interested ppl shall download the Splus codes and data at <a href="http://www.raffonline.altervista.org/fgd/" target="_blank" rel="nofollow">http://www.raffonline.altervista.org/fgd/</a><br/>PS: to be honest, this is not the area i am family with at all, download at your own risk <br/>Tags - <a href="http://www.mathfinance.cn/tags/nonparametric/" rel="tag">nonparametric</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/nonparametric-high-dimensional-time-series-analysis/">Nonparametric High-Dimensional Time Series Analysis </a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/maximum-likelihood-estimation/</link>
<title><![CDATA[Maximum likelihood estimation in R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Sun, 18 Jan 2009 17:58:12 +0000</pubDate> 
<guid>http://www.mathfinance.cn/maximum-likelihood-estimation/</guid> 
<description>
<![CDATA[Maximum likelihood estimation can be implemented like <a href="http://www.mathfinance.cn/qmle/" target="_blank">Quasi-maximum likelihood</a> in Matlab, You can also write an R function which computes out the likelihood function. As always in R, this can be done in several different ways.<br/><br/>One issue is that of restrictions upon parameters. When the search algorithm is running, it may stumble upon nonsensical values - such as a sigma below 0 - and you do need to think about this. One traditional way to deal with this is to "transform the parameter space". As an example, for all positive values of sigma, log(sigma) ranges from -infinity to +infinity. So it's safe to do an unconstrained search using log(sigma) as the free parameter.<br/><br/>For detail about methodology and sample codes see <a href="http://www.mayin.org/ajayshah/KB/R/documents/mle/mle.html" target="_blank" rel="nofollow">http://www.mayin.org/ajayshah/KB/R/documents/mle/mle.html</a>.<br/>Tags - <a href="http://www.mathfinance.cn/tags/mle/" rel="tag">mle</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/maximum-likelihood-estimation/">Maximum likelihood estimation in R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/high-moment-portfolio/</link>
<title><![CDATA[Extra moments measure]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Tue, 16 Dec 2008 21:57:00 +0000</pubDate> 
<guid>http://www.mathfinance.cn/high-moment-portfolio/</guid> 
<description>
<![CDATA[The following functions are intended to replicate calculations for taking higher moments of hedge fund returns into account in analyzing particular investments.&nbsp;&nbsp;Most of the formulae are taken from various EDHEC research papers.<br/><br/># All returns are assumed to be on a monthly scale!<br/><br/>functions including:<br/><br/># moment.third<br/># moment.fourth<br/># CoSkewness<br/># CoKurtosis<br/># BetaCoVariance<br/># BetaCoV (wrapper for BetaCoVariance)<br/># SystematicBeta (wrapper for BetaCoVariance)<br/># BetaCoSkewness<br/># BetaCoS (wrapper for BetaCoSkewness)<br/># SystematicSkewness (wrapper for BetaCoSkewness)<br/># BetaCoKurtosis<br/># BetaCoK (wrapper for BetaCoKurtosis)<br/># SystematicKurtosis (wrapper for BetaCoKurtosis)<br/># <a href="http://www.mathfinance.cn/tags/var/" target="_blank">VaR</a><br/># VaR.Beyond<br/># VaR.column<br/># VaR.CornishFisher<br/># VaR.Marginal<br/># modifiedVaR (wrapper for VaR.CornishFisher)<br/><br/><a href="http://braverock.com/brian/R/extra_moments.R" target="_blank" rel="nofollow">http://braverock.com/brian/R/extra_moments.R</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/moment/" rel="tag">moment</a> , <a href="http://www.mathfinance.cn/tags/portfolio/" rel="tag">portfolio</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/high-moment-portfolio/">Extra moments measure</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/mean-variance-portfolio/</link>
<title><![CDATA[Functions for portfolio analysis ]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Thu, 11 Dec 2008 15:07:17 +0000</pubDate> 
<guid>http://www.mathfinance.cn/mean-variance-portfolio/</guid> 
<description>
<![CDATA[Functions include:<br/>1. efficient.portfolio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compute <a href="http://www.mathfinance.cn/tags/markowitz/" target="_blank">minimum variance portfolio</a> subject to target return<br/>2. globalMin.portfolio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compute global minimum variance portfolio<br/>3. tangency.portfolio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compute tangency portfolio<br/>4. efficient.frontier&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;computer <a href="http://www.mathfinance.cn/tags/markowitz/" target="_blank">Markowitz </a>bullet<br/><br/><a href="http://faculty.washington.edu/ezivot/econ483/portfolio.ssc" target="_blank" rel="nofollow">http://faculty.washington.edu/ezivot/econ483/portfolio.ssc</a><br/><br/><br/>Tags - <a href="http://www.mathfinance.cn/tags/markowitz/" rel="tag">markowitz</a> , <a href="http://www.mathfinance.cn/tags/splus/" rel="tag">splus</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/mean-variance-portfolio/">Functions for portfolio analysis </a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/switch-splus-R-function/</link>
<title><![CDATA[Convert Splus to R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 10 Dec 2008 18:57:26 +0000</pubDate> 
<guid>http://www.mathfinance.cn/switch-splus-R-function/</guid> 
<description>
<![CDATA[Suppose you have got used to Splus and want to switch to R software (why bother to change? R is free while Splus is not, fair enough?), what can you do? since there are many functions in S-PLUS that are missing in R, one way is to understand the functions and write your owns, working N hours without sleep (N>?). however, you can avoid doing like that if you are as headche as me whenever you think of this solution. There is a package named Splus2R, which is to facilitate the conversion of S-PLUS packages to R packages, this package provides some missing S-PLUS functionality in R. <br/><br/>I have not tested the package, though, will update later. Here is downloading link: <a href="http://cran.r-project.org/web/packages/splus2R/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/splus2R/index.html</a>.<br/>Tags - <a href="http://www.mathfinance.cn/tags/splus/" rel="tag">splus</a> , <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/switch-splus-R-function/">Convert Splus to R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/multivariate-dependence-copulas/</link>
<title><![CDATA[Multivariate dependence with copulas]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 17 Nov 2008 20:03:56 +0000</pubDate> 
<guid>http://www.mathfinance.cn/multivariate-dependence-copulas/</guid> 
<description>
<![CDATA[Classes (S4) of commonly used <a href="http://www.mathfinance.cn/tags/copula/" target="_blank">copulas</a> including elliptical (normal and t), Archimedean (Clayton, Gumbel, Frank, and Ali-Mikhail-Haq), <a href="http://www.mathfinance.cn/tags/extreme/" target="_blank">extreme value</a> (Husler-Reiss and Galambos), and other families (Plackett and Farlie-Gumbel-Morgenstern). Methods for density, distribution,<a href="http://www.mathfinance.cn/tags/random/" target="_blank"> random number generation</a>, bivariate dependence measures, perspective and contour plots. Functions for fitting copula models. Independence tests among random variables and random vectors. Serial independence tests for univariate and multivariate continuous time series. Goodness-of-fit tests for copulas based on multipliers and on the <a href="http://www.mathfinance.cn/tags/bootstrapping/" target="_blank">parametric bootstrap</a>. <br/><br/>R package can be downloaded at <a href="http://cran.r-project.org/web/packages/copula/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/copula/index.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/copula/" rel="tag">copula</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/multivariate-dependence-copulas/">Multivariate dependence with copulas</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/modeling-financial-time-series-S-PLUS/</link>
<title><![CDATA[Modeling Financial Time Series with S-PLUS]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 12 Nov 2008 21:36:34 +0000</pubDate> 
<guid>http://www.mathfinance.cn/modeling-financial-time-series-S-PLUS/</guid> 
<description>
<![CDATA[Although S-plus is the most terrible language I have ever used in terms of debugging (I have to say that, no offense to S-plus fans, as my colleagues said, it is hard to understand it is still existed in 21 centuary), I found the S-plus scripts accompanying the book <strong>Modeling Financial Time Series with S-PLUS</strong>,&nbsp;&nbsp;covering:<br/><br/>Time Series Manipulation, Time Series Concepts, Unit Root Tests,&nbsp;&nbsp;<a href="http://www.mathfinance.cn/tags/extreme/" target="_blank">Modeling Extreme Values</a>, <a href="http://www.mathfinance.cn/tags/regression/" target="_blank">Time Series Regression</a>, <a href="http://www.mathfinance.cn/tags/garch/" target="_blank">Univariate GARCH</a>, Long Memory, Rolling Analysis, Systems of Regression Eqations, VAR Models, Cointegration, Factor Models, <a href="http://www.mathfinance.cn/tags/yield/" target="_blank">Term Structur</a>e, <a href="http://www.mathfinance.cn/tags/copula/" target="_blank">Copulas</a>, Generalized Method of Moments, etc.<br/><br/>For detail please download at <a href="http://faculty.washington.edu/ezivot/MFTS2ndEditionScripts.htm" target="_blank" rel="nofollow">http://faculty.washington.edu/ezivot/MFTS2ndEditionScripts.htm</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/s-plus/" rel="tag">s-plus</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/modeling-financial-time-series-S-PLUS/">Modeling Financial Time Series with S-PLUS</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/quantitative-risk-management/</link>
<title><![CDATA[Quantitative Risk Management R package]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 05 Nov 2008 20:43:48 +0000</pubDate> 
<guid>http://www.mathfinance.cn/quantitative-risk-management/</guid> 
<description>
<![CDATA[I shared an <a href="http://www.mathfinance.cn/econometrics-performance-risk-analysis/" target="_blank">Econometric tools for performance and risk analysis</a> package in R, today I introduce another <strong>Quantitative Risk Management</strong> R package, which is accompanying the book Quantitative Risk Management: Concepts, Techniques and Tools by Alexander J. McNeil, Rudiger Frey and Paul Embrechts, a nice book written by one of my professors. In this book special care is given to <a href="http://www.mathfinance.cn/tags/copula/" target="_blank">Copula analysis</a>, <a href="http://www.mathfinance.cn/generalized-extreme-value-distribution-density/" target="_blank">Extreme value thoey</a>, credit risk analysis, etc. Given the fact it was ranked by one of the top 10 most technical books of the year 2007, i bet you will learn a lot from it.<br/><br/>R-language version can be downloaded at <a href="http://cran.r-project.org/web/packages/QRMlib/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/QRMlib/index.html</a> and S-PLUS library to accompany book is at <a href="http://www.ma.hw.ac.uk/~mcneil/book/index.html" target="_blank" rel="nofollow">http://www.ma.hw.ac.uk/~mcneil/book/index.html</a>.<br/>Tags - <a href="http://www.mathfinance.cn/tags/risk/" rel="tag">risk</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/quantitative-risk-management/">Quantitative Risk Management R package</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/Rmetrics/</link>
<title><![CDATA[Rmetrics - Basics of Option Valuation]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 22 Oct 2008 19:14:49 +0000</pubDate> 
<guid>http://www.mathfinance.cn/Rmetrics/</guid> 
<description>
<![CDATA[Open Source Software for <a href="http://www.mathfinance.cn" target="_blank">Financial Engineering and Computational Finance</a><br/><br/>Rmetrics is the premier open source solution for teaching financial market analysis and valuation of financial instruments. With hundreds of functions build on modern methods Rmetrics combines explorative data analysis, statistical modeling and rapid model prototyping. The Rmetrics Packages are embedded in R building an environment which creates for students a first class system for applications in statistics and finance. <br/><br/>Download at <a href="http://cran.cnr.berkeley.edu/web/packages/fOptions/index.html" target="_blank" rel="nofollow">http://cran.cnr.berkeley.edu/web/packages/fOptions/index.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a> , <a href="http://www.mathfinance.cn/tags/option/" rel="tag">option</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/Rmetrics/">Rmetrics - Basics of Option Valuation</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/econometrics-performance-risk-analysis/</link>
<title><![CDATA[Econometric tools for performance and risk analysis]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Mon, 13 Oct 2008 19:31:47 +0000</pubDate> 
<guid>http://www.mathfinance.cn/econometrics-performance-risk-analysis/</guid> 
<description>
<![CDATA[<div class="quote"><div class="quote-title">Quotation</div><div class="quote-content">Library of econometric functions for performance and risk analysis of financial portfolios. This library aims to aid practitioners and researchers in using the latest research in analysis of both normal and non-normal return streams.<br/><br/>We created this library to include functionality that has been appearing in the academic literature on performance analysis and risk over the past several years, but had no functional equivalent in R. In doing so, we also found it valuable to have wrapper functions for functionality easily replicated in R, so that we could access that functionality using a function with defaults and naming consistent with common usage in the finance literature. The following sections cover Performance Analysis, Risk Analysis (with a separate treatment of VaR), Summary Tables of related statistics, Charts and Graphs, a variety of Wrappers and Utility functions, and some thoughts on work yet to be done. </div></div><br/><br/><a href="http://braverock.com/brian/R/PerformanceAnalytics/html/PerformanceAnalytics-package.html" target="_blank" rel="nofollow">http://braverock.com/brian/R/PerformanceAnalytics/html/PerformanceAnalytics-package.html</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/econometrics/" rel="tag">econometrics</a> , <a href="http://www.mathfinance.cn/tags/performance/" rel="tag">performance</a> , <a href="http://www.mathfinance.cn/tags/r/" rel="tag">r</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/econometrics-performance-risk-analysis/">Econometric tools for performance and risk analysis</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/evolutionary-algorithm/</link>
<title><![CDATA[evolutionary algorithm optimization ]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Thu, 04 Sep 2008 15:27:42 +0000</pubDate> 
<guid>http://www.mathfinance.cn/evolutionary-algorithm/</guid> 
<description>
<![CDATA[In the post <a href="http://www.mathfinance.cn/optimization-packages/" target="_blank">Optimization packages</a> dozens of optimization routines can be downloaded, here I am going to share a special optimization method: evolutionary algorithm. <br/><br/>Evolutionary algorithms (EAs) are search methods that take their inspiration from natural selection and survival of the fittest in the biological world. EAs differ from more traditional optimization techniques in that they involve a search from a "population" of solutions, not from a single point. Each iteration of an EA involves a competitive selection that weeds out poor solutions. The solutions with high "fitness" are "recombined" with other solutions by swaping parts of a solution with another. Solutions are also "mutated" by making a small change to a single element of the solution. Recombination and mutation are used to generate new solutions that are biased towards regions of the space for which good solutions have already been seen.<br/><br/>This R package provides the DEoptim function which performs Differential Evolution Optimization (evolutionary algorithm), for detail check <a href="http://cran.r-project.org/web/packages/DEoptim/index.html" target="_blank" rel="nofollow">http://cran.r-project.org/web/packages/DEoptim/index.html</a>.<br/>wiki(Evolutionary algorithm)<br/>Tags - <a href="http://www.mathfinance.cn/tags/optimization/" rel="tag">optimization</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/evolutionary-algorithm/">evolutionary algorithm optimization </a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/copula-graph/</link>
<title><![CDATA[Visualize Copulas]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Wed, 20 Aug 2008 14:09:55 +0000</pubDate> 
<guid>http://www.mathfinance.cn/copula-graph/</guid> 
<description>
<![CDATA[In those <a href="http://www.mathfinance.cn/tags/copula/" target="_blank">Copula codes</a> you can get a rough idea what copula is, how to estimate and simulate it, how to test its performance, etc., to help you visualize what on earth the copula should look like, below R code draws plots of some widely used copulas.<br/><br/><a href="http://www.math.tu-berlin.de/~mkeller/index.php?target=rcode" target="_blank" rel="nofollow">http://www.math.tu-berlin.de/~mkeller/index.php?target=rcode</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/copula/" rel="tag">copula</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/copula-graph/">Visualize Copulas</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/process-simulation/</link>
<title><![CDATA[Process Simulation in R]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Tue, 12 Aug 2008 07:50:09 +0000</pubDate> 
<guid>http://www.mathfinance.cn/process-simulation/</guid> 
<description>
<![CDATA[Simple demonstration codes for process simulation in R, including Brownian motion simulation, Poisson process simulatio, Euler scheme simulation for Geometric Brownian motion, the mean-reverting process, and the process with two 'attractors', etc.<br/><br/><a href="http://www.math.ku.dk/~rolf/teaching/mfe04/MiscInfo.html#Code" target="_blank" rel="nofollow">http://www.math.ku.dk/~rolf/teaching/mfe04/MiscInfo.html#Code</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/simulation/" rel="tag">simulation</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/process-simulation/">Process Simulation in R</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/vasicek-model-estimation/</link>
<title><![CDATA[R-code for Vasicek estimation]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Fri, 08 Aug 2008 06:51:47 +0000</pubDate> 
<guid>http://www.mathfinance.cn/vasicek-model-estimation/</guid> 
<description>
<![CDATA[A short-rate model is usually calibrated to some initial structures in the market, typically the initial yield curve, the caps volatility surface, the swaptions volatility surface, and possibly other products, thus determining the model parameters. Vasicek, Cox Ingersoll Ross (CIR), Dothan, for instance, are among the frequently-used short-rate models. The strength of Vasicek model is analytical bond prices and analytical option prices can be obtained and easily calculatied, however, negative short rates are also possible with positive probability.<br/><br/><br/>R code can be downloaded at <a href="http://www.math.ku.dk/~rolf/teaching/mfe04/MiscInfo.html#Code" target="_blank" rel="nofollow">http://www.math.ku.dk/~rolf/teaching/mfe04/MiscInfo.html#Code</a> <br/><br/>wiki(Vasicek model)<br/>Tags - <a href="http://www.mathfinance.cn/tags/vasicek/" rel="tag">vasicek</a> , <a href="http://www.mathfinance.cn/tags/cox_ingersoll_ross/" rel="tag">cox ingersoll ross</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/vasicek-model-estimation/">R-code for Vasicek estimation</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/Yahoo_option_price/</link>
<title><![CDATA[download option price data from Yahoo]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Tue, 29 Jul 2008 07:57:15 +0000</pubDate> 
<guid>http://www.mathfinance.cn/Yahoo_option_price/</guid> 
<description>
<![CDATA[This R program can be used to download option price data from Yahoo to a data frame and to plot the corresponding implied-volatility smiles. <br/><br/><a href="http://www.math.tu-berlin.de/~mkeller/index.php?target=rcode" target="_blank" rel="nofollow">http://www.math.tu-berlin.de/~mkeller/index.php?target=rcode</a><br/>Tags - <a href="http://www.mathfinance.cn/tags/download/" rel="tag">download</a> , <a href="http://www.mathfinance.cn/tags/data/" rel="tag">data</a> , <a href="http://www.mathfinance.cn/tags/option/" rel="tag">option</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/Yahoo_option_price/">download option price data from Yahoo</a></strong>.
]]>
</description>
</item><item>
<link>http://www.mathfinance.cn/Quantile_Regression/</link>
<title><![CDATA[Quantile Regression]]></title> 
<author>abiao &lt;&gt;</author>
<category><![CDATA[R/Splus]]></category>
<pubDate>Tue, 29 Jul 2008 07:48:16 +0000</pubDate> 
<guid>http://www.mathfinance.cn/Quantile_Regression/</guid> 
<description>
<![CDATA[Quantile regression is a statistical technique intended to estimate, and conduct inference about, conditional quantile functions. Just as classical linear regression methods based on minimizing sums of squared residuals enable one to estimate models for conditional mean functions, quantile regression methods offer a mechanism for estimating models for the conditional median function, and the full range of other conditional quantile functions. By supplementing the estimation of conditional mean functions with techniques for estimating an entire family of conditional quantile functions, quantile regression is capable of providing a more complete statistical analysis of the stochastic relationships among random variables.<br/><br/><br/>http://www.econ.uiuc.edu/~roger/research/rq/rq.html<br/>wiki(Quantile regression)<br/>Tags - <a href="http://www.mathfinance.cn/tags/regression/" rel="tag">regression</a><br /><strong>Read the full post at <a href="http://www.mathfinance.cn/Quantile_Regression/">Quantile Regression</a></strong>.
]]>
</description>
</item>
</channel>
</rss>