
Homework Assignment 6: Nice Demo City, But
Will It Scale?
36-402, Advanced Data Analysis, Spring 2011
SOLUTIONS
1. Answer: Taking the log of both sides gives
log y= log Y
N= log Y−log N
≈log(cN b)−log N
= log c+ log Nb−log N
= log c+blog N−log N
=β0+β1log N
where we have taken β0= log cand β1=b−1.
2. Answer:
#### Problem 2
# Get the data:
gmp.data = read.csv(file =
"http://www.stat.cmu.edu/~cshalizi/402/hw/06/gmp_2006.csv")
pcgmp.data = read.csv(file =
"http://www.stat.cmu.edu/~cshalizi/402/hw/06/pcgmp_2006.csv")
# Using summary(gmp.data) helps to show that X2006 is the column of interest
# Check that both data sets are ordered the same way:
sum(gmp.data$Metropolitan != pcgmp.data$Metropolitan)
# The N, in millions: Divide gdp by gdp-per-capita
N = gmp.data$X2006/pcgmp.data$X2006
# The N, corrected (since gdp is in millions)
N = N*1000000
# Observe that the result matches what Cosma says it should:
summary(N)
# Compute variance of log y
y = pcgmp.data$X2006 # same as Y/N
1