Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I fit parameters of an arbitrary function of a single variable to data? [closed]

I’m working in R. I have a function (F) relating one variable (X) to another variable (Y). (F) has 3 mutable parameters (A, B, C), such that Y == F(X) == G(X, A, B, C). I would like to fit this function to a dataset which gives N (X, Y) pairs by finding the best (A, B, C).

The relationship between (X) and (Y) is neither polynomial and nor some kind of probability distribution. I'm curious if there's a way to do this for an arbitrary (F) as defined above.

like image 934
user1873348 Avatar asked Dec 08 '25 06:12

user1873348


1 Answers

Yes, ?nls . There are a number of nonlinear regression packages for R; nls is kinda the basic function. If you've never used formulas in R, you should do a little reading up on them in the help files. But, like in any other computer language, you'll need to provide some initial "guess" values for your coefficients A,B,C .

for example, nls(Y ~ I(A*sin(x) + B*exp(x/C)),data=x, start=list(A=1,B=.5,C=3))

like image 116
Carl Witthoft Avatar answered Dec 10 '25 19:12

Carl Witthoft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!