Discussion:
Covariance matrix
(too old to reply)
Suhrud
2008-10-07 16:43:03 UTC
Permalink
Hi All,

I am using lsqcurvefit to fit a function to some neural data. I have about 11 parameters in the model. I posted a question yesterday about calculating confidence intervals on the fitted parameters using nlparci but have not received a reply yet. In brief, when I calculated CI using nlparci, for some of my data the CI values for 2 out of 11 parameters are in hundreds of thousands (which can not right). I'd like to know if nlparci is the correct function to use if I used lsqcurvefit to get the jacobian and residual?

I do have another question regarding the same problem.
I am wondering if there is a way to calculate covariance matrix for the parameters from lsqcurvefit, so I can find out if there is a strong correlation between the parameters (with erroneous CIs) in the model. Does anyone have experience with this? How can find the covariance matrix?
I'd really really appreciate any help.

Thanks,
Suhrud.
Peter Perkins
2008-10-07 17:20:53 UTC
Permalink
Post by Suhrud
Hi All,
I am using lsqcurvefit to fit a function to some neural data. I have about 11 parameters in the model. I posted a question yesterday about calculating confidence intervals on the fitted parameters using nlparci but have not received a reply yet. In brief, when I calculated CI using nlparci, for some of my data the CI values for 2 out of 11 parameters are in hundreds of thousands (which can not right). I'd like to know if nlparci is the correct function to use if I used lsqcurvefit to get the jacobian and residual?
In theory, yes. In practice, you're (apparently) passing something that's not right, and you'lll probably want to step through the code with the debugger to see where things are going wrong, which should tell you what's wrong with your inputs.
Post by Suhrud
I do have another question regarding the same problem.
I am wondering if there is a way to calculate covariance matrix for the parameters from lsqcurvefit, so I can find out if there is a strong correlation between the parameters (with erroneous CIs) in the model. Does anyone have experience with this? How can find the covariance matrix?
If you have NLPARCI, you can look in the code, and you'll find that it computes the SEs based on the diagonal of (in effect) (J'J)^(-1). All you need to do is compute that entire inverse.

If you were to use NLINFIT, you could get the estimated cov matrix as an output, but there may be other reasons for using LSQCURVEFIT.
Suhrud
2008-10-07 19:01:02 UTC
Permalink
Post by Peter Perkins
Post by Suhrud
Hi All,
I am using lsqcurvefit to fit a function to some neural data. I have about 11 parameters in the model. I posted a question yesterday about calculating confidence intervals on the fitted parameters using nlparci but have not received a reply yet. In brief, when I calculated CI using nlparci, for some of my data the CI values for 2 out of 11 parameters are in hundreds of thousands (which can not right). I'd like to know if nlparci is the correct function to use if I used lsqcurvefit to get the jacobian and residual?
In theory, yes. In practice, you're (apparently) passing something that's not right, and you'lll probably want to step through the code with the debugger to see where things are going wrong, which should tell you what's wrong with your inputs.
Post by Suhrud
I do have another question regarding the same problem.
I am wondering if there is a way to calculate covariance matrix for the parameters from lsqcurvefit, so I can find out if there is a strong correlation between the parameters (with erroneous CIs) in the model. Does anyone have experience with this? How can find the covariance matrix?
If you have NLPARCI, you can look in the code, and you'll find that it computes the SEs based on the diagonal of (in effect) (J'J)^(-1). All you need to do is compute that entire inverse.
If you were to use NLINFIT, you could get the estimated cov matrix as an output, but there may be other reasons for using LSQCURVEFIT.
Thank you Peter. Just as I had suspected there is a correlation between the two parameters for which the CIs were large. The covariance matrix is >>0 only for those two parameters.
Continue reading on narkive:
Loading...