An example of how to interpret a power law or log-log regression. See Chapter 3 in Regression and Other Stories.

Animals’ body mass and metabolism comes from section 3.8.2 of Gelman and Nolan: Teaching Statistics: A Bag of Tricks, second edition. Oxford University Press, 2017.


Load packages

library("rprojroot")
root<-has_file(".ROS-Examples-root")$make_fix_file()
par (mar=c(3,3,1,1), mgp=c(1.8,.5,0), tck=-.01)
plot (c(log(.01), log(3000)), c(log(.06),log(1700)), xaxt="n", yaxt="n",
  xlab="log (body mass in kilograms)",
  ylab="log (metabolic rate in watts)",
  bty="l", type="n")
axis(1, seq(-4,8,2))
axis(2, seq(-2,6,2))
grid(col="gray")
abline(1.2, 0.74)
points(log(0.02), log(0.17), pch=20)
text(log(.02) + 0.2, log(0.17),"Mouse", cex=.9, adj=0)
points(log(70), log(80), pch=20)
text(log(70) - 0.2,log(80),"Man", cex=.9, adj=1)
points(log(3700), log(2100),pch=20)
text(log(3700) - 0.2, log(2100),"Elephant", cex=.9, adj=1)
text(log(2), log(3.5), "log y = 1.2 + 0.74 log x", cex=.9, adj=0)

par (mar=c(3,3,1,1), mgp=c(1.8,.5,0), tck=-.01)
plot (c(0, 3700), c(0, 2100), 
  xlab="body mass in kilograms",
  ylab="metabolic rate in watts",
  bty="l", type="n")
curve(exp(1.2 + 0.74*log(x)), add=TRUE)
points(0.02, 0.17, pch=20)
text(0.02 + 50, 0.17, "Mouse", cex=.9, adj=0)
points(70, 80, pch=20)
text(70 + 70, 90 + 100, "Man", cex=.9, adj=1)
points(3700, 2100, pch=20)
text(3700 - 50, 2100, "Elephant", cex=.9, adj=1)
text(1450, 700, expression(y ~ "=" ~  e^{1.2 ~ + ~ 0.74 ~ l*o*g ~ x} ~ "=" ~ 3.3 ~ x ^ 0.74), adj=0)

LS0tCnRpdGxlOiAiUmVncmVzc2lvbiBhbmQgT3RoZXIgU3RvcmllczogTWV0YWJvbGljIgphdXRob3I6ICJBbmRyZXcgR2VsbWFuLCBKZW5uaWZlciBIaWxsLCBBa2kgVmVodGFyaSIKZGF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