How to get the confidence intervals of regression coefficients in nlinfit?

18 ビュー (過去 30 日間)
xv cheng
xv cheng 2018 年 8 月 18 日
編集済み: Adam Danz 2018 年 8 月 18 日
I used nlinfit or lsqcurvefit to do non-linear fit.
[beta,R,J,CovB,MSE,ErrorModelInfo] = nlinfit(X,Y,@myfun,beta0)
How to get the confidence intervals of regression coefficients 'beta'?
I'm sorry it might be just a math problem, but I really want to implement it in matlab code.
Thank you very much!

採用された回答

Adam Danz
Adam Danz 2018 年 8 月 18 日
編集済み: Adam Danz 2018 年 8 月 18 日
I looked into this somewhat recently and found two main strategies for computing confidence intervals of the coefficients.
  1. using nlparci()
  2. computing them directly by calculating the covariance matrix
Both methods use the jacobian and residual outputs and for my data there are very tiny differences in the results between the two methods.
Here are some sources I stored within the footnotes of my code and I recommend browsing through them to determine the best method for your problem.
Approximation of covar matrix of the params
Both covar matrix and nlparci methods
How covar matrix is used to get CI
One method to approximate CIs using linear example, explains how to do with nonlinearly.
nlparci can be used with lsqnonlin outputs (my project uses lsqnonlin but the outputs are similar for your project)
If you go with the nlparci() method, it's as easy as pluggin in your outputs...
CI = nlparci(betaEstimates,residuals,'jacobian',jacobian);
If you go with the covar matrix method, here a snippet from my code that should be fairly self-explanatory.
df = length(residuals) - numel(betaEstimates); %degrees of freedom
alpha = 0.05; %for 95% conf int
crit = tinv(1-alpha/2,df); %critical value
covm = inv(jacobian'*jacobian) * var(residuals); %covariance matrix
covmIdx = sub2ind(size(covm),1:size(covm,1),1:size(covm,2)); %indices of the diag of covm
CI = nan(numel(betaEstimates),2);
I'm refraining for making a recommendation partially due to what @SK mentioned; there isn't a standard solution to getting CIs for the beta estimates, and also because I'm exploring these methods as a novice (and welcome feedback).

その他の回答 (1 件)

SK
SK 2018 年 8 月 18 日
編集済み: SK 2018 年 8 月 18 日
There is no fixed answer to this, unless myfun is known and is nice enough to be analysed theoretically. In general, I would do the following:
1. Look at the residuals, Y - myfun(X, beta0). (Here beta0 are your coefficient estimates).
2. Try to determine the distribution of the residuals.
3. Generate many realizations of Y using Y = myfun(X, beta0) + R, where R is generated randomly according to the distribution found in (2). To each realization, do an nlinfit and find the vector beta0_y.
4. Look at the distribution of beta0_y. It may be identifiable as a known distribution or not. Regardless, you can find confidence intervals from it.

カテゴリ

Help Center および File ExchangeNonlinear Regression についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by