4
$\begingroup$

I've fitted some weighted data to a nonlinear model (namely a Sèrsic light profile), using least squares.

That is, I have fitted a weighted nonlinear least squares model of the form:

$$I_r = I_0 \exp\left[-\left(\frac{r}{\alpha}\right)^{1/n}\right]+\epsilon_r$$

where $I_0$, $α$ and $n$ are parameters.

How do I then find confidence limits for each parameter, i.e. the 1,2,3 sigmas?

$\endgroup$
3
  • $\begingroup$ Should follow from the delta method, and also probably be part of the output of whatever statistical package you are using. Can we see some code? $\endgroup$ Commented Dec 17, 2013 at 16:59
  • $\begingroup$ I use python with scipy and lmfit. lmfit's confidence finding algorithms are currently flawed and I don't know how to fix it (that's another story) $\endgroup$ Commented Dec 17, 2013 at 17:18
  • $\begingroup$ I have made some edits to your question to incorporate a description of the model being fitted. You should check it still says what you want. $\endgroup$
    – Glen_b
    Commented Dec 17, 2013 at 17:27

2 Answers 2

3
$\begingroup$

I don't have any sample data for your function, but here is an example with a single exponential.

> library(nls2)
> library(MASS)

> x
 [1]  3.04  3.17  3.32  7.02  8.02  8.26 10.04 14.02 15.02 16.07 17.02 21.02 22.02
[14] 23.02 24.02 28.02 29.02 30.02 34.02 35.02 36.02 41.02 42.02 43.02 44.02 46.02
[27] 50.02 51.02 56.02 57.02 58.02 62.02 63.02 64.02 65.02 80.02 91.02
> y
 [1] 478 484 462 507 496 498 446 409 438 409 374 355 345 336 338 320 315 297 306 278
[21] 264 230 253 240 238 196 193 184 196 199 198 172 153 165 157 132  99
> fit <- nls(y ~ a*exp(b*x), start=list(a=500,b=-0.02))
> summary(fit)

Formula: y ~ a * exp(b * x)

Parameters:
    Estimate Std. Error t value Pr(>|t|)    
a  5.364e+02  8.085e+00   66.34   <2e-16 ***
b -1.876e-02  5.729e-04  -32.74   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 19 on 35 degrees of freedom

Number of iterations to convergence: 3 
Achieved convergence tolerance: 1.698e-07

> confint(fit)
Waiting for profiling to be done...
          2.5%        97.5%
a 520.08993543 552.89982422
b  -0.01993429  -0.01760968
$\endgroup$
3
  • $\begingroup$ Ok, but what language is this? I'm in python! I'd like to know how it's done as well! $\endgroup$ Commented Dec 19, 2013 at 19:30
  • $\begingroup$ Sorry, it is in R. You did not specify that the answer had to be in python and I can't help you with a python version. Non-linear regression is a complicated subject. There are a number of fine books available on the topic if you want more technical details. $\endgroup$
    – Thomas
    Commented Dec 19, 2013 at 19:50
  • $\begingroup$ I just wanted to know how its done so I could apply it in my current situation! $\endgroup$ Commented Dec 20, 2013 at 12:25
3
$\begingroup$

You can always fallback on bootstrapped confidence intervals.

Bootstrap resampling:

  1. Let $X$ denote your training dataset. Let $n$ denote the number of samples in your training data. Let $k$ denote the number of resampling iterations you want to perform. The more the better, but $k$ should probably be no fewer than $1000$.

  2. for $i=1,2,\dots k$, take a random sample $\tilde{X}_i$ (with replacement) of size $n$ from $X$. Train your model and calculate your model paramters. Let $\tilde{\theta}_i$ denote your fitted parameters trained on the $i^{th}$ resampled data set.

  3. You can now calculate confidence intervals by determining the quantiles of $\tilde{\theta} = [\tilde{\theta}_1, \tilde{\theta}_2,\dots \tilde{\theta}_k]$. For example, to obtain a $95\%$ confidence interval, calculate the $2.5\%$ and $97.5\%$ quantiles of $\tilde{\theta}$.

For more on bootstrapping, reference chapters seven and eight of The Elements of Statistical Learning (available for free download).

$\endgroup$

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.