Warning: include_once(/home/nullvoid/blog.mikezhang.com/wp-content/plugins/wordpress-support/wordpress-support.php): failed to open stream: Permission denied in /home/nullvoid/blog.mikezhang.com/wp-settings.php on line 217

Warning: include_once(): Failed opening '/home/nullvoid/blog.mikezhang.com/wp-content/plugins/wordpress-support/wordpress-support.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/nullvoid/blog.mikezhang.com/wp-settings.php on line 217
NullVoid » Notes NullVoid » Notes


Political Uncertainty and Corporate Investment Cycles

Tuesday, June 19th, 2012 -- By ET

I read this paper from Journal of Finance (2012 Feb issue).  It tells an interesting story: during election years, firms reduce investment expenditures by an average of 4.8% relative to nonelection years, across nations, controlling for growth opportunities and economic conditions.

The authors explained the observation with political uncertainty.  I wonder if more can be done on this. Does political uncertainty affect individual firms or the economy in general? Would these elections also affect end consumers/voters?  There seems to be a lot of interesting questions related to this topic.

Why SOPA is Bad to Innovation

Wednesday, January 18th, 2012 -- By ET

SOPA stands for Stop Online Piracy Act, which is a legislation introduced by the US House of Representatives. Websites like Google and Wikipedia believe this is Internet Censorship and it will cripple the Internet.

Wikipedia showed a blackout page today to protest, and it will last for 24 hours.

In my paper with Feng Zhu (You can download the paper from here.) published in June 2011 in the American Economic Review (AER), we studied the effect of blocks of the Chinese Wikipedia on incentives to contribute.

A direct effect is obviously that many people can no longer contribute to Wikipedia.

The following figure suggests that contributions from China reduced significantly after the block.

The bar chart further compares the contributions from different regions before and after the block.

An indirect effect is that people who were not directly blocked also reduced their contribution significantly. In the paper we estimate that the reduction in contribution from those who are outside China is more than 40% within the 4 weeks after the block.

The next figure shows the number of new contributors. It can be clearly seen that each block (shown in shaded areas) significantly reduced new contributors.

The lesson learned: information needs to be free. Legislation not well thought out may bring unintended consequences.

The Myth

Thursday, June 16th, 2011 -- By ET

<br />



My Myth


Many ions ago there lived a powerful and beautiful goddess
called Claudia. Claudia was gentle and kind and she lives in a village full of
gods that sat on top of a cloud which floated about in the turquoise blue sky.  Claudia was the goddess of weather so she
controlled the wind, sun and the clouds. Every morning she would go to the
middle of the village and make the sun rise, and then she would decide what
weather she wanted.


Meanwhile in the underground was Zeuseus, a big and evil dragon
with eyes as black as coal. Zeuseus lived in a castle that looked like haunted
house. Zeuseus was mad that no flowers ever grew in the underground even after
he planted some seeds because there was no water in the underground.


One day Zeuseus flew out of the underworld went to fly around
the forest he saw a poster stuck on a bark of a tree. On it said:


Servants needed, please call Claudia The Weather God at
456123789 or email a message before 30th January Thank You!


Just after Zeuseus read the poster on
the bark of the tree he reached out and grabbed the poster of the tree, and
flew back to his house.


When Zeuseus went back home he wrote down his evil plan to steal
the rain clouds from Claudia into his notebook this is what he wrote:

    Plan to steal the rain


Dress up as a god and call Claudia to say I take the job to be a

Then when she’s not looking I will coax the clouds to follow me
or I pretend I need to borrow the rain clouds but never give the rain clouds



When he finished writing his plan he stepped back to admire his
work then he remembered the purpose of writing the notes.


Zeuseus disguised himself with his magic, called Claudia and
flew of to Claudia’s palace in the village of gods floating in the clouds.


Zeuseus was warmly welcomed when he arrived at the palace, and
just as he hoped he was working in the room with the balcony where the rain
clouds hanged about and there were all asleep! Zeuseus couldn’t believe his


 When he made sure no
one was looking he changed back to his real form, grasped onto the clouds and
flew back to his underground home.


