Monthly Archives: January 2013

F1Stats – Visually Comparing Qualifying and Grid Positions with Race Classification

January 30, 2013
By
F1Stats – Visually Comparing Qualifying and Grid Positions with Race Classification

Following the roundabout tour of F1Stats – A Prequel to Getting Started With Rank Correlations, here’s a walk through of my attempt to replicate the first part of A Tale of Two

Read more »

R finals

January 30, 2013
By
R finals

On the morning I returned from Varanasi and the ISBA meeting there, I had to give my R final exam (along with three of my colleagues in Paris-Dauphine). This year, the R course was completely in English, exam included, which means I can post it here as it may attract more interest than the French

Read more »

Modeling Residential Electricity Usage with R

January 30, 2013
By
Modeling Residential Electricity Usage with R

Wow, I can’t believe it has been 11 months since my last blog posting!  The next series of postings will be related to the retail energy field.  Residential power usage is satisfying to model as it can be forecast fairly accurately with the right inputs.  Partly as a consequence of deregulation there is now more data more available than...

Read more »

Regression on categorical variables

January 30, 2013
By
Regression on categorical variables

This morning, Stéphane asked me tricky question about extracting coefficients from a regression with categorical explanatory variates. More precisely, he asked me if it was possible to store the coefficients in a nice table, with information on the variable and the modality (those two information being in two different columns). Here is some code I did to produce the...

Read more »

Approaching the Zero Bound – Bonds

January 30, 2013
By
Approaching the Zero Bound – Bonds

As bonds approach the artificial zero bound, where do we go next especially after the record setting +30% in 2011?  The rolling 250-day total return has rarely gone negative since the inception of the Vanguard Funds VBMFX and VUSTX.  I am int...

Read more »

The magic empty bracket

January 30, 2013
By
The magic empty bracket

I have been working with R for some time now, but once in a while, basic functions catch my eye that I was not aware of… For some project I wanted to transform a correlation matrix into a covariance matrix. Now, since cor2cov does not exist, I thought about “reversing” the cov2cor function (stats:::cov2cor). Inside

Read more »

Speed up for loops in R

January 30, 2013
By

Are your for loops too slow in R ? Are loops that should take seconds actually taking hours ? As I found out recently, how you structure your code can make a huge difference in execution times. Fortunately making a few small changes to your code can speed up these loops by several orders of

Read more »

R’s range and loop behaviour: Zero, One, NULL

January 30, 2013
By

One of the most common pattern in programming languages is to ability to iterate over a given set (a vector usually) by using 'for' loops. In most modern scripting languages range operations is a build in data structure and trivial to use with 'for' lo...

Read more »

Building a package in RStudio is actually very easy

January 30, 2013
By
Building a package in RStudio is actually very easy

So, you’ve written some code and you use it routinely. Now you’ve written some code and you’d like to use version control to ensure that development continues in a robust fashion. You do that and you use Github or something so that not only are changes tracked, but the general public receives the benefit of

Read more »

The three-dots construct in R

January 30, 2013
By

There is a mechanism that allows variability in the arguments given to R functions.  Technically it is ellipsis, but more commonly called “…”, dots, dot-dot-dot or three-dots. Basics The three-dots allows: an arbitrary number and variety of arguments passing arguments on to other functions Arbitrary arguments The two prime cases are the c and list The post The...

Read more »