Fitting a function in R
问题 I have a few datapoints (x and y) that seem to have a logarithmic relationship. > mydata x y 1 0 123 2 2 116 3 4 113 4 15 100 5 48 87 6 75 84 7 122 77 > qplot(x, y, data=mydata, geom="line") Now I would like to find an underlying function that fits the graph and allows me to infer other datapoints (i.e. 3 or 82 ). I read about lm and nls but I'm not getting anywhere really. At first, I created a function of which I thought it resembled the plot the most: f <- function(x, a, b) { a * exp(b *-x