how to return the R-squared using lscov command

3 ビュー (過去 30 日間)
Janis
Janis 2013 年 1 月 12 日
How can I get the R-squared using the LSCOV command?
  1 件のコメント
Matt J
Matt J 2013 年 1 月 13 日
What is R?

サインインしてコメントする。

回答 (1 件)

Wayne King
Wayne King 2013 年 1 月 13 日
編集済み: Wayne King 2013 年 1 月 13 日
I'm not sure whether your A matrix can be interpreted as a design matrix for a linear model and B is your response vector (here I'm using the input designations in lscov), but if that is the case, then the classic R-squared would be.
X = lscov(A,B);
xhat = A*X;
resid = xhat-B;
SSE = norm(resid,2)^2;
TSE = norm((B-mean(B),2)^2;
R2 = 1-SSE/TSS;
Alternatively, you could use something like:
X = lscov(A,B);
xhat = A*X;
r2 = norm(xhat,2)^2/norm(B,2)^2;
The l2-norm of xhat is less than or equal to the l2 norm of the B vector. If A*X is a good fit for B, then the norm of xhat will be close to the l2 norm of B and the ratio will be close to 1.
If A*X is bad fit for B, then the ratio will be small.
  2 件のコメント
Matt J
Matt J 2013 年 1 月 13 日
編集済み: Matt J 2013 年 1 月 13 日
This would only work if LSCOV is called with no more than 2 input args, i.e., if it is unweighted least squares. With the syntax
x=lscov(A,B,V)
you would perhaps need
resid = xhat-B;
resid = dot(resid,V\resid);
Tom Lane
Tom Lane 2013 年 1 月 14 日
I would recommend computing both SSE and TSS using weights.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by