Wednesday, January 20, 2010

Replicating Econbrowser's replication of CEA analysis

There was an interesting post on Econbrowser where the impact of the fiscal stimulus done by the CEA was replicated.

options nocenter;
filename gdp 'C:\ReplicateCEA\GDPC1.txt';
/* File downloaded from FRED St. Louis */
data GDP;
infile gdp firstobs = 14;
/* Read two variables: date and GDP */
input date value;
informat date yymmdd10.;
format date yymmdd10.;
lngdp = log(value);
y=lngdp;
/* Calculate the first difference of y */
diffy = dif(y);
run;

data gdp4q;
set GDP end=last;
output;
if last then do;
date = '01Oct2009'd;
value = value * 1.04;
lngdp = log(value);
y=lngdp;
output;
end;
run;

data gdp4q;
set gdp4q;
dateq = put(date,yyq6.);
run;

filename nfp 'C:SVAR\ReplicateCEA\PAYEMS.txt';
/* File downloaded from FRED St. Louis */
data NFP;
infile nfp firstobs = 16;
/* Read two variables: date and GDP */
input date value;
informat date yymmdd10.;
format date yymmdd10.;
lnnfp = log(value);
e=lnnfp;
/* Calculate the first difference of y */
diffnfp = dif(e);
dateq = put(date,yyq6.);
run;

data nfp2;
set nfp; by dateq date;

if last.dateq then output;
run;

data gdp_nfp(drop = ln: diff:);
merge gdp4q(in=a rename = (value = gdp)) nfp2(in=b rename = (value = nfp));

by dateq;
if a and b;
run;

proc print data = gdp_nfp noobs;
where year(date)>=2007;
run;

ods output ParameterEstimates=pe;
proc varmax data = gdp_nfp;
where 1990<=year(date)<=2007;
id date interval = qtr;
model y e /p=4 ;
output lead=12 out = for;
run;

proc transpose data = pe out = pe_ty;
where equation = 'y';
var estimate;
id parameter;
run;

data pe_ty;
set pe_ty(rename = (const1 = intercept) drop = _name_);
_type_ = 'PARMS';
_model_ = 'Baseline';
_depvar_ = 'y';
y = -1;
RUN;

proc transpose data = pe out = pe_te;
where equation = 'e';
var estimate;
id parameter;
run;

data pe_te;
set pe_te(rename = (const2 = intercept) drop = _name_);
_type_ = 'PARMS';
_model_ = 'Baseline';
_depvar_ = 'e';
e = -1;
RUN;

%macro genar(lag=,eq1=,eq2=,var1=,var2=);
%do i=1 %to &lag;
%do e=1 %to &eq2;
ar&i._&eq1._&e=lag&i(&&var&e);
%end;
%end;
%mend genar;

options mprint;
data gdp2;
set gdp_nfp;
%genar(lag=4,eq1=1,eq2=2,var1=y,var2=e);
run;

data e2;
set gdp_nfp;
%genar(lag=4,eq1=2,eq2=2,var1=y,var2=e);
run;

proc score data = gdp2 score = pe_ty out=gdp2_score type=parms;
var ar1_1_1 ar1_1_2 ar2_1_1 ar2_1_2 ar3_1_1 ar3_1_2 ar4_1_1 ar4_1_2;
run;

proc score data = e2 score = pe_te out=e2_score type=parms;
var ar1_2_1 ar1_2_2 ar2_2_1 ar2_2_2 ar3_2_1 ar3_2_2 ar4_2_1 ar4_2_2;
run;

symbol1 value=none i=join;
symbol2 value=none i=join;
proc gplot data = gdp2_Score;
where year(date)>=2008;
plot (baseline y) * date / overlay;
run;
quit;

proc gplot data = e2_score;
where year(date)>=2008;
plot (baseline e) * date / overlay;
run;
quit;

Sunday, January 17, 2010

What I've been reading

1. Three Scientists and their Gods: Looking for Meaning in an Age of Information by Robert Wright: Was more interesting than I expected. One review is here. The book features (1) computer scientist Ed Fredkin who believes that the universe IS a computer, (2) sociobiologist E. O. Wilson, and (3) Quaker economist Kenneth Boulding. The book presents their views on how they view their world and what shaped their views.

2. Swoosh: The Unauthorized Story of Nike and the Men Who Played There by JB Strasser and Laurie Becklund. Another book which was more interesting than I had expected. It was NOT a story of Phil Knight who declined to be interviewed for the book. What is interesting about the book is the absence of Knight after Nike went public and plunged into a product crisis lurching from apparel to uninspired shoe after uninspired shoe (except for the success of Air Jordan) and how it was overtaken by Reebok. This seems to be a story of another company with 'founderitis' -the inability of its founders to deal with the changing marketplace perhaps as a direct result of the wealth brought on by the IPO.

