Articles by sang-heon lee

Bond Modified Duration in R

September 3, 2021 | sang-heon lee

Bond duration is a basic building block for bond portfolio management and asset-liability management (ALM). This post explains the meaning of duration and calculation of this risk measures by using Excel and R. Instead of using another full-fledged ...
[Read more...]

Basic R : Read so many CSV files

September 2, 2021 | sang-heon lee

This post presents basic R code snippets to read files with given file extensions such as csv or txt. This is simple but very useful when it comes to the case where there are too many files to read manually. If we have too many (i.e. 1000 file...
[Read more...]

Pricing of FX Forward in R and Excel

August 8, 2021 | sang-heon lee

This post explains how to price a FX forward. We assume that 1) USD is the foreign currency and KRW the domestic one, 2) USD IRS zero curve and KRW FX implied zero curve are given. Before making a R code, we use Excel spreadsheet for the clear under...
[Read more...]

Delta Sensitivity of Interest Rate Swap

July 23, 2021 | sang-heon lee

This post explains how to calculate delta sensitivities or delta vector of interest rate swap, especially delta. delta can be calculated by either 1) zero delta or 2) market delta. To the best of our knowledge, FRTB can use these two methods but SIM...
[Read more...]

Interest Rate Swap Pricing using R code

July 10, 2021 | sang-heon lee

This post explains how to price an interest rate swap (IRS) using R code and Excel's illustrations. We use swap rates, zero curve data from Bloomberg. We consider 5-Year Libor 3M IRS without OIS discounting as an pre-crisis IRS example. Libor ...
[Read more...]

Using NEOS Optimization Solver in R code

June 27, 2021 | sang-heon lee

This post explains how to use ROI and ROI.plugin.neos packages in R code, which provide an interface to NEOS. NEOS (Network-Enabled Optimization System) Server is a free internet-based service for solving numerical optimization problems. For underst...
[Read more...]

Using R code in Java Eclipse with rJava

June 23, 2021 | sang-heon lee

This post shows how to use R code in Eclipse IDE for Java with rJava package. But this work requires several environment setting which is a little bit confusing. Although there are some good posts regarding this issue, we use a step by step guide wi...
[Read more...]

Benchmark Bond Portfolio Returns using R code

June 20, 2021 | sang-heon lee

This post calculates the holding period returns of four benchmark zero coupon bonds portfolios such as bullet, barbell, ladder and buy-and-hold using R code Benchmark Bond Portfolio Strategies Bond portfolio strategies are too many to enumerate. But there are benchmark bond strategies which are frequently introduced to textbook. Among them ...
[Read more...]

Yield to Maturity and Reinvestment Risk

June 17, 2021 | sang-heon lee

This post shows how the reinvestment risk affect the holding period return of coupon bond using R code Coupon Bond and Reinvestment Risk using R code At first, we need to make a distinction between par yield and YTM (Yield to Maturity). Par Yield The par yield is the coupon ...
[Read more...]

Hull-White 1-factor model using R code

June 13, 2021 | sang-heon lee

This post explains how to simulate short rates, discount factors, future spot rates, and so on using the Hull-White 1 factor model with given calibrated parameters. We summarize important model blocks using previous post for clear understanding and finally implement them sequentially for simulation using R code. Hull-White 1-factor model using ...
[Read more...]

Coupon Bearing Bond Pricing using R code

June 13, 2021 | sang-heon lee

This post explains how to calculate the price of some complicated coupon bearing bond using R code. Pricing of Coupon Bond using R code There are pricing formula for coupon bond as well as discount bond which are used among practioners under the market convention. Bond Pricing Formula Discount Bond \[\...
[Read more...]

Capitalization of Names using R code

June 12, 2021 | sang-heon lee

This post shows simple R trick for capitalization of names, which may have some delimiter. Problem Problem is to apply capitalization to names separated by punctuation mark ("."). For example, "BABACAR.THIOMBANE" is to converted to "Babacar.Thiombane" as follows. 1234567891011---------------------------------------------------           name(input)                      output---------------------------------------------------     BABACAR.THIOMBANE           Babacar.Thiombane         DAMEN.THACKER               Damen.... [Read more...]

Understanding Logistic Regression

May 27, 2021 | sang-heon lee

This post explains the logistic regression and implements R code for the estimation of its parameters. Logistic Regression Logistic Regression is a benchmark machine learning model. This model have a binary response variable (\(Y\)) which takes on 0 or 1. We can find lots of this kind of variables, among them are ...
[Read more...]
1 2

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)