[GRASS-dev] Re: [GRASS GIS] #576: i.pca fails to center data prior
to analysis
GRASS GIS
trac at osgeo.org
Fri Nov 4 07:10:25 EDT 2011
#576: i.pca fails to center data prior to analysis
--------------------------------------------------------------+-------------
Reporter: nikos | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: i.pca, data centering, prcomp(), R, eigenvectors | Platform: Unspecified
Cpu: Unspecified |
--------------------------------------------------------------+-------------
Comment(by mmetz):
Replying to [ticket:576 nikos]:
> I have spotted one case where ''i.pca'' does not work as expected. I
have a set of 3 MODIS surface reflectance bands. Performing PCA on those
using ''i.pca'' '''does not center''' the data before the analysis, that
is, the mean of each dimension (band) is not subtracted from the dimension
itself to give a dataset that has zero mean which is an integral part of
the solution to PCA.
[...]
>
> * Using the same data with the ''prcomp(x, center=TRUE, scale=FALSE)''
function in R, which centers the dataset by default anyway if not told
otherwise, gives different results:
>
{{{
> PC1 PC2 PC3
> mod07_b2 0.4372107 0.83099407 -0.3439413
> mod07_b6 0.7210155 -0.09527873 0.6863371
> mod07_b7 0.5375718 -0.54806096 -0.6408165
}}}
I get identical results with i.pca in trunk r49090 if I create a MASK
first, thus excluding any NULL cells (some cells are NULL in one band but
not NULL in another band).
{{{
# making use of NULL propagation
r.mapcalc "MASK = mod_b2 + mod_b6 + mod_b7 + 1"
}}}
`i.pca` gives now
{{{
Eigen values, (vectors), and [percent importance]:
PC1 778244.03 ( 0.4372, 0.7210, 0.5376) [79.20%]
PC2 192494.58 ( 0.8310,-0.0953,-0.5481) [19.59%]
PC3 11876.45 ( 0.3439,-0.6863, 0.6408) [ 1.21%]
}}}
which is identical to the above output of ''prcomp(x, center=TRUE,
scale=FALSE)''
Markus M
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/576#comment:1>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list