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 } wvargrad = function(w) { 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, eval_grad = wvargrad, opts=opts ) w= optret$solution Q5 = w*mux + (1-w)*muy

Finally, the midterm result. Maybe I got lucky in one or two places, but I don’t think the result is completely random or undeserved either. More importantly, I still believe that this is actually a good course [Take it, if it’s offered again!] and I am taking away a lot for my current main area as well.