A model of the form $y=a\cdot x^b$ can be linearly fitted by taking logs on both sides - giving $\ln(y)=\ln(a)+b\cdot\ln(x)$, where $\ln(y)$ is regressed against $\ln(x)$. This is a standard textbook approach.

What if there was an additive linear term included - e.g. $y=a\cdot x_1^b + c\cdot x_2$, how would you fit this for $a$, $b$, and $c$? Taking logs doesn't seem to do the trick, what other alternative methods are there?

  • $\begingroup$ "A model of the form $y=a⋅x^b$ can be linearly fitted by taking logs on both sides" ... such an argument only works when $y$ is strictly positive, and the transformation of the model without regard for what happens to the error term generally only works when the errors are very small. $\endgroup$
    – Glen_b
    Commented Mar 28, 2023 at 23:34

1 Answer 1


This is a job for something like nonlinear least squares, e.g., nls in R. Here is a snippet.

nl.eq <- function(x1, x2, a, b, d) {

n <- 10000
x1 <- runif(n)
x2 <- rnorm(n)
a <- 2
b <- 3
d <- 4
y <- a*x1^b + d*x2 + rnorm(n)

nlsreg <- nls(y ~ nl.eq(x1, x2, a, b, d), start = list(a = 1, b = 1, d = 1))
  • $\begingroup$ You mean a real-world example (my code already has a numerical example)? Many variables exhibit polynomial relationships, see e.g. wage returns to experience which may not increase linearly but flatten off for experienced employees. $\endgroup$ Commented May 22, 2023 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.