Articles by sang-heon lee

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...]

Smith-Wilson Extrapolation with R code

May 25, 2021 | sang-heon lee

This post explains how to implement the Smith-Wilson extrapolation by which deterministic DNS shock scenarios are generated. Smith-Wilson Extrapolation Deterministic DNS shock scenarios under ICS (K-ICS) are the term structure of annually compounding spot rates which spans from 1-month to 1440-month (120-year) or longer. This is used to discount the ...
[Read more...]

Construction of SOFR Index from SOFR Rates

May 24, 2021 | sang-heon lee

This post replicates the construction process of the SOFR index from daily SOFR rates. Since this index is published in a daily basis officially, there is no need to make it. But in the process of pricing SOFR swaps and floating rate notes, this sort of calculation is needed. SOFR ...
[Read more...]

Markowitz v.s. Michaud Portfolio Optimization with R code

May 22, 2021 | sang-heon lee

This post shows how to perform asset allocation based on the Markowitz's mean-variance (MV) portfolio model which is the benchmark framework. This model is based on the diversification effect. Another alternative Michaud's Resampled Efficiency (RE) portfolio model is also discussed. These two models are implemented using a quadratic optimization R ...
[Read more...]

Review of IAIS DNS Shock Generating Algorithm Update

May 19, 2021 | sang-heon lee

This post reviews the update of IAIS DNS Shock Generating Algorithm of IAIS(2018, 2019). This update have some modificatoin which is related to the expression of conditional covariance. But this expression needs to be more refined in the mathematical manner. This post try to explain it. IAIS DNS Shock Generating Algorithm : ... [Read more...]

Sign Constrained Lasso with R code

May 19, 2021 | sang-heon lee

This post explains how to implement the sign constrained lasso with ridge, and linear regression model. The restrictions of expected sign is of great importance in the case when building an econometric model with meaningful interpretation. We can easily incorporate sign restrictions to the above regression models using glmnet R ...
[Read more...]

Lasso Regression Model with R code

May 19, 2021 | sang-heon lee

Tibshirani (1996) introduces the so called LASSO (Least Absolute Shrinkage and Selection Operator) model for the selection and shrinkage of parameters. This model is very useful when we analyze big data. In this post, we learn how to set up the Lasso model and estimate it using glmnet R package. Tibshirani (1996) ...
[Read more...]

BOK ECOS Open API using R code

May 13, 2021 | sang-heon lee

BOK (Bank of Korea) administrates ECOS database for economic ststistics/market data and provides Open API for this database. ECOS API also supports several popular programming language such as R, Python. In this post, we use R programming to download data through ECOS API. This work can really help you ...
[Read more...]

Retrieving Stock Price using R

May 11, 2021 | sang-heon lee

Let's download stock prices using getSymbols() function in quantmod R library. I hope he will come back soon. It is easy to download. The first thing is to find the ticker for the security. The second thing is to run the following R code with ticker. Tickers are easily found ...
[Read more...]

Bayesian Linear Regression with Gibbs Sampling using R code

May 8, 2021 | sang-heon lee

Sang-Heon Lee This article explains how to estimate parameters of the linear regression model using the Bayesian inference. Our focus centers on user-friendly intuitive understanding of Bayesian estimation. From some radical point of view, we regard the Bayesian model as the average of multiple models generated with slightly different parameter ...
[Read more...]

Black Lognormal model for Swaption with R code

May 8, 2021 | sang-heon lee

Sang-Heon Lee This article derives the swaption pricing formula using Black model, which is a lognormal model. We present the detailed calculation example using R code. This work is a prerequisite for the calibratiion of Hull-White or LGM (Linear Gaussian Markov) model. The calibration of parameters of no-aritrage term structure ...
[Read more...]
1 2 3 4

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)