简体   繁体   中英

Fitting a simple power law function in R

I want to use a power function on the classic surface area to volume relationship.

surfaceArea<-c(6,24,54)
volume<-c(1,8,27)

Logging the data works to get the parameter values of the linear function as follows

logSurfaceArea<-log10(surfaceArea)
logVolume<-log10(volume)

plot(logSurfaceArea~logVolume, pch =16)
allometryModel <-lm(logSurfaceArea~logVolume)
summary(allometryModel)

But how do I get the parameter values for the original power function?

One way to do it is to use mathematical way of thinking. Let's say y is surfaceArea and x is volume, then what you are fitting with the lm function is this:

log10(y) = a*log10(x) + b,

then

y = 10^(a * log10(x) + b) = 10^(a * log10(x)) * 10^b = (10^(log10(x)))^a * 10^b = x^a * 10^b

you can check it plotting these plots:

 plot(volume, volume^allometryModel$coeff[2]*10.0^allometryModel$coeff[1], col="red")
 plot(volume, surfaceArea)

Please note, that you need to propagate properly the errors if you would like to use the coefficient errors provided by the lm function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM