Economics should be open

July 29, 2009

Stata, control flow based on variable type

Filed under: Uncategorized — howardchong @ 12:45 am

Suppose you want to write a function (or a loop), where you do something to every variable that depends on its type. In matlab, I would use “isnumber”, etc, or just use the function that returns the type of the variable.

I couldn’t find such a function in stata. There is no “isnumeric” or “isfloat” function.

There is an extended function called “type”. This is my prefered way to do it:

local mytype : type myvarname
disp "`mytype'"

They also have “confirm”, which works:

http://www.stata.com/help.cgi?confirm

(more…)

July 28, 2009

octave error “error: invalid call to script”

Filed under: Uncategorized — howardchong @ 11:18 pm

I am new to Octave. I am using Octave 3.0 on windows (with octave-forge) and trying to call a script and get the following error:

“error: invalid call to script”

The fix?

I was trying to run hello1.m by typing

hello1.m

but I need to take the .m off and type

hello1

This error may also come up for different reasons, but this was my reason.

July 27, 2009

Input Output Table, generating from BEA data

Filed under: Uncategorized — howardchong @ 6:52 pm

I struggled a bit in putting together an input output  table (IO table) for the US economy in doing my research on the impact of carbon prices on industrial activity.

Here I include Octave (compatible with MATLAB) code to generate an input output table given 3 inputs from the Bureau of Economic Analysis:

  1. Total consumption
  2. Industrial activity linked to commodity (USE)
  3. Industries and how much of each commodity they produce (MAKE)

More…

(more…)

July 20, 2009

identity matrix in excel

Filed under: Uncategorized — howardchong @ 10:13 pm

So, excel can do matrix calculations. That’s useful. But why the hell didn’t it give us a function to create an identity matrix.

Here’s a quick hack (no programming) to generate an identity matrix.

(more…)

Blog at WordPress.com.