views:

85

answers:

2

I have data points that represent a logarithmic function.

Is there an approach where I can just estimate the function that describes this data using R?

Thanks.

A: 

If I understand right you want to estimate a function given some (x,y) values of it. If yes check the following links.

Read about this:

http://en.wikipedia.org/wiki/Spline_%28mathematics%29
http://en.wikipedia.org/wiki/Polynomial_interpolation
http://en.wikipedia.org/wiki/Newton_polynomial
http://en.wikipedia.org/wiki/Lagrange_polynomial

Googled it:

http://www.stat.wisc.edu/~xie/smooth_spline_tutorial.html
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/smooth.spline.html
http://www.image.ucar.edu/GSP/Software/Fields/Help/splint.html

I never used R so I am not sure if that works or not, but if you have Matlab i can explain you more.

George B.
A: 

I assume that you mean that you have vectors y and x and you try do fit a function y(x)=Alog(x).
First of all, fitting log is a bad idea, because it doesn't behave well. Luckily we have x(y)=exp(y/A), so we can fit an exponential function which is much more convenient. We can do it using nonlinear least squares:

 nls(x~exp(y/A),start=list(A=1.),algorithm="port")

where start is an initial guess for A. This approach is a numerical optimization, so it may fail.
The more stable way is to transform it to a linear function, log(x(y))=y/A and fit a straight line using lm:

lm(log(x)~y)
mbq