Obtaining the variance-covariance matrix

i wanted to ask if by doing the result will be equal to E as in the equation shown

 Accepted Answer

That appears to me to be the covariance matrix of the parameters of the linear regression, so in a word, No. The cov function will not do what you want in that situation.
If you have the Statistics and Machine Learning Toolbox, use the LinearModel (specifically: fitlm) to return the CoefficientCovariance matrix for you. It will also do all the necessary calculations to estimate the confidence intervals on the parameters, so there is no need for you to code them separately.

6 Comments

I just went through the documentation of the fitlm function but i dont see where the confidence intervals and the covariance matrix will be given. Im sorry but can you please ellobaroate on this method if you dont mind.
Everything needed to do linear regressions is there, however not all in one place. See LinearModel (that I already linked to) for the covariance matrix, and Interpret Linear Regression Results for the parameter confidence intervals. Also see predict to calculate the ocnfidence intervals on the regression line. (Note that there are several predict functions for different procedures, so be sure to choose the correct one for your current problem. Those are usually linked to in the relevant documentation pages. The one I linked to here is the correct one for linear regression tasks)
Example —
x = 1:20; % Create Data
y = 3*x + randn(size(x))*10 + 5; % Create Data
mdl = fitlm(x,y)
CoefCov = mdl.CoefficientCovariance
CoefCI = mdl.coefCI
The documentation is not confusing, however it is necessary to follow the appropriate links to do everything you want to do. There is simply too much information to put it all in one documentation page.
Thank youuu this is live saving, I was literally get everything manually And this just saved me hours of work
As always, my pleasure!
i might be asking for much here, but do you know a way to find the Bonferroni confidence interval for the Regression Coefficients. If not thanks anyways!
Away for a while. My apologies for the delay.
The only thing I was able to find is Bonferroni Confidence Intervals. I hadn’t heard of them previously. It seems that this would be straightforward to program. I’m not aware of any existing MATLAB function to do so.

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!