# Zivot's Intro to Computational Finance - Mid Term

matthias on 2013/02/03

As I had written before I am participating in Zivot’s Computational Finance class that he’s currently holding via Coursera. Since there won’t be a certificate for this class, I am using my blog to update and publish my progress.

The exercises so far all went quite well. I am rediscovering or rather discovering an appreciation for R that I never had. I attribute that to Rstudio which makes R so much better than the basic interface I was battling when I used R the last time 4 years ago.

Since I don’t have access to MATLAB anymore and getting Octave on Windows isn’t exactly easy either, I am actually considering using R for small, instant computations - basically like an extended calculator. In addition to what it’s actually meant to be of course.

Here’s an example for the solution of a nonlinear program. I don’t feel like I could’ve written that a lot faster or more compact in MATLAB.

library(nloptr)

wvar = function(w) {
w^2*varx + (1-w)^2*vary + 2*(w-w^2)*covxy
}
2*w*varx - 2*(1-w)*vary + 2*(1-2*w)*covxy
}
opts = list("algorithm"="NLOPT_LD_LBFGS",
"xtol_rel"=1e-8)
optret = nloptr(x0=c(0.5),
eval_f =wvar,