What follows is simple computation, solely to show us exactly what happens. It continues the work of the previous post, which did my default calculations for standardized data. Here I do the same calculations for centered and raw data.
The raw data is still
I will center the data and call it Xc. Get the column means…
and subtract them from each column to get Xc:
Proceeding as before, we get the SVD and display w…
Get the eigenvalues of the covariance matrix (and that’s the only change we make after switching to centered data):
I’m getting fond of just doing pie charts:
Get the diagonal matrix of square roots of those eigenvalues of the covariance matrix…
Get the weighted eigenvector matrix A
Get the scores as the first three columns of 2u (where 2 = , N=5).
Confirm that we have . (Yes.)
We compute the new data (Y = Xv = uw)
And we confirm the product – which amounts to confirming the SVD. Not a bad thing to do considering how many u’s and w’s I have floating around in my Mathematica® notebook.
Then, on second thought, I’m going to forget about computing Davis’ loadings and scores.
So we should display the two forms of loadings A, v together:
We should display the corresponding scores F^T, Y:
And we could confirm that the new data Y have mean 0 (yes) and redistributed variances equal to the eigenvalues:
(yes, the same as the eigenvalues .)
And we could confirm that F^T is standardized: the means and variances of the columns are 0 and 1 respectively. in fact F^T is uncorrelated: its covariance matrix is the identity.
What about reconstituted data? I would look at w in preference to since it’s the w’s I will be setting to zero.
As before, setting to zero will have a very small effect on the data: the reconstituted matrix would differ from the original by a square root sum of squares of 1.55 . So I’m going to set all but the first w equal to zero, just to get reconstituted data that differs nontrivially from the original.
The reconstituted data is , i.e.
and the leftover is X1 = X – X0 is
I’ll show you again that the difference between X and X0 is the sum of squares of the w’s we omitted. the squares of the entries in Xc1 are
Their sum is 27.5582 and the square root is 5.24959 . And the squares of and are 25.1575 and 2.40069, with matching sum 27.5582 .
We could compute the reconstituted new data Y, but as before, it would just be the first column of Yc.
I use the raw data and call it Xr.
Get the SVD and display w…
Neither the correlation matrix nor covariance matrix is appropriate, so we look at the singular values. But we want to honor
I could compute the matrix from the w matrix. Given the sizes of the matrices, I might actually compute
and take the square root. But conceptually it is cleaner to compute the eigenvalues of , which is exactly the correlation and covariance matrices for standardized and centered data. (Let me put that another way: if I did not have built-in Mathematica® commands Covariance and Correlation, I would be computing in every case.) Note, however, that for the raw data it is not remotely a covariance matrix. I get
and here’s the pie chart of them:
and then I form the diagonal matrix of square roots:
Get the weighted eigenvector matrix
Get the scores FT as the first three columns of 2u (where 2 = , N=5).
Check by confirming that for Xr, Fr, Ar. (Yes.)
we compute the new data (Y = u w):
And we confirm the product – which amounts to confirming the SVD. Not a bad thing to do considering how many u’s and w’s I have floating around.
Now let’s look at the new data Y. Here are its means…
and its variances…
The sum of the variances is 1096.36, and that is, in fact, the sum of the variances of the raw data. we have redistributed the variance.
Recall the eigenvalues:
The first “but” is that the redistributed variances have nothing to do with the eigenvalues. Hey, Xc is not centered, so has nothing to do with the variance of the raw data.
The second “but” is that the redistributed variances of the centered data were
and the first one is larger than what I got for Yr. That’s actually good, since the first variance of Yc was supposed to be the largest I could get. The redistribution of variance of the raw data is not maximal. It’s not that far off, but it’s not maximal.
This has implications for regression analysis. That is, if I want to redistribute the variance of a bunch of variables for regression, to do it properly I have to center the data, which is not something I like doing under the circumstances. The uncentered data seems more appropriate.
The change to Y is far more significant than the change to F^T. In this case, it is still true that
but it is no longer appropriate to say that the F^T are uncorrelated. In fact, the means are nonzero
and the variances are not 1:
The matrix F^T is almost orthonormal, except that instead of
What about reconstituted data? I would look at w in preference to :
As before, setting to zero will have a very small effect on the data: the reconstituted matrix would differ from the original by a total sum of squares of 25 . so I’m going to set all but the first w equal to zero, just to get reconstituted data that differs nontrivially from the original.
Here’s the reconstituted data:
It is still true that the raw data X and the reconstituted data X0 differ by the square root of the sum of squares of the two omitted w’s.
Finally, if we were to compute the new components of the reconstituted data we would get the first column of the Yr matrix.