I'd like to perform an exponential regression with multiple independent variables (similar to the LOGEST function in Excel)
I'm trying to model the function $Y = b {m_1}^{x_1}{m_2}^{x_2}$ where $b$ is a constant, $x_1$ and $x_2$ are my independent variables, and $m_1$ and $m_2$ are the coefficients of the independent variables.
I think I can linearize the function by doing something like glm(log(Y) ~ x1 + x2)
but I don't totally understand why that would work. Also, I'd like to run a true non-linear regression if there is such a thing.
My goal is to run both a linear and an exponential regression, and find the best fit line based on the higher $R^2$ value.
I would also really appreciate your help in understanding how to plot the predicted curve in a scatter plot of my data as well.
lm(log(Y) ~ x1 + x2)
versus the original exponential model is down to how you think the error behaves. If, in your data, you see that the noise increases asx1
andx2
increase, then you have good reason to use the log model, but if you see that it's constant, then the latter is more appropriate - my argument depends upon the lm function assuming constant variance of noise - i would have a look at stats.stackexchange.com/questions/47063/… $\endgroup$glm
formulation will work; it will perform well; and it will make other facilities available including hypothesis testing, prediction, and confidence intervals. Useglm(y ~ x1 + x2, gaussian(link="log")
. If the software complains about being unable to finding a starting value for iteration, often just throwing a linear trend at it works, as inglm(y ~ x1 + x2, gaussian(link="log"), mustart=1:length(y))
. $\endgroup$