Calculate t-statistic of coefficient matrix

11 Ansichten (letzte 30 Tage)
Daniel van den Berg
Daniel van den Berg am 23 Nov. 2022
Beantwortet: Akshat am 29 Aug. 2023
Using LSQLIN, I have obtained a coefficient matrix between my variables. Now, I would like to perform statistical analysis on the regression to see if it makes sense. I used to do this using the variance-covariance matrix obtained as output from mvregress. However, I have to use lsqlin now, which does not have this output.
My question is: How can I obtain the variance-covariance matrix from my coefficient matrix so that I can do statistical analysis on my regression? Otherwise, How can I obtain the standard errors from my coefficients? From here, I can do the same calculations.
I am really not at home in statistics, so I am a bit out of my depth here...
Thank you very much in advance!

Antworten (1)

Akshat
Akshat am 29 Aug. 2023
Hi Daniel,
I understand that you have hit a block to generate the variance-covariance matrix as there is no support for lsqlin to generate the same.
I am assuming that you have a coefficient matrix (b), a dependent variable (Y) and the independent variable matrix (X).
To generate the variance covariance matrix from these given things, you must have the Residual Sum Squares, for which the residual matrix is necessary. Hence, the following steps are to be followed:
  • Calculate the residual error matrix. You can simply do this by doing the simple matrix arithmetic, actual – predicted. That is:
residual = Y - X*b;
  • Now, you have to calculate the Residual sum squares, which is basically sum of element wise square of the elements in the residual error vector. Syntax for the same:
RSS = sum(residual.^2);
  • Finally, you have to calculate the variance-covariance matrix from this. Which is
covMatrix = RSS / df * inv(X' * X);
  • Here, we have "RSS" and "X". " X’ " is transpose of "X". "df" here, is the degrees of freedom. Degrees of freedom is the number of observations minus the number of predictors (variables). Syntax for the same:
df = size(X, 1) - size(X, 2);
"covMatrix" is the variance-covariance matrix desired.
This approach should help as per my understanding of the question, but there is a chance it might not work as I have not reproduced this approach at my end!
Misc. Resources regarding variance-covariance matrix: https://stattrek.com/matrix-algebra/covariance-matrix

Community Treasure Hunt

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

Start Hunting!

Translated by