When Zeuseus got home he tried to make the clouds to do what he
wanted them to do but the clouds always refused and did the opposite of what
Zeuseus wanted them to do.


Just as Zeuseus was about to give up, a letter slipped in from
the Mail box hole, Zeuseus picked it up and opened it:


Dear Zeuseus,

I know that you stole my rain clouds and I would like to have
them back. You could borrow them for nine months if you would not cause any
more trouble with the weather.

Thank you!!!



Zeuseus wrote a letter back:


Dear Claudia,


I would not like to borrow your clouds because they wouldn’t
listen to me!!!!!!!!!!



After Zeuseus finished writing the letter he sent the clouds and
the letter to Claudia.


And that is how sunny days and rainy days were created.




Traits of Successful Business Executives

Friday, August 13th, 2010 -- By ET

I’m doing some literature review for a paper of mine. I came across the following paper:

The Business Executive: The Psychodynamics of a Social Role

By: William E. Henry

The American Journal of Sociology, Vol. 54, No. 4, Industrial Sociology (Jan., 1949), pp. 286-291.


It was written in 1949, and talks about the common characteristics of successful business executives. Typically I do not find these descriptive papers useful, but it is interesting to see how people in 1949 perceive what executives should do to be successful.

The paper listed the following personality patterns that are common for success:

    Achievement Desires
    Mobility Drive
    Idea of Authority
    Ability to Organize Unstructured Situations
    Strong Self-Structure
    Apprehension and the Fear of Failure
    Activity and Aggression
    Strong Reality Orientation
    Different Interpersonal Relations with respect to Superiors and Subordinates
    Broken Tie with his own Parents
    Dependency Feelings and Concentration Upon Self

That was a long list, if you check these on people we know, say Steven Jobs, you would probably be amazed how accurate these items can “predict” his success. I’m constantly suspicious of this type of work because they obviously miss the sample of failed cases. It could be the case that people who share these traits fail more, but due to the sample selection problem, we cannot observe them. What if some other factors are driving the success of these people, and they just learned to behave in this way (i.e., behaving in this way does not produce success.)?

This brings back to the argument of my paper: when people assume social roles, they behave according to the perceived traits of these roles. In many situations, the list of characteristics is a result of being successful, not a source of it.

Run Robust Regression in R

Sunday, August 8th, 2010 -- By ET

Here is how:

model1 < - lm(dev ~ ind1 + ind2) sandwich(model1) vcovHC(model1, type = "HC")

A Complicated SQL Query

Monday, August 17th, 2009 -- By ET

Just wrote the most complicated SQL query I’ve ever encountered.  Since the table “clicks” has more than 5 million records, I’m going to wait till tomorrow to get the result.

The reason I have to write this is that I was trying to use a PERL program to do the same, and so far, after two days, it is still running with very slow progress.

