function - How can I estimate the logarithmic form of data points using R? -
I have data points that represent logarithmic functions.
Is there a way where I can just guess the function which describes this data using R?
Thank you.
I think that you mean that you have vector y
and < Code> x and you try to organize the function y (x) = Alog (x)
. First of all, the fitting log is a bad idea, because it does not behave well. Fortunately, we have x (y) = exp (y / a)
, so we can fit an exponential function which is more convenient, we can use at least sections of this non-alignment :
nls (x ~ exp (y / a), start = list (a = 1.), algorithm = "port")
where The initial estimate for start
a a
. This approach is a numerical optimization, so it can fail.
In a more consistent way, it is a linear function, switching to log (x) and y / a
and a straight fit using the LM
:
LM (log (x) ~ y)
Comments
Post a Comment