TU Berlin | Insitut für Mathematik

R code

Programs I wrote for the statistical computing environment R. Note that I am no longer actively maintaining the code.

Download Option Data and Plot Smiles

yahoo_opt.R

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. Requires package 'fCalendar'. After downloading and sourcing the file try the following lines of code:


opt <- yahoo.getAllOptions("IBM") ## download data
summary(opt)                      ## data overview
plot.smile(opt)                   ## plot 2d volatility smiles
plot3d.smile(opt)                 ## plot 3d volatility smiles

Visualize Levy Processes

levy_proc.R

This R program contains functions to plot trajectories of several Levy processes. The processes implemented are alpha-stable processes, Variance-Gamma and Normal-Inverse-Gaussian processes. Requires packages 'SuppDists' and 'fBasics'. After downloading and sourcing the file try the following lines of code:


plot.multi(stable.proc,alpha=1.7,beta=1)         ## Stable process
plot.multi(VG.proc,sigma=0.2,theta=1,kappa=0.1)  ## Variance Gamma process with drift
plot.multi(NIG.proc,sigma=0.2,theta=0,kappa=0.1) ## Normal Inverse Gaussian process

Visualize Some Copulas

copula.R

This R program draws some plots of frequently used copulas. Just execute the R-code directly.