create table sqlhistory as
SELECT a.inc, a.clicktime, (SELECT MAX(clicktime) FROM clicks b
where a.keyid=b.keyid and a.adid=b.adid and b.clicktime<a.clicktime
) as bctime, a.keyid, a.adid, a.bid, a.price, a.rank, a.reserve_price, a.reserve_price_new
FROM clicks a
where a.bid<>(select c.bid from clicks c
where a.keyid=c.keyid and a.adid=c.adid and c.clicktime=(SELECT MAX(clicktime) FROM clicks b
where a.keyid=b.keyid and a.adid=b.adid and b.clicktime<a.clicktime

limit 1


Sun Wei suggested a new way to do it, and the productivity increased almost 1000 fold


create table clickorder as
select * from clicks
order by keyid, adid, clicktime


create an auto_increment field called ‘inc’, and a new field called lastbid


update clickorder a, clickorder b
set a.lastbid=b.bid
where b.inc=a.inc-1 and a.keyid=b.keyid and a.adid=b.adid

Decimal Point Alignment in Latex

Monday, September 8th, 2008 -- By ET

UPDATE: A web-based version is available. You don’t need to upload the whole file to do the conversion now.

Check out the new version at: http://blog.mikezhang.com/dcolumn/processtable.cgi.

It has been a headache to do decimal point alignment in latex.

Fortunately, there is a package called dcolumn that helps with this problem.

This dcolumn package “defines a system for defining columns of entries in an array or tabular which are to be aligned on a ‘decimal point’.”

Unfortunately, it is very hard to make the modifications manually on the tables to align the decimal points of numbers.  I searched online and could not find a solution.  So I created a web service that does this:

Basically, just visit the webpage: http://blog.mikezhang.com/dcolumn/.


There is only one field for you to browse a latex file.  Make sure it has extension .tex, otherwise, the system would not accept the file.

Click Submit, you will obtain the converted file with correctly aligned numbers in your tables.

See the screen shot of the finished page:


Now clicking “FILE” will bring you the new file, in txt format.  You need to change the extension to .tex to try it out.  This intended trouble helps you to avoid overwriting your original file.

Here is how it worked on a paper:



and After:


Perl Reading A File

Thursday, August 28th, 2008 -- By ET

Read from a file, and write out. Just put it here for my own reference.



open(DAT, $data_file) || die(“Could not open file!”);

#print “Content-type: text/html\n\n”;
#print “”;

foreach $lines (@raw_data)
print “$var1,$var2,$var3\n”;
# print ”

#print “”;

multinomial logit in R

Monday, August 11th, 2008 -- By ET

# load the data
> nes96 <- read.table(“http://www.stat.washington.edu/quinn/classes/536/data/nes96r.dat”, header=TRUE)

# load the nnet library which has the multinom function
> library(nnet)
Loading required package: MASS

# let’s change the PID variable into a factor
> nes96$PID <- factor(nes96$PID, labels=c(“Strong Democrat”, “Weak
Democrat”, “Independent-Democrat”, “Independent-Independent”,
“Independent-Republican”, “Weak Republican”, “Strong Republican”))

# fit a multinomial logit model where PID is the response variable,
# and the predictors are: log(popul+.1), selfLR, age, educ, and income

> multinom.out <- multinom(PID~log(popul+.1)+selfLR+age+educ+income,
# weights: 49 (36 variable)
initial value 1836.939181
iter 10 value 1691.507857
iter 20 value 1603.709441
iter 30 value 1523.540117
iter 40 value 1461.935703
final value 1461.922748

# let’s take a look at the results
> summary(multinom.out, corr=FALSE)

Re-fitting to get Hessian

multinom(formula = PID ~ log(popul + 0.1) + selfLR + age + educ +
income, data = nes96)

(Intercept) log(popul + 0.1) selfLR age
Weak Democrat -0.3733563 -0.01153736 0.2976980 -0.024944529
Independent-Democrat -2.2509348 -0.08875096 0.3916628 -0.022897526
Independent-Independent -3.6659051 -0.10596768 0.5735134 -0.014851243
Independent-Republican -7.6136944 -0.09155519 1.2787425 -0.008680754
Weak Republican -7.0604314 -0.09328575 1.3469400 -0.017903442
Strong Republican -12.1051935 -0.14087942 2.0699883 -0.009432601
educ income
Weak Democrat 0.082487696 0.005195818
Independent-Democrat 0.181044184 0.047874118
Independent-Independent -0.007131611 0.057577321
Independent-Republican 0.199828063 0.084495215
Weak Republican 0.216938699 0.080958623
Strong Republican 0.321923127 0.108890412

Std. Errors:
(Intercept) log(popul + 0.1) selfLR age
Weak Democrat 0.6298384 0.03428246 0.09362654 0.006524873
Independent-Democrat 0.7631917 0.03916169 0.10823837 0.007914493
Independent-Independent 1.1565170 0.05703689 0.15854307 0.011331040
Independent-Republican 0.9575695 0.04379006 0.12889466 0.008418690
Weak Republican 0.8443601 0.03935158 0.11718480 0.007611003
Strong Republican 1.0599179 0.04213748 0.14340364 0.008133748
educ income
Weak Democrat 0.07358680 0.01763372
Independent-Democrat 0.08528965 0.02228102
Independent-Independent 0.12628792 0.03361350
Independent-Republican 0.09412459 0.02619610
Weak Republican 0.08500687 0.02297606
Strong Republican 0.09109678 0.02530048

Residual Deviance: 2923.845
AIC: 2995.845

# the results above aren’t too surprising– for instance we see that
# more conservative respondents are more likely to be Republican identifiers
# than Democratic identifiers or independent identifiers. Income has a
# similar effect. Republican identifiers also tend to be better educated
# than other identifiers.

# let’s look at some fitted probabilities. To do this, we’ll set all of
# the covariates (except selfLR) equal to their median values and vary
# selfLR from its low value to it’s high value.

> beta <- coef(multinom.out)
> X <- cbind(1, 3.096, 1:7, 44, 4, 17)

> Xb1 <- X %*% beta[1,]
> Xb2 <- X %*% beta[2,]
> Xb3 <- X %*% beta[3,]
> Xb4 <- X %*% beta[4,]
> Xb5 <- X %*% beta[5,]
> Xb6 <- X %*% beta[6,]

> denomsum <- exp(Xb1) + exp(Xb2) + exp(Xb3) + exp(Xb4) + exp(Xb5) +

> p0 <- 1/(1+denomsum)
> p1 <- exp(Xb1)/(1+denomsum)
> p2 <- exp(Xb2)/(1+denomsum)
> p3 <- exp(Xb3)/(1+denomsum)
> p4 <- exp(Xb4)/(1+denomsum)
> p5 <- exp(Xb5)/(1+denomsum)
> p6 <- exp(Xb6)/(1+denomsum)

> plot(0:6, p0, xlab=”Self LR Placement”, ylab=”", ylim=c(0,1), type=”l”,
col=1, pch=16)
> lines(0:6, p1, col=2)
> lines(0:6, p2, col=3)
> lines(0:6, p3, col=4)
> lines(0:6, p4, col=5)
> lines(0:6, p5, col=6)
> lines(0:6, p6, col=7)
> legend(0, 1, legend=c(“Strong Dem.”, “Weak Dem.”, “Ind. Dem.”, “Ind.
Ind.”, “Ind. Rep.”, “Weak Rep.”, “Strong Rep.”), col=1:7, lty=1)

A Note on Good Chinese Restaurants in HK

Thursday, June 5th, 2008 -- By ET

Found from here.

A couple of abbreviations: ‘TST’=Tsim Sha Tsui, and ‘CWB’=Causeway Bay.

District Type Restaurant Address Phone
Admiralty Beijing Peking Garden Pacific Place shopping mall
Admiralty Shanghai Shanghai Garden Hutchison House
Admiralty Sichuan Sichuan Garden Pacific Place shopping mall
Central Cantonese Lei Garden Shop No. 3007-3011, 3/F.,
International Finance Centre
Central Cantonese Tai Woo 92 & 100 Caine Road, Central
Central Chiu Chow Garden Chiu Chow Garden Jardine House
Central Hunan Hunan Garden The Forum tower,
Exchange Square
CWB Beijing Peking Garden Lee Theatre Plaza
CWB Cantonese Jade Garden 1 Hysan Avenue
CWB Hakka Hakka Hut 21/F Lee Theatre Plaza,
99 Percival St
CWB Shanghai Crystal Jade Shop B224 (basement),
Times Square
CWB Shanghai vegetarian Kung Tak Lam 31 Yee Wo Street
Mongkok Cantonese Lei Garden 121 Sai Yee Street 2392-5184
TST Cantonese Jade Garden Star House
TST Beijing Peking Garden Star House
TST Beijing The Spring Deer 36-44 Mody Road, 1st Floor 2723-3673
TST Hakka Hak-ka Hut 6/F, Miramar Shopping Centre,
132 Nathan Road
TST Northern / Hot-pot Tai Fung Lau 1/F Windsor Mansion,
29 Chatham Road South
TST Shanghai Crystal Jade 3328 Harbour City,
Canton Road
TST Shanghai vegetarian Kung Tak Lam 7th floor, 1 Peking Road
TST East Cantonese Lei Garden B-2, Houston Centre 2722-1636
Wanchai Cantonese Lei Garden 1/F., CNT Tower,
338 Hennessy Road
Wanchai Cantonese Tack Hsin 84-86 Morrison Hill Road,
Tsung Tsin Mansion
Yau Ma Tei Beijing The Peking Restaurant 1/F, 227, Nathan Road

Here’s a set of recommendations from Spike over at Hongkietown.

I’d add:

Tai Woo, East Ocean. Tack Hsin and Hoi Tin — four chains all over HK, very competent and reasonably priced Cantonese seafood palaces and decent dim sum.

Little Sheep — China-based chain famous for northern style hotpot.

Under Bridge Spicy Crab — as the name says.

Xiao Nan Guo — Shanghai-based chain

and reading the Cha Xio Bao blog for lots of great, off-the-beaten path tips.

Mr Tall adds:

I’ve done a bit of googling about for some specifics. I certainly haven’t tried all of these places, and if you know of one that’s moved/closed/terrible, please let us know.

  • You can find Tai Woo restaurant branches as follows:Causeway Bay Branch:
    27 Percival Street.
    Tel: 2893 0822; 2893 9882

    Shau Kei Wan Branch:
    192 – 198, Shau Kei Wan Road, Sai Wan Ho

    Central Branch:
    92 & 100 Caine Road, Central

    Tsim Sha Tsui Branch:
    14 – 16 Hillwood Road, Tsim Sha Tsui

  • There are East Ocean branches as follows:5/FL., Miramar Shopping Ctr.,
    132 Nathan Road, Tsimshatsui, Kowloon.
    Phone: 2317 8889

    Level 3-302, New World Centre,
    Tsimshatsui, Kowloon.
    Phone: 2367 1133

    Shop 3202, Harbour City,
    Tsimshatsui, Kowloon, H.K.
    Phone: 2956 2882

    B1 East Ocean Ctr., 98 Granville Road,
    Tsimshatsui East, Kowloon.
    Phone: 2723 8128

    2/FL., Sun Hung Kai Centre,
    30 Harbour Road, Wanchai, Hong Kong.
    Phone: 2827 9938

    3/FL., Harbour Centre, 25 Harbour Road,
    Wanchai, Hong Kong.
    Phone: 2827 8887

    5/FL., CITIC Tower, 1 Tim Mei Avenue,
    Central, Hong Kong.
    Phone: 2877 2211

    Shop G201 The Repulse Bay,
    109 Repulse Bay Road, Hong Kong.
    Phone: 2803 1882

  • Now how about some Tack Hsin outlets:1-13 Sugar Street
    Causeway Bay HK
    2894 8899

    84-86 Morrison Hill Road, Tsung Tsin Mansion
    Wanchai, HK
    2572 0898

    Shop 5, G/F, Pearl Court
    2-12 Holland Street, HK
    2872 6168

    2/F Peninsula Centre, 67 Mody Road
    TST East, Kowloon,HK
    2721 8102

    4/F Chong Hing Square
    601 Nathan Road, Kowloon, HK
    2780 0182

    3 Tak Hing Street
    Tsim Sha Tsui, Kowloon, HK
    2723 2646

  • There’s a Hoi Tin restaurant on:Elizabeth Bld, Causeway Bay
    Tel: 2891 3886.
  • There are Little Sheep hotpot restaurants as follows:Wanchai Hot Pot
    Causeway Bay Plaza, Wan Chai
    Tel: 2893 8318

    Mongkok Hot Pot
    16 Kar Lo street, ground floor/1st floor
    Tel: 2396 8816

    Tsim Sha Tsui Hot Pot
    26 Kimberley Rd, Tsim Sha Tsui
    Tel: 2722 7633

    Tsuen Wan Hot Pot
    City Landmark, Tsuen Wan
    Tel: 2940 7678

  • Now, for the marvelously-named ’Bridge under spicy crab’ restaurant:Shop C, G/F., Wah Fat Mansion, 405-419 Lockhart Road,
    Wan Chai, Hong Kong


    Shop 6-9, G/F., 429 Lockhart Road, Wan Chai, Hong Kong
    Tel: 2893 1289 or 2573 7698

  • And finally, a Xiao Nan Guo outlet:12th floor, Shell Tower, Causeway Bay (i.e. near Times Square)
    Tel: 2894 8899

You are visitor number several since September 1, 2001

Copyright Xiaoquan (Michael) Zhang, 2004-2020. All rights reserved.
All trademarks property of their owners.