# NOT RUN {
data(LCL)
head(LCL)
x <- LCL[,1]; y <- LCL[,2]
## Zipf plots
out1 <- ZipfPlot(x)
out2 <- ZipfPlot(y)
plot(out1, type='l', ylim=c(0,9), lwd=2,
xlab="log(X)", ylab="log(Rank)")
lines(out2, lty=2,lwd=2,col=4)
## Normalize 'y' and use 'x' as baseline
out <- Zipf.Normalize(x,y) # OLS estimates
out3 <- ZipfPlot(out$y)
## Zipf plot of the normalized profile
lines(out3, lty=3,lwd=2, col=2)
## Show fitted least squares lines
out$coef
abline(a=out$coef[1,1],b=out$coef[1,2], lty=1)
abline(a=out$coef[2,1],b=out$coef[2,2], lty=2,col=4)
## search for optimal estimates
### not run --slow
#out4 <- Zipf.Normalize(x,y,optim=TRUE)
#persp(out4$mat.optim, theta=90, phi=30,
# xlab="Gamma", ylab="Sigma", zlab="Dmax")
#plot(out1, type='l', ylim=c(0,9), lwd=2,
# xlab="log(X)", ylab="log(Rank)")
#lines(out2, lty=2,lwd=2,col=4)
#out5 <- ZipfPlot(out4$y)
#lines(out5, lty=3,lwd=2, col=2)
## Linear scaling normalization
out6 <- Zipf.Normalize(x,y,method='scaling')
plot(out1, type='l', ylim=c(0,9), lwd=2,
xlab="log(X)", ylab="log(Rank)")
lines(out2, lty=2,lwd=2,col=4)
out7 <- ZipfPlot(out6$y)
lines(out7, lty=3,lwd=2, col=2)
### not run --slow
#out8 <- Zipf.Normalize(x,y,method='scaling',optim=TRUE)
#plot(out1, type='l', ylim=c(0,9), lwd=2,
# xlab="log(X)", ylab="log(Rank)")
#lines(out2, lty=2,lwd=2,col=4)
#out9 <- ZipfPlot(out8$y)
#lines(out9, lty=3,lwd=2, col=3)
# }
Run the code above in your browser using DataLab