Gams code snippet for checking consistency of a matrix

In an earlier post, I showed how to include code snippets in your program. One of the most important principles of programming is the DRY principle: Don’ Repeat Yourself. Code snippets can be used to do stuff you have to code over and over again.
One such a task for me is checking if the row and column totals in a matrix are equal (for example in the input output table you use, you want to check if supply is equal to demand).
 
Here is the code snippet:
 
 
Now you can batinclude (meaning that you can pass
Read the rest “Gams code snippet for checking consistency of a matrix”

Using code snippets in Gams: batinclude

One of the important rules of good programming is the DRY principle: Don’t Repeat Yourself. After repeating myself too often, I decided to start working with code snippets and macros for often used code. Here is an example of code I use very often. Suppose you want to aggregate your data from your input-output table to more aggregated version, for example, from 87 sectors to only 5 sectors, so you can test your model more easily). In GAMS you do this with a mapping, where you map the 87 sectors to the 5 sectors. This mapping can then be used
Read the rest “Using code snippets in Gams: batinclude”

Viewing all the objects in R in a buffer in Emacs

You also probably did not read the complete Emacs-Speaks-Statistics manual… ? By chance, I discovered a nice feature, called Rdired.
This command gives you a dired-buffer with all your objects. In this buffer you can view, edit and plot your R-objects. It is documented in chapter 12.9 of the manual.
 
Here is small example: In the buffer in the middle, you see the original code taken from the manual. I invoked ess-rdired and the lower buffer is shown. I then put the cursor on the line with the parameter s and hit “v”. This gave me the upper buffer
Read the rest “Viewing all the objects in R in a buffer in Emacs”

Auto-Completion in Emacs, LaTeX and Gams

The fun with Emacs is that you can discover new (or old) stuff that makes your life much easier on an almost weekly base. I was reading the manual on Emacs Speaks Statistics and discovered that there is a mode called auto-completion. I googled it, installed it and after some experimenting, I got it running. You can find it here. It comes with autocompletion for some programming languages (Python, Ruby, C+, etc.) but not for LaTeX, so I googled further and discovered an extension called auto-complete-latex (you can download it here.
Here are some screenshots: You just start
Read the rest “Auto-Completion in Emacs, LaTeX and Gams”