简体   繁体   English

在R中拟合简单的幂律函数

[英]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: 假设y是surfaceArea, x是体积,那么适合lm函数的是:

log10(y) = a*log10(x) + b, 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 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. 请注意,如果您想使用lm函数提供的系数误差,则需要正确传播误差。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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