From: Christoph on
Hi,

does anyone know the best way to compute R squared and adjusted R squared values when running a regression with lscov?

Thanks a lot!!

Christoph
From: Greg Heath on
On Jul 21, 1:16 pm, Christoph <ennobehr...(a)web.de> wrote:
> Hi,
>
> does anyone know the best way to compute R squared and adjusted R squared values when running a regression with lscov?
>
> Thanks a lot!!
>


What candidates are you considering?

Hope this helps.

Greg
From: Peter Perkins on
On 7/21/2010 1:16 PM, Christoph wrote:
> does anyone know the best way to compute R squared and adjusted R squared values when running a regression with lscov?

Christoph, it's straight-forward to compute those from their
definitions. For example:

b = lscov(X,y);
sse = sum((y - X*b).^2);
sst = sum((y - mean(y)).^2);
rsq = 1 - sse/sst;

You could also simplify this a bit using the MSE output, and the VAR
function. If you have access to the Statistics Toolbox, both REGRESS
and REGSTATS compute r-squared. Hope this helps.
From: Christoph on
Thanks Peter!

Just out of interest, how would you compute the R^2 with the mse output and the var function?
From: Peter Perkins on
On 7/23/2010 11:11 AM, Christoph wrote:
> Just out of interest, how would you compute the R^2 with the mse output and the var function?

Well, MSE is SSE/(n-p), right? Similarly, VAR is SST/(n-1) (or n,
depending on how you compute it).

So, 1 - (mse*(n-p))/(var*(n-1)).