[R-sig-Geo] FW: Factor Analysis using R and grass

Agustin Lobo alobolistas at gmail.com
Thu Mar 26 10:55:55 CET 2009


Note that there has recently been a lot of
traffic on this issue, visit
http://grass.osgeo.org/wiki/Principal_Component_Analysis

i.pca has given trouble since many years ago, the consensus
was rather using m.eigensystem and r.mapcalc instead.

It seems that the fact is the i.pca is equivalent
to prcomp(X,center=F) in R. Non-centered PCA is not
a common use of PCA (IMHO, pretty useless in our context),
and actually has no equivalent in princomp()

Anyway, note that if you do a random selection of, say,
5% of your pixels, save values to a table and import
to R, you can calculate the eigenvectors and then use
them in r.mapcalc to calculate the PCs. This gives you much
more control of the statistical part. You can also calculate
the covar matrix in grass, pass it to R and carry out your analysis
there. In that way you will not have to sample, but I encourage you
to test the sampling procedure.

Finally note that factor analysis and PCA are not identical.

Agus

Dylan Beaudette wrote:
> Hi,
>
> Alternatively, if you must use all of the pixels in a massive grid, you can do 
> PCA in GRASS with the i.pca command. Note that you must take care of 
> standardization if you are using variables with different units / scales.
>
> Cheers,
>
> Dylan
>
>
> On Wednesday 25 March 2009, Tomislav Hengl wrote:
>   
>> Hi Brian,
>>
>> The PCA you can also run without GRASS e.g.:
>>     
>>> gridmaps <- readGDAL("NED1.asc")
>>> names(gridmaps)[1] <- "DEM"
>>> proj4string(gridmaps) <- CRS("+init=epsg:32618")
>>> gridmaps$twi <- readGDAL("twi.asc")$band1
>>> gridmaps$achan <- readGDAL("achan.asc")$band1
>>> gridmaps$insolat <- readGDAL("insolat.asc")$band1
>>> pc.dem <- prcomp(~DEM+twi+achan+insolat, scale=TRUE, gridmaps at data)
>>> biplot(pc.dem, arrow.len=0.1, xlabs=rep(".", length(pc.dem$x[,1])),
>>> main="PCA biplot")
>>>       
>> If you have missing pixels or if you use a max, then you will need to
>> select the generated components before you can reproduce the maps.
>>
>> See also:
>> http://spatial-analyst.net/wiki/index.php?title=Analysis_of_DEMs_in_R%2BILW
>> IS/SAGA
>>
>> HTH
>>
>> Tom Hengl
>> http://spatial-analyst.net
>>
>>
>>
>> -----Original Message-----
>> From: r-sig-geo-bounces at stat.math.ethz.ch
>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Brian Cooper
>> Sent: Wednesday, March 25, 2009 2:27 PM
>> To: r-sig-geo at stat.math.ethz.ch
>> Subject: [R-sig-Geo] Factor Analysis using R and grass
>>
>> I am new to both R and Grass. I need to duplicate the Principal Component
>> Analysis approach used in SPSS with GRASS and R. Is this possible?
>>
>> brian Cooper
>>
>> 	[[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>     
>
>
>
>



More information about the R-sig-Geo mailing list