Interesting titbit: None of the original people of Nike liked the Swoosh logo and none (except for Jeff Johnson who came up with the name) liked calling the company Nike. Missing from the book is probably a good description of the shoe making process. This is discussed mainly toward the latter part of the book as Nike was foundering and unable to come up with innovative products and the extremem difficulties they encountered when trying to put sacs filled with air in the soles.

3. Two Park Street: A Publishing Memoir by Robert Brooks about his time as editor-in-chief of the Trade department at Houghton Mifflin. He recounts the role he played in bringing to publication the Peterson Field Guides, Rachel Carson's Silent Spring and Winston Churchills 6 volume work on World War 2 among others (Lord of the Rings was published in the UK and Houghton Mifflin bough the rights for U.S.). The memoirs paint a romantic view of book publishing during his tenure (from the 1930s to 60s).

Average monthly condo fees in the U.S.


Data source:
Steven Ruggles, Matthew Sobek, Trent Alexander, Catherine A. Fitch, Ronald Goeken, Patricia Kelly Hall, Miriam King, and Chad Ronnander. Integrated Public Use Microdata Series: Version 4.0 [Machine-readable database]. Minneapolis, MN: Minnesota Population Center [producer and distributor], 2008.

We've been looking at condos around the DC area and it got me wondering as to what the average condo fees were like around the country. The above is a chart of the average condo fees tabulated from IPUMS. Because of topcoding the average is below the true average. The mean and max are labeled at the end of the bars. Unfortunately, I'm unable to improve on the resolution of the jpeg.

The SAS code for this is:

proc means data = cf.hh2008 N mean std min max;
where year = 2008 and condofee > 0;
class stateicp;
var condofee;
weight hhwt;
output out = summ mean = meancondofee min = mincondofee max=maxcondofee;
run;

data summ2;
set summ;
proc sort; by descending meancondofee;
run;

data annosum;
set summ2;
%annomac;
%dclanno;
%system(2,2,3);
midpoint = stateicp;
x = round(meancondofee,1);
lbl = compress(put(meancondofee, 8.)"/"put(maxcondofee, 8.));
%label(x,.,lbl,black,0,0,1.8,swissb,6);
run;

filename grafout 'chart1.jpeg';
goptions device = jpeg targetdevice = jpeg ftext="Verdana" gsfname = grafout xmax=8 in ymax=6 in xpixels=4000 ypixels=3000 vpos=40 hpos=40 lfactor=1 ;
axis1 label = none;
title1 h=1 'Average monthly condominium fees in 2008: U.S. States';

proc gchart data=summ2;
where _type_ ^=0;
hbar stateicp / sumvar=meancondofee maxis=axis1 discrete descending nostat anno=annosum(where=(_type_^=0));
run;
quit;

Saturday, January 16, 2010

Seals as predictors of earthquakes?

This news item in early January caught my eye:

The sea lions of San Francisco are almost as famous as the city's cable cars or even the Golden Gate bridge, says the BBC's Peter Bowes in Los Angeles.

Twenty years ago, for no apparent reason, the smelly, noisy animals took up residence in the docks at Pier 39.

Their numbers grew rapidly to about 1,700 animals, and they became a popular tourist attraction.

But then most of them disappeared.
....
One outlandish suggestion was that they were fleeing the bay because of an imminent earthquake, our correspondent says.

The seals were found off the coast of Oregon. But did they really sense the imminent earthquake on January 9?

Lost decade of retirement

This post by Jim Hamilton on the lost decade for stocks made me check on my mutual fund returns:

Fund _______________5 years_____________10 years/inception
TRP Retirement ................ -2.92% ............................... -1.83%
TRP Equity Index...............0.79%................................. -0.40%
TRP Growth........................2.45%................................. 2.03%
TRP International...............6.19%.................................. 1.54%
TRP Science & Tech ...........4.62%..................................-5.8%

Assuming inflation rate of about 3% on average I may have been better off putting the money under my mattress. The lost decade is testing my faith in buy and hold.

Saturday, January 9, 2010

Haunting first lines

"Last night I dreamt I went to Manderley again."
Rebecca, by Daphne Du Maurier

"I came to Comala because I had been told that my father, a man named Pedro Paramo, lived there. It was my mother who told me. And I had promised her that after she died I would go see him."
Pedro Paramo by Juan Rolfo

Wednesday, January 6, 2010

Entropy and free trade

Is it possible to use entropy as an analogy to free trade? Contrary to intuition, maximum entropy is not totally free trade but but some point between free trade and autarky (and perhaps speculatively close to autarky itself).

This analogy is used to illustrate why free trade is not a stable equilibrium. (As free market liberals would say - if free trade were so great we'd already be there. There would be no need for the WTO.)

1. Energy has to be expended to bring the world closer to free trade. If this energy is insufficient the trading system would tend toward autarky.
2. Free trade cannot spontaneously happen. Work is required to achieve it.
3. The energy/work that is applied to achieving free trade can dissipate quickly into a lot of hot air.