How to calculate Power Regression in R (Step-by-Step Guide)

[This article was first published on Data Analysis in R » Quick Guide for Statistics & R » finnstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The post How to calculate Power Regression in R (Step-by-Step Guide) appeared first on finnstats.

If you want to read the original article, click here How to calculate Power Regression in R (Step-by-Step Guide).

Power Regression in R, Power regression is a non-linear regression technique that looks like this:

y = ax^b

where:

y: The response variable

x: The predictor variable

a, b: The coefficients of regression used to describe the relationship between x and y.

When the response variable is equal to the predictor variable raised to a power, this sort of regression is utilized to represent the scenario.

Power Regression in R

In R, the following example explains how to run power regression for a given dataset step by step.

Step 1: Collect data

Let’s start by making some fictitious data for two variables: x and y.

x<-1:10
y<-c(10, 28, 15, 17, 65, 120, 115, 119, 123,100)

Step 2: Create a visual representation of the data

Then, to visualise the relationship between x and y, let’s make a scatterplot:

plot(x, y)

We can observe from the graph that the two variables have a strong power relationship. As a result, fitting a power regression equation to the data rather than a linear regression model appears to be a decent option.

Step 3: Fit the Power Regression Model

Next, we’ll use the lm() function to fit a regression model to the data, indicating that R should fit the model using the logs of the response and predictor variables:

model <- lm(log(y)~ log(x))

Now we view the output of the model

summary(model)
Call:
lm(formula = log(y) ~ log(x))
Residuals:
    Min      1Q  Median      3Q     Max
-0.9251 -0.1743  0.1661  0.2879  0.5404
Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)   2.0869     0.3858   5.410 0.000639 ***
log(x)        1.2056     0.2320   5.197 0.000826 ***
--
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5102 on 8 degrees of freedom
Multiple R-squared:  0.7715,       Adjusted R-squared:  0.7429
F-statistic:    27 on 1 and 8 DF,  p-value: 0.0008258

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

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

ln(y) = 2.0869 + 1.2056*log(x)

Based on the value of the predictor variable, x, we can use this equation to predict the responder variable, y.

For example, if x = 5, then we would predict that y value.

ln(y) = 2.0869+1.2056log(5) = 9.669329

Subscribe to our newsletter!

To read more visit How to calculate Power Regression in R (Step-by-Step Guide).

If you are interested to learn more about data science, you can find more articles here finnstats.

The post How to calculate Power Regression in R (Step-by-Step Guide) appeared first on finnstats.

To leave a comment for the author, please follow the link and comment on their blog: Data Analysis in R » Quick Guide for Statistics & R » finnstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)