# Formula For Logarithmic Regression

• May 26th 2011, 09:52 AM
Tanner8
Formula For Logarithmic Regression
Hello, I am aware the final formula is y=a+blnx, however I don't know the formulas to find a and b. I searched around everywhere and all I can find is how to do it on a calculator. Once this is found, how can I find the coefficient of determination as well? Thank you
• May 26th 2011, 10:10 AM
bryangoodrich
Do you know how to do a normal linear regression? Do you know how to find the coefficient of determination (i.e., $R^2$) for a normal linear regression? If so, then think of this logarithmic transformation on X as just a standard X variable. In other words, let $X^*=ln(X)$, and do the normal stuff for the linear regression:

$Y = a + bX^*$

The transformation doesn't change the methodology of a regression, only the interpretation of the results.
• May 27th 2011, 01:54 PM
Tanner8
Quote:

Originally Posted by bryangoodrich
Do you know how to do a normal linear regression? Do you know how to find the coefficient of determination (i.e., $R^2$) for a normal linear regression? If so, then think of this logarithmic transformation on X as just a standard X variable. In other words, let $X^*=ln(X)$, and do the normal stuff for the linear regression:

$Y = a + bX^*$

The transformation doesn't change the methodology of a regression, only the interpretation of the results.

Thank you. However I am still getting a wrong result. Here is the dataset,

Y=
Code:

`      1043      1148      1105      1218      1037      841      903      866      928      881      802      828      726`
X=
Code:

`      1      2      3      4      5      6      7      8      9      10      11      12      13`
For the linear regression I get -32.5x+1176 which is consistent with Excel. However when I get the log of all of the X values and perform the normal linear regression as you say I get 237.9ln(x)+637.6 when the correct answer according to Excel is -148ln(x)+1204.9. I am not sure what I am doing wrong. I should be using the natural log of x throughout all of the summation calculations that require x correct? Thank you
• May 27th 2011, 02:10 PM
bryangoodrich
You might want to check your calculations. I checked this in R and got the same results as Excel. See the code below. Results have been commented out.

Code:

```y <- c(1043, 1148, 1105, 1218, 1037, 841, 903, 866, 928, 881, 802, 828, 726) x <- 1:13 lnx <- log(x) (fit <- lm(y ~ x))          ## y = 1176 - 32.52*x #Call: #lm(formula = y ~ x) #Coefficients: #(Intercept)            x  #    1175.77      -32.52  (fit.log <- lm(y ~ lnx))    ## y = 1205 - 148*log(x) #Call: #lm(formula = y ~ lnx) #Coefficients: #(Intercept)          lnx  #      1205        -148```
• May 27th 2011, 03:20 PM
Tanner8
Got it, thanks. The problem was my data-typing in my program, it was rounding the logged values.