Matrix exponentiation in R

Why is there no matrix exponentiation in R?

I need it all the time, for dealing with continuous time Markov chains, but it just isn’t there!

Well, it is probably found in a lot of packages (maybe even some I have installed), but I feel it should be there as a built in function.

I usually end up implementing it myself using eigen value decomposition

mexp <- function(Q,t) {
  ## calculates matrix exponential using a simple eigen-value decomposition
  x <- eigen(Q)
  U <- x$vectors
  L <- diag(exp(t*x$values))
  return (U %*% L %*% solve(U))

but that isn’t that numerically stable, so it is a sub-optimal solution.

I guess it isn’t trivial to get right, but damn I miss it…


Collaborating using Google Docs

When collaborating on writing a paper, I often use a version control system like subversion.

It lets you keep track of changes and also lets different people work on different sections in the paper concurrently, since the system can merge changes when they are committed.

This works great for plain text documents.  So great for LaTeX documents.  Not so well for Word documents.  Not that I write that many papers in Word, but I’m collaborating more and more with people who do, and that means sending copies of Word documents around by email (with the obvious problems of merging changes manually and such).

On a current project we are using Google Docs instead.

It is much better.  There is a master copy, so everyone works on the same document (no manual mergin), we can work on it concurrently, and it keeps track of changes.

Plus, as I just found out today, you can even work on documents when offline, if you have Google Gears installed.

It also works great for sharing small additional notes and thoughts on the project.  Normally I would write my thoughts on my blog, but for some projects I cannot really share all our work until we publish.  Having the ideas on Google Docs is a nice alternative then, especially since my collaborators can then add to them and make them even better.

There are only a few features I really miss.

Like a LaTeX plugin for writing math.  With just plain text, math is very hard to get right.  Yes, you can also share LaTeX documents, but you have to pull the code down in a text file to process it, and that kind of defeats the purpose.

I would also love to see proper handling of references.  Like an integration with Zotero or something like that.  That would be sweet.