# How to pass equation formula to R function? [closed]

I need to interpolate simple linear equation to the set of points. Equation has the following form:

$$log10(y)=A+B/(C-X)$$ where A,B,C - coefficients of equation.

So far I was able to interpolate only the following:

$$log10(y)=A+B/(1-X)$$ which in R code looks like

log10(y) ~ I(1/(1 - X^-1))

But I am interested in obtaining coefficient C explicitly. Is there a way of doing this using R formula? Thanks in advance?

• It's not a linear model though. Look for non-linear models. – Firebug May 24 '17 at 13:51

If I understand your question right, you do not seek for a linear model but for a non-linear one. One of the main assumptions of the linear model function lm() is a model that is linear in its parameters, this does surely not hold in your case with a model of the kind:
$$Y=\beta_0+ \frac{\beta_1}{\beta_2-X}+u$$ I would suggest to use the package nls (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/nls.html) that allows for models such as yours. Applying something like: model<-nls(y~beta_0+beta_1/(beta_2-x),start=list(beta_0=1,beta_1=1,beta_2=1)) with startcoding some starting values. I have not tested it but this should work that way.
By the way, I would advise you to include some additional coefficent on $X$ in order to gain more flexibilty in the model as it is probable that $\beta_1$ and $\beta_2$ are hard to identify.