The power equation has the general form of y = bX^m. I found a good example to

calculate the power regression using Excel but I couldn't find a direct method to calculate the power regression in R. In this blog, I will try to explain the same technique using R.

X | Y |

0.021 | 505 |

0.062 | 182 |

0.202 | 55.3 |

0.523 | 22.2 |

1.008 | 11.3 |

3.320 | 4.17 |

7.290 | 1.75 |

The basic idea is to get the linear regression between log(X) and log(Y), then map the coefficient to the power log m and b.
The code in R could be as the following:

x=c(0.021,0.062,0.202,0.523,1.008,3.320,7.290)
y=c(505,182,55.3,22.2,11.3,4.17,1.75)
fit=lm(log10(x)~log10(y))
fit
Call:
lm(formula = log10(x) ~ log10(y))
Coefficients:
(Intercept) log10(y)
1.124 -1.037
plot(x,y,type="p",col="black")
lines(x, 10^ fit$coefficients[1] * x^fit$coefficients[2],type="l",col="red")

## No comments:

## Post a Comment