<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Economics should be open</title>
	<atom:link href="http://opensourceeconomics.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://opensourceeconomics.wordpress.com</link>
	<description>Howard Chong Economics Blog</description>
	<lastBuildDate>Tue, 11 Jan 2011 01:35:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='opensourceeconomics.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Economics should be open</title>
		<link>http://opensourceeconomics.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://opensourceeconomics.wordpress.com/osd.xml" title="Economics should be open" />
	<atom:link rel='hub' href='http://opensourceeconomics.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Tips for running long stata jobs, UNIX</title>
		<link>http://opensourceeconomics.wordpress.com/2010/06/03/tips-for-running-long-stata-jobs-unix/</link>
		<comments>http://opensourceeconomics.wordpress.com/2010/06/03/tips-for-running-long-stata-jobs-unix/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 00:51:24 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=207</guid>
		<description><![CDATA[Here are some tips for running large stata jobs in linux/Unix Turn off the GUI and run the command on the command line hit CTRL-F1 login sudo /etc/init.d/gdm stop // this stops the GUI stata -b do mydofile.do Run one command after another stata -b do firstfile.do ; stata -b do secondfile.do ; stata -b [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=207&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here are some tips for running large stata jobs in linux/Unix</p>
<p><span id="more-207"></span></p>
<ol>
<li>Turn off the GUI and run the command on the command line</li>
<pre>hit CTRL-F1
login
sudo /etc/init.d/gdm stop  // this stops the GUI
stata -b do mydofile.do</pre>
<li>Run one command after another</li>
<pre>stata -b do firstfile.do ; stata -b do secondfile.do ; stata -b do third.do</pre>
<li>Delay the start of the command</li>
<pre>sleep 14400 ; stata -b do myfile.do
#NOTE: sleep takes seconds as argument, so that is 4 hours. Adjust to your needs.</pre>
</ol>
<p>Don&#8217;t forget top to check on your processes. Don&#8217;t allocate so much memory that you start paging to disk.</p>
<p>Your hints/advice are welcome!</p>
<p><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;"><span style="line-height:18px;white-space:pre;font-size:x-small;"><br />
</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=207&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2010/06/03/tips-for-running-long-stata-jobs-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>CEC climate zones, zip5, and California counties</title>
		<link>http://opensourceeconomics.wordpress.com/2010/06/02/cec-climate-zones-zip5-and-california-counties/</link>
		<comments>http://opensourceeconomics.wordpress.com/2010/06/02/cec-climate-zones-zip5-and-california-counties/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 19:45:10 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=202</guid>
		<description><![CDATA[I gathered shape files for california and produced the following spatial correspondence table: CEC (California Energy Commission) Climate Zones (numbering 16). zip5 (polygons) CA counties (polygons) I used this by using the ArcTool called INTERSECT. I don&#8217;t have a great way of uploading the data, so if you want this data, help me upload it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=202&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I gathered shape files for california and produced the following spatial correspondence table:</p>
<p>CEC (California Energy Commission) Climate Zones (numbering 16).</p>
<p>zip5 (polygons)</p>
<p>CA counties (polygons)</p>
<p>I used this by using the ArcTool called INTERSECT.</p>
<p>I don&#8217;t have a great way of uploading the data, so if you want this data, help me upload it and it will be available to you (and everyone) for free.<a href="http://opensourceeconomics.files.wordpress.com/2010/06/intersect-picture-for-opensource.png"><img class="aligncenter size-full wp-image-203" title="ArcMap screenshot for intersect" src="http://opensourceeconomics.files.wordpress.com/2010/06/intersect-picture-for-opensource.png?w=944&#038;h=573" alt="" width="944" height="573" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=202&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2010/06/02/cec-climate-zones-zip5-and-california-counties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>

		<media:content url="http://opensourceeconomics.files.wordpress.com/2010/06/intersect-picture-for-opensource.png" medium="image">
			<media:title type="html">ArcMap screenshot for intersect</media:title>
		</media:content>
	</item>
		<item>
		<title>Stata: how to make sure your file exists</title>
		<link>http://opensourceeconomics.wordpress.com/2010/03/01/stata-how-to-make-sure-your-file-exists/</link>
		<comments>http://opensourceeconomics.wordpress.com/2010/03/01/stata-how-to-make-sure-your-file-exists/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 23:29:45 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=198</guid>
		<description><![CDATA[Use this info here to check if a file exists in your stata code. Uses CAPTURE and return codes (_rc) http://enoriver.net/index.php/2008/09/24/qualify-your-commands-with-capture/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=198&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Use this info here to check if a file exists in your stata code. Uses CAPTURE and return codes (_rc)</p>
<p><a href="http://enoriver.net/index.php/2008/09/24/qualify-your-commands-with-capture/">http://enoriver.net/index.php/2008/09/24/qualify-your-commands-with-capture/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/198/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=198&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2010/03/01/stata-how-to-make-sure-your-file-exists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>Fun with GIS, California zip9, cbg, latlon</title>
		<link>http://opensourceeconomics.wordpress.com/2010/02/08/fun-with-gis-california-zip9-cbg-latlon/</link>
		<comments>http://opensourceeconomics.wordpress.com/2010/02/08/fun-with-gis-california-zip9-cbg-latlon/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 05:14:37 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=196</guid>
		<description><![CDATA[So, I&#8217;m having lots of &#8220;fun&#8221; with GIS right now. I&#8217;m having to map zip9 (AKA zip+4, zip 9, zip5+4) in California to census block groups (and census tracts) (CBG / CT) and then to latitude and longitude. I&#8217;m having to do this because I haven&#8217;t found a similar list online. There are some data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=196&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;m having lots of &#8220;fun&#8221; with GIS right now.</p>
<p>I&#8217;m having to map zip9 (AKA zip+4, zip 9, zip5+4) in California to census block groups (and census tracts) (CBG / CT) and then to latitude and longitude.</p>
<p><span id="more-196"></span></p>
<p>I&#8217;m having to do this because I haven&#8217;t found a similar list online. There are some data vendors, but I&#8217;m old-fashioned and like to see the original data sets and do the merge myself.</p>
<p>Odd thing, though, is that I can&#8217;t find any zip9 polygons. I just have them as points. Which somewhat makes sense since zip9s are usually a couple of blocks at most, but it&#8217;d be nice to know which zip9&#8242;s are very large in area and which are small. (Could I back this out by checking the nearest neighbor distance?)</p>
<p>This is a pretty large spatial join since I have a count of 2,854,068 zip9&#8242;s in California and something on the order of  10,000-100,000  CBGs.</p>
<p>If you need crosswalks / correspondence tables for this data, please feel free to ask. Preference given to academic researchers and I will ask for a nominal fee (&lt;$50) for time spent preparing it for you, especially if you are not in academia/public-sector.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/196/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=196&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2010/02/08/fun-with-gis-california-zip9-cbg-latlon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>Pitfalls of STATA robust estimation, a quick simulation study.</title>
		<link>http://opensourceeconomics.wordpress.com/2009/11/02/pitfalls-of-stata-robust-estimation-a-quick-simulation-study/</link>
		<comments>http://opensourceeconomics.wordpress.com/2009/11/02/pitfalls-of-stata-robust-estimation-a-quick-simulation-study/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 23:50:42 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=192</guid>
		<description><![CDATA[Use of &#8220;robust&#8221; after regress in Stata seems to be automatic. From the textbooks,  robust is more asymptotically efficient, and there is only a small hit for not assuming homoskedasticity. There is one problem I am encountering, and that is in small samples. If your coefficient of interest has very little variation, be careful. Especially [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=192&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Use of &#8220;robust&#8221; after regress in Stata seems to be automatic. From the textbooks,  robust is more asymptotically efficient, and there is only a small hit for not assuming homoskedasticity.</p>
<p>There is one problem I am encountering, and that is in small samples. If your coefficient of interest has very little variation, be careful. Especially when measuring treatment effects where you have very few or very many treated observations.</p>
<p><span id="more-192"></span>Here&#8217;s where I had problems: I am conducting a stock market event study. We are trying to figure out what size of event window to use, so we run, for each stock:</p>
<p>return=alpha + beta * market + gamma1 * Day1 +gamma2*Day2 + gamma3*Day3 +epsilon</p>
<p>when we run this with robust, we get much smaller standard errors. We run the Ftest of &#8220;test Day1+Day2+Day3=0&#8243; and get significance.</p>
<p>But, when we later run:</p>
<p>return=alpha + beta * market + gamma1to3 * Day1to3 * 1/3 + epsilon,</p>
<p>we don&#8217;t get stat significance. And it&#8217;s all due to robust. (note, the 1/3 is there to rescale for 3 days)</p>
<p>&nbsp;</p>
<p>Delving further, I run a simulation where the dgp is y=x*1/4 + eps</p>
<p>I then regress y on x and a 1day event. I simulate 1000 times and here&#8217;s my results:</p>
<pre>
    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
          op |      1000   -.0266356    1.000336   -2.86643   3.137967
          os |      1000    1.000005    .0218117   .9318347   1.066719
       opval |      1000    .4983793    .2890897   .0011551    .999441
          rp |      1000   -.0266356    1.000336   -2.86643   3.137967
          rs |      1000    .0435009    .0135115   .0295254   .1079442
-------------+--------------------------------------------------------
       rpval |      1000    .0268978     .121465          0   .9918482</pre>
<div><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-size:small;"><span style="line-height:18px;white-space:pre;"><br />
</span></span></div>
<p>o designates OLS. op is the point estimate for event (should be 0), os is the stderr, and opval is the pvalue.  r designates robust, and rp, rs, and rpval are similarly defined.</p>
<p>Note that robust gives smaller std errors. In fact, much smaller. And this is due to the fact that this coefficient is estimated off one observation.</p>
<p>Importantly, this is NOT fixed if you increase the number of total observations. You have to increase the number of observations in the event. I rerun this with an eventsize of 10, and then OLS and robust are close to matching.</p>
<p>See and run the code to see what I mean.</p>
<p>CODE</p>
<pre>
<div id="_mcePaste">* simulation showing how robust raises the t stat for a time series event.</div>
<div id="_mcePaste">capture program drop eventSim</div>
<div id="_mcePaste">program define eventSim, rclass</div>
<div id="_mcePaste">syntax [, obs(integer 1) eventsize(integer 1) xcoeff(real 1) ]</div>
<div id="_mcePaste">drop _all</div>
<div id="_mcePaste">set obs `obs'</div>
<div id="_mcePaste">gen n=_n</div>
<div id="_mcePaste">gen x=rnormal()</div>
<div id="_mcePaste">gen y=x*`xcoeff'+rnormal()</div>
<div id="_mcePaste">gen event=n&lt;=`eventsize'</div>
<div id="_mcePaste">regress y x</div>
<div id="_mcePaste">regress y x event</div>
<div id="_mcePaste">matrix eb=e(b)</div>
<div id="_mcePaste">matrix ev=e(V)</div>
<div id="_mcePaste">return scalar OLSpoint=eb[1,2]</div>
<div id="_mcePaste">return scalar OLSstderr=sqrt(ev[2,2])</div>
<div id="_mcePaste">test event</div>
<div id="_mcePaste">return scalar OLSpvalue=r(p)</div>
<div id="_mcePaste">regress y x event, robust</div>
<div id="_mcePaste">matrix eb=e(b)</div>
<div id="_mcePaste">matrix ev=e(V)</div>
<div id="_mcePaste">return scalar ROBpoint=eb[1,2]</div>
<div id="_mcePaste">return scalar ROBstderr=sqrt(ev[2,2])</div>
<div id="_mcePaste">test even</div>
<div id="_mcePaste">return scalar ROBpvalue=r(p)</div>
<div id="_mcePaste">end</div>
<div id="_mcePaste">simulate op=r(OLSpoint) os=r(OLSstderr) opval=r(OLSpvalue) rp=r(ROBpoint) rs=r(ROBstderr) rpval=r(ROBpvalue), reps(1000): eventSim, obs(1000) eventsize(1)  xcoeff(.25)</div>
<div id="_mcePaste">su</div>
<div id="_mcePaste">simulate op=r(OLSpoint) os=r(OLSstderr) opval=r(OLSpvalue) rp=r(ROBpoint) rs=r(ROBstderr) rpval=r(ROBpvalue), reps(1000): eventSim, obs(1000) eventsize(10)  xcoeff(.25)</div>
<div id="_mcePaste">su</div>
<div id="_mcePaste">** note the mean of os, the mean of rs, and the standard deviation of op should all match.</div>
<div id="_mcePaste">** the reason is because the dgp is homoskedastic and the robust and ols extimators are both consistent.</div>
<div id="_mcePaste">** when eventsize is 10, they match pretty well.</div>
<div id="_mcePaste">** when eventsize is 1, the match is very bad. Robust gives abnormally small standard errors.</div>
<div id="_mcePaste">** my guess as to why is because the Huber-White robust estimates allow there to be a different sigmasq for the event period.</div>
<div id="_mcePaste">** When the event is small (or has size 1), then event is perfectly fitted (has zero residual) and that term in the</div>
<div id="_mcePaste">** heteroskedasticity matrix is small (or zero).</div>

* simulation showing how robust raises the t stat for a time series event.
capture program drop eventSimprogram define eventSim, rclass	syntax [, obs(integer 1) eventsize(integer 1) xcoeff(real 1) ]	drop _all	set obs `obs'	gen n=_n	gen x=rnormal()	gen y=x*`xcoeff'+rnormal()      gen event=n&lt;=`eventsize'	regress y x	regress y x event	matrix eb=e(b)	matrix ev=e(V)	return scalar OLSpoint=eb[1,2]	return scalar OLSstderr=sqrt(ev[2,2])	test event	return scalar OLSpvalue=r(p)
 regress y x event, robust	matrix eb=e(b)	matrix ev=e(V)	return scalar ROBpoint=eb[1,2]	return scalar ROBstderr=sqrt(ev[2,2])	test even	return scalar ROBpvalue=r(p)end
simulate op=r(OLSpoint) os=r(OLSstderr) opval=r(OLSpvalue) rp=r(ROBpoint) rs=r(ROBstderr) rpval=r(ROBpvalue), reps(1000): eventSim, obs(1000) eventsize(1)  xcoeff(.25)susimulate op=r(OLSpoint) os=r(OLSstderr) opval=r(OLSpvalue) rp=r(ROBpoint) rs=r(ROBstderr) rpval=r(ROBpvalue), reps(1000): eventSim, obs(1000) eventsize(10)  xcoeff(.25)su
** note the mean of os, the mean of rs, and the standard deviation of op should all match.** the reason is because the dgp is homoskedastic and the robust and ols extimators are both consistent.** when eventsize is 10, they match pretty well.** when eventsize is 1, the match is very bad. Robust gives abnormally small standard errors.** my guess as to why is because the Huber-White robust estimates allow there to be a different sigmasq for the event period.** When the event is small (or has size 1), then event is perfectly fitted (has zero residual) and that term in the** heteroskedasticity matrix is small (or zero).</pre>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=192&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2009/11/02/pitfalls-of-stata-robust-estimation-a-quick-simulation-study/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>Notepad++ and Stata, a better do file editor</title>
		<link>http://opensourceeconomics.wordpress.com/2009/10/13/notepad-and-stata-a-better-do-file-editor/</link>
		<comments>http://opensourceeconomics.wordpress.com/2009/10/13/notepad-and-stata-a-better-do-file-editor/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 01:16:56 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Stata]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=189</guid>
		<description><![CDATA[I do not like the bult in stata editor. It makes reading stata do files a chore. I come a bit from the programming world which will show commented lines and blocks in a different color and highlight reserved words. I looked for al alternative stata text editor / do file editor and like Notepad++. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=189&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I do not like the bult in stata editor. It makes reading stata do files a chore. I come a bit from the programming world which will show commented lines and blocks in a different color and highlight reserved words. I looked for al alternative stata text editor / do file editor and like Notepad++.</p>
<p>Notepad++ is a good alternative. You can still run blocks of code (like control-D) and who do file (like control-R) if you set it up. Plus it&#8217;s free.</p>
<p><span id="more-189"></span>Here&#8217;s my simple 3 step setup.</p>
<p>1) Download and install Notepad++</p>
<p>2) To get context highlighting, go here:  download the link to the stata XML file here <a href="http://notepad-plus.sourceforge.net/commun/userDefinedLang/userDefineLang_stata.xml">http://notepad-plus.sourceforge.net/commun/userDefinedLang/userDefineLang_stata.xml </a>.  Click  start, run, type (or paste in) <strong><em>%APPDATA%\Notepad++</em></strong> then click ok. Assuming you just installed Notepad++, just copy the file you downloaded to this directory, delete the existing <em>userDefineLang.xml</em> and rename your file <em>userDefineLang.xml.</em></p>
<p>3) To enable running code from Notepad++, follow steps 1-4 of the following page:</p>
<p><a href="http://s281191135.onlinehome.us/2008/20080427-stata.html">http://s281191135.onlinehome.us/2008/20080427-stata.html</a></p>
<p>It may look complicated, but it is just downloading two files, saving them to c:\ado\personal (or wherever you like), editing two setup files so it knows which stata version you use, and setting up the F9 ad F10 shortcuts.</p>
<p>That&#8217;s it.</p>
<p>You&#8217;ll get context highlighting, comment block highlighting, and keyword highlighting.</p>
<p>To change the colors of the highlighting, go to View | User Define Dialog</p>
<p>And follow the directions here: <a href="http://notepad-plus.sourceforge.net/uk/UserLanguageDefineSystem-HOWTO.php">http://notepad-plus.sourceforge.net/uk/UserLanguageDefineSystem-HOWTO.php</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=189&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2009/10/13/notepad-and-stata-a-better-do-file-editor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>Difference between WLS and weighted average</title>
		<link>http://opensourceeconomics.wordpress.com/2009/10/01/difference-between-wls-and-weighted-average/</link>
		<comments>http://opensourceeconomics.wordpress.com/2009/10/01/difference-between-wls-and-weighted-average/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 23:00:27 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Data Insights]]></category>
		<category><![CDATA[Stata]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=187</guid>
		<description><![CDATA[I hear the phrase &#8220;what does it look when we weight the data&#8221; a lot. It confused me for a while, but I figured it out: it could mean two things, so the response should be, which of the two do you want? Weighted Least Squares and weighted average are opposite concepts, in a sense. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=187&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I hear the phrase &#8220;what does it look when we weight the data&#8221; a lot. It confused me for a while, but I figured it out: it could mean two things, so the response should be, which of the two do you want?</p>
<p>Weighted Least Squares and weighted average are opposite concepts, in a sense.</p>
<p><span id="more-187"></span></p>
<p>Weighted Least Squares (WLS) is an assumption about your error structure. Let&#8217;s say your data is across cities and includes a population variable. If, in STATA, you type:</p>
<pre> regress LHS population otherRHS [aweight=population]</pre>
<p>then you are assuming that var(eps_i)=epssq_0*population, AKA variance is higher for large populations, you should give extra weight to the <em>smaller observations</em>. (See Greene, <em>Econometric Analysis)</em></p>
<p>If instead you want bigger populations to matter more, you&#8217;d have to aweight by something inversely proportional, perhaps the inverse of population.</p>
<p>When doing weighted average, you multiply by the population, so bigger cities have more influence. Granted, using a weighted average is restricted to computing averages, it&#8217;s not used as part of a regression analysis.</p>
<p>STATA also uses population weighting, which is more like weighted average than not. There, you are assuming precisely var(eps_i)=epssq_0/population. This functional form is driven by the a priori knowledge that your data points represent different sample sizes.</p>
<p>Be wary of anyone who says, &#8220;We should have observations with X matter more, so let&#8217;s run WLS with X.&#8221; They are mixing two concepts.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=187&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2009/10/01/difference-between-wls-and-weighted-average/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>List of european power plants, data sources for electricity generation</title>
		<link>http://opensourceeconomics.wordpress.com/2009/08/26/list-of-european-power-plants-data-sources-for-electricity-generation/</link>
		<comments>http://opensourceeconomics.wordpress.com/2009/08/26/list-of-european-power-plants-data-sources-for-electricity-generation/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 18:19:25 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Carbon Trading]]></category>
		<category><![CDATA[Data Insights]]></category>
		<category><![CDATA[Energy]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=183</guid>
		<description><![CDATA[I was looking for a list of power plants in Europe in 2008. I didn&#8217;t find one. You know why? It just got created in late 2008, and I just found it in 2009. http://carma.org/ More beta below the bump. Beta, AKA additional info Carma is not specifically pitched as a list of power plants [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=183&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was looking for a list of power plants in Europe in 2008. I didn&#8217;t find one. You know why? It just got created in late 2008, and I just found it in 2009.</p>
<p><a href="http://carma.org/">http://carma.org/</a></p>
<p>More beta below the bump.</p>
<h2><span id="more-183"></span>Beta, AKA additional info</h2>
<p>Carma is not specifically pitched as a list of power plants in Europe, but it covers Europe well. It is aimed at covering the world. You can download the data.</p>
<p>It has firm names or company names associated with each firm, as well as CO2 emissions, and generation in MWH.</p>
<p>It is not THAT well linked to companies, because some companies have subsidiaries. So, make sure you collect everything with the text &#8220;RWE&#8221; as an RWE company. <span style="text-decoration:underline;">I&#8217;ve done some linking, so if you want to compare, please shoot me a line and we can share.</span></p>
<p>You got to be careful of a few things. First, understand that much of Europe uses Combined Heat and Power (AKA cogeneration) and district heating. So, in this case, your tonsCO2/MWH might be high, but this may be due to the CHP. Second, Carma also covers a large amount of auto-generation and might cover refining and heat. For example, International Paper has a plant in Europe. I would guess this is a plant they run to supply their own electricity. Third (and this only matters if you&#8217;re charcterizing firms), I believe that many large firms have large <em>partially owned</em> subsidiaries. For example, consider ENBW. It is 45% owned by EDF and 45% owned by a german firm, according to Wikipedia:</p>
<blockquote><p>The two principal shareholders of EnBW are <a style="text-decoration:none;color:#002bb8;background-image:none;background-repeat:initial;background-attachment:initial;background-color:initial;background-position:initial initial;" title="Électricité de France" href="http://en.wikipedia.org/wiki/%C3%89lectricit%C3%A9_de_France">Électricité de France</a> (EDF), with a 45% share and Oberschwäbischen Elektrizitätswerke (OEW), with a 45% share. In accordance with a closed consortium agreement between EdF and OEW, EdF will take over the supervision over EnBW until 2012. Furthermore, the two shareholders agreed to keep the share ratios as they are and to vote in mutual agreement on important decisions.</p></blockquote>
<h2>Other Data Sources</h2>
<p>I&#8217;m not sure what their data source is, but I bet that they aggregated info from individual national information. For Europe, Eurostat does NOT have this information (to my knowledge), though Eurostat does report MWH and Carbon on a national basis, I think annually. IEA (International Energy Agency) has the same level of info as Eurostat.</p>
<p>The obvious issue with the Eurostat data is that it aggregates all the power plants in a country. Also a big issue (but not as obvious) is that it is somewhat easy to measure carbon for a country by tracking flows of fuels, but attribution to sectors (electricity, for example) may be problematic. At best, it&#8217;s a black box and we have to trust that it was done right.</p>
<p>Carbon from electricity is tracked very well by the CITL (Community Independent Transaction Log) of the European ETS (Emissions Trading Scheme). But this doesn&#8217;t report MWH.</p>
<p>Another potential source of info is EPER. But this is emissions only.</p>
<p>In the US, we have the CEMS system, which is continuous emission monitoring system. Data includes heat rate and power output at a high resolution (daily? hourly? I forget). Data is gov&#8217;t, so it is public. One problem is that carbon isn&#8217;t measured. Not such a big deal, since you can calculate it stoichiometrically from the input fuel information, at least in theory.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=183&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2009/08/26/list-of-european-power-plants-data-sources-for-electricity-generation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>Octave cell-arrays are pretty slow</title>
		<link>http://opensourceeconomics.wordpress.com/2009/08/14/octave-cell-arrays-are-pretty-slow/</link>
		<comments>http://opensourceeconomics.wordpress.com/2009/08/14/octave-cell-arrays-are-pretty-slow/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 17:50:14 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=181</guid>
		<description><![CDATA[I&#8217;m trying to figure out which open source statistical/computation package to use.  I used to use Matlab. It&#8217;s good, but expensive, and it has WAY more features than I need. I know I should be running things on Unix, but right now I&#8217;m on Windows XP. I sometimes putty into a Unix server and run [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=181&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to figure out which open source statistical/computation package to use.  I used to use Matlab. It&#8217;s good, but expensive, and it has WAY more features than I need.</p>
<p>I know I should be running things on Unix, but right now I&#8217;m on Windows XP. I sometimes putty into a Unix server and run things.</p>
<p>R looks very good. That&#8217;s  my next langauge to learn.</p>
<p>Octave is pretty good. It provides syntax almost identical to Matlab.  In 3.0, it now has support for Multidimensional Cell Arrays. These are arrays that can hold any data type. Most common for me is an array of strings. If you load data that is mixed text and numeric, then your data will probably be read as a cell-array.</p>
<p>One thing I have noticed is that the cell-arrays are really quite slow.</p>
<p>I had a ~10000 x 10 csv file.</p>
<p>Column 1 had mixed numeric and strings. They were 6 character codes, and about 2/3 of them did not have alphabetical characters. I needed to convert these to strings, and then do a sort and some other processing. I basically had to traverse each element of the first row and do the datatype change individually.</p>
<p>The process was VERY slow. In fact, I think Excel would be better at such tasks.</p>
<p>Here are a few tips:</p>
<ul>
<li>If you can, remove all strings from your CSV file.</li>
<li>If you read a large dataset as a large cell arrays, separate each column into its own variable. Then pack together the numeric data into a matrix (if needed).</li>
<li>STATA has an &#8220;encode&#8221; routine that converts strings into records stored as numeric. For example, if your data range is car makes, it will give each make a number and then also generate a lookup table where you can decipher what the numbers mean.</li>
</ul>
<p>Also check out this page that benchmarks the math/science packages with a set of standard routines:</p>
<p><a href="http://www.sciviews.org/benchmark/index.html">http://www.sciviews.org/benchmark/index.html</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=181&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2009/08/14/octave-cell-arrays-are-pretty-slow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
		<item>
		<title>Stata, control flow based on variable type</title>
		<link>http://opensourceeconomics.wordpress.com/2009/07/29/stata-control-flow-based-on-variable-type/</link>
		<comments>http://opensourceeconomics.wordpress.com/2009/07/29/stata-control-flow-based-on-variable-type/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 00:45:40 +0000</pubDate>
		<dc:creator>howardchong</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://opensourceeconomics.wordpress.com/?p=176</guid>
		<description><![CDATA[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 &#8220;isnumber&#8221;, etc, or just use the function that returns the type of the variable. I couldn&#8217;t find such a function in stata. There is no &#8220;isnumeric&#8221; or &#8220;isfloat&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=176&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>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 &#8220;isnumber&#8221;, etc, or just use the function that returns the type of the variable.</p>
<p>I couldn&#8217;t find such a function in stata. There is no &#8220;isnumeric&#8221; or &#8220;isfloat&#8221; function.</p>
<p>There is an extended function called &#8220;type&#8221;. This is my prefered way to do it:</p>
<pre style="padding-left:30px;">local mytype : type myvarname</pre>
<pre style="padding-left:30px;">disp "`mytype'"</pre>
<p>They also have &#8220;confirm&#8221;, which works:</p>
<p><a href="http://www.stata.com/help.cgi?confirm">http://www.stata.com/help.cgi?confirm</a></p>
<p><span id="more-176"></span></p>
<p>COPIED FROM STATA (accessed 7/28/2009):</p>
<pre style="margin:10px;">You are writing a command that performs some action on each of the
    variables in the local macro <em>varlist</em>.  The action should be different for
    string and numeric variables.  The <strong>confirm</strong> command can be used here in
    combination with the <a style="color:#000066;text-decoration:none;" href="http://www.stata.com/help.cgi?capture"><strong>capture</strong></a> command to switch between the different
    actions:

        <strong>foreach v of local </strong><em>varlist</em><strong> {</strong>
                <strong>capture confirm string variable `v'</strong>
                <strong>if !_rc {</strong>
                        <em>action for string variables</em>
                <strong>}</strong>
                <strong>else {</strong>
                        <em>action for numeric variables</em>
                <strong>}</strong>
        <strong>}</strong>

    An alternative solution using inline expansion of the extended macro
    function <strong>:type</strong> (see <a style="color:#000066;text-decoration:underline;" href="http://www.stata.com/help.cgi?local">local</a>) reads

        <strong>foreach v of local varlist {</strong>
                <strong>if substr("`:type `v''",1,3) == "str" {</strong>
                        <em>action for string variables</em>
                <strong>}</strong>
                <strong>else {</strong>
                        <em>action for numeric variables</em>
                <strong>}</strong>
        <strong>}</strong></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/opensourceeconomics.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/opensourceeconomics.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/opensourceeconomics.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/opensourceeconomics.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/opensourceeconomics.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/opensourceeconomics.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/opensourceeconomics.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/opensourceeconomics.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=opensourceeconomics.wordpress.com&amp;blog=4946512&amp;post=176&amp;subd=opensourceeconomics&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://opensourceeconomics.wordpress.com/2009/07/29/stata-control-flow-based-on-variable-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979bce5b2541ba645e36bbf8a9544c6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">howardchong</media:title>
		</media:content>
	</item>
	</channel>
</rss>
