R: Using equation with natural logarithm in nls
In addition I will point out that your model
y ~ a + b*(x/305) + c*((x/305)^2) + d*log(305/x) + f*(log(305/x))^2
is linear in the statistical sense of being linear in the coefficients; it doesn't need to be linear in x.
You don't need nls to fit this model, you could use lm().
But remember to look at the I() function to express terms like (x/305)^2.
ETA example:
aDF <- data.frame(x=abs(rnorm(100)), y=rnorm(100))
lm(y ~ 1 + I(x/305) + I((x/305)^2) + log(305/x) + I(log(305/x)^2), data=aDF)
In R, log
is the natural logarithm. In calculators, log usually means base 10 logarithm. To achieve that in R you can use the log10
function.
log(5)
## [1] 1.609438
log10
## [1] 0.69897(5)
As for your formula, it seems correct, since log
is the natural logarithm.