**Power regression** is a type of non-linear regression that takes on the following form:

**y = ax ^{b}**

where:

**y:**The response variable**x:**The predictor variable**a, b:**The regression coefficients that describe the relationship between*x*and*y*

This type of regression is used to model situations where the response variable is equal to the predictor variable raised to a power.

The following step-by-step example shows how to perform power regression for a given dataset in R.

**Step 1: Create the Data**

First, let’s create some fake data for two variables: x and y.

#create data x=1:20 y=c(1, 8, 5, 7, 6, 20, 15, 19, 23, 37, 33, 38, 49, 50, 56, 52, 70, 89, 97, 115)

**Step 2: Visualize the Data**

Next, let’s create a scatterplot to visualize the relationship between x and y:

#create scatterplot plot(x, y)

From the plot we can see that there exists a clear power relationship between the two variables. Thus, it seems like a good idea to fit a power regression equation to the data instead of a linear regression model.

**Step 3: Fit the Power Regression Model**

Next, we’ll use the **lm()** function to fit a regression model to the data, specifying that R should use the log of the response variable and the log of the predictor variable when fitting the model:

#fit the model model <- lm(log(y)~ log(x)) #view the output of the model summary(model) Call: lm(formula = log(y) ~ log(x)) Residuals: Min 1Q Median 3Q Max -0.67014 -0.17190 -0.05341 0.16343 0.93186 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.15333 0.20332 0.754 0.461 log(x) 1.43439 0.08996 15.945 4.62e-12 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.3187 on 18 degrees of freedom Multiple R-squared: 0.9339, Adjusted R-squared: 0.9302 F-statistic: 254.2 on 1 and 18 DF, p-value: 4.619e-12

The overall F-value of the model is 252.1 and the corresponding p-value is extremely small (4.619e-12), which indicates that the model as a whole is useful.

Using the coefficients from the output table, we can see that the fitted power regression equation is:

**ln(y) = 0.15333 + 1.43439ln(x)**

Applying *e* to both sides, we can rewrite the equation as:

**y = e**^{ 0.15333 + 1.43439ln(x)}**y = 1.1657x**^{1.43439}

We can use this equation to predict the response variable, *y*, based on the value of the predictor variable, *x*.

For example, if *x* = 12, then we would predict that *y* would be **41.167**:

y = 1.1657(12)^{1.43439} = 41.167

**Bonus:** Feel free to use this online Power Regression Calculator to automatically compute the power regression equation for a given predictor and response variable.

**Additional Resources**

How to Perform Multiple Linear Regression in R

How to Perform Exponential Regression in R

How to Perform Logarithmic Regression in R

Hi,

I have a question.

I need to perfom a power regression in R and I used the method you propesed.

I was wondering if the p-value and R2 of my power regression are the same that I find when i perform the linear model ln(y) = ln(x).

If not so, is there a way to find the R2 and p-value of my power regression?

Thank you!

Hello! I have a question.

I was wondering if the p-value and R2 I obtain performing the linear model ln(y)=ln(x) are the same I should use to describe my power model.

OLS Linear regression of log-transformed variables introduces positive bias in the mean response (y-value of regression line). This must be corrected with a bias correction factor if using this method. See this post and Miller 1984, “Reducing Transformation Bias in Curve Fitting” in The American Statistician. https://stats.stackexchange.com/questions/359088/correcting-log-transformation-bias-in-a-linear-model

I appreciate the nice work you are doing, sir. Please, if given the predictor and the response variables as:

x = [1, 2, 3, 4, 7, 8, 9, 2]

y = [4, 7, 9, 5, 6, 1, 3, 2]

how do you fit a power law of the form y = a*x**b (i.e., y = ax^b) to the variables using Python?

I appreciate the nice work you are doing, sir. Please, if given the predictor and the response variables as:

x = [1, 2, 3, 4, 7, 8, 9, 2] and

y = [4, 7, 9, 5, 6, 1, 3, 2]

how do you fit a power law of the form y = a*x**b (i.e., y = ax^b) to the variables using Python?