1
$\begingroup$

I have this following relation

$$N = \dfrac{(113834700(3000-c)(1-e^{-(Xn)/(3000-c)})}{n}$$

I also have a set of values for $N$ and $X$, these are vectors. So, we have a scatter plot $N$ vs $X$.

We have to fit the data ($N$ and $X$) with the above relation and thereby have to find $c$ and $n$, which are scalars. How do I do this?

$\endgroup$
10
  • $\begingroup$ At first you need to understand which type of distance will satisfy you. Is Euclidean distance OK? $\endgroup$ Commented Apr 24, 2016 at 14:58
  • $\begingroup$ I wanted to give one answer, but there are so many pitfalls about it so I would better recommend you to take a look at this page en.wikipedia.org/wiki/Mathematical_optimization and choose method appropriate for your data. $\endgroup$ Commented Apr 24, 2016 at 15:01
  • $\begingroup$ Non Linear Regression might do the trick here. If you use R, try the nls function. $\endgroup$ Commented Apr 24, 2016 at 15:32
  • $\begingroup$ @Greenparker I tried but kept getting some error messages in R. Could you please help me out with the R syntax for solving this? $\endgroup$ Commented Apr 24, 2016 at 15:34
  • 1
    $\begingroup$ I suspect that noticing that there is really only one parameter, (3000-c)/n, is part of the assignment. $\endgroup$
    – JimB
    Commented Apr 24, 2016 at 17:25

1 Answer 1

1
$\begingroup$

As @JimBaldwin noted in a comment, there really is only 1 free parameter to fit in your equation, $(3000-c)/n$. If your code for nls or another nonlinear curve fitting routine included both $c$ and $n$ as separate parameters, then it would not be surprising for the routine to run with errors: there is an infinite set of $c$ and $n$ paired values that could "fit." So solve that problem by defining another variable, call is $a$:

$$a=\frac{3000-c}{n}.$$

It also can be easier to avoid accidental errors by avoiding unusual or large constant terms. I'd simply divide all the $N$ values by the constant 113834700 to start, so that there's less chance for error in writing the formula to submit to the fitting routine. Let's say:

$$B= \frac{N}{113834700}.$$

Then you are fitting a simple relation:

$$B=a\left(1-e^{-\frac{X}{a}}\right),$$

which will minimize the chance of errors both in your coding and in the routine.

As with any nonlinear fitting, it's important to start with a good initial estimate for your unknown parameter $a$, and to be prepared to test carefully to make sure that you have found a global minimum for residual squared error rather than some local minimum. I have some examples of R code for nls on this page in a similar context, which illustrates some of the considerations.

Also, make sure that the value of 113834700 is truly a constant and not a fitted value from someone else's analysis of another data set, for which you should be estimating a new value from your data set. That type of problem arose in the question I linked in the previous paragraph. If you do only have 1 free parameter, you could use the optim function instead of nls in R.

$\endgroup$
1
  • $\begingroup$ I only see your answer after I have posted my answer at stats.stackexchange.com/questions/209068/… . Your final paragraph matches with what I concluded using the data posted in that other question. I concluded his model is lousy, and that hard-coded multiplicative constant "ain't cutting it". I introduced another parameter in its place and got a much better fit,. $\endgroup$ Commented Apr 24, 2016 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.