# Uncertainty on independent variable of a non linear model

I have a question about how to estimate the uncertainty of a value calculated from a non linear model. My non-linear model is the following:

$$y=A+\frac{B}{1+e^{k(x-x_0)}+e^{c(x-x_1)}}$$

where $A, B, k, c, x_0, x_1$ are fitting parameters that I find using a Levenberg–Marquardt algorithm (non linear least square fitting). What I do after is to calculate $x$ at a particular $y$, but I don't know how to estimate the uncertainty on the found $x$. What I have done so far is to calculate the standard deviation of the fitting parameters using the covariance matrix and the root mean square error (RMSE) and I tried to propagate the error, but the problem is that I cannot get an analytical solution for $x$.

How can I proceed to estimate the uncertainty on $x$ ? Thanks

• Doesn't your function calculate y as a function of x? Where is the error term in your model? – gung - Reinstate Monica Dec 12 '16 at 13:29
• Yes my function calculates y. I called them y and x but they are actually viscosity for y and time for x. I have viscosity data changing over time and I fit this data to the above function. Then I use this function to back calculate a particular time. Briefly, I calculate the time when the viscosity has increased of 20%. Now I would like to express this time +- an uncertainty. – Francesco Dec 12 '16 at 13:41
• The calculation of x at a particular y is done by a numerical method, because I couldn't get an analytical expression for x. – Francesco Dec 12 '16 at 13:58

Use Monte Carlo uncertainty propagation (GUM-Supplement 1):

1/ evaluate the covariance matrix of your parameters (not only the uncertainties; they are probably strongly correlated and this has a HUGE impact on the final uncertainty)

2/ draw random samples from a normal multivariate distribution using the best value of your parameters and their covariance matrix

3/ calculate x for each point of the sample

4/ estimate the mean and standard deviation of x

• Thank you very much, I will try to understand how to implement Monte Carlo method. – Francesco Dec 12 '16 at 14:58
• You just need a random generator for normal multivariate distributions (for instance mvtnorm::rmvnorm() in R). – Pascal Dec 13 '16 at 8:56

You can use bootstrap to estimate the distribution of the any x. Below is my effort to point out the things to do:

1. Make a bootstrap sample. That is, take n samples from the original data with replacement, where n is the size of original data. Estimate all the parameters you want.

2. Repeat step 1 for a number of times, say b times (The value of b may be 1000, 10000, 100000 etc). That is you make b bootstrap sample and for all the samples you estimate all the parameters. Save values of all the parameters for all b runs.

3. Now you have b values of x. These values form a distribution of x. You can compute the mean and variance and translate into confidence interval, if you assume certain theoretical distribution for the parameter. The alternate way would be using empirical percentiles to construct the confidence interval. That is use 2.5th and 97.5th percentile of the distribution of x as a confidence interval of x.

If the variance co-variance matrix is necessary, then that also can be constructed from the the data you have.