From eea5fa0c30186d76b2939ef581a0e18c2f058100 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 29 Dec 2023 15:13:22 -0500 Subject: [PATCH 1/5] Update prcomp.Rd - Should say see princomp if you want to use all values - Change authors since this is not based on the princomp implementation from RStoolbox --- man/prcomp.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/prcomp.Rd b/man/prcomp.Rd index a921e94ec..319c87433 100644 --- a/man/prcomp.Rd +++ b/man/prcomp.Rd @@ -6,7 +6,7 @@ \title{SpatRaster PCA with prcomp} \description{ -Compute principal components for SpatRaster layers. For very large rasters this can only be done with a sample. This may be good enough but see \code{\link{prcomp}} if you want to use all values. +Compute principal components for SpatRaster layers. For very large rasters this can only be done with a sample. This may be good enough but see \code{\link{princomp}} if you want to use all values. } \usage{ @@ -28,7 +28,7 @@ Compute principal components for SpatRaster layers. For very large rasters this prcomp object } -\author{Alex Ilich and Robert Hijmans, based on a similar method by Benjamin Leutner} +\author{Robert Hijmans} \seealso{ \code{\link{princomp}}, \code{\link[stats]{prcomp}}} From be9ded9ed1c07d226ccea0bb6fffed9521846c0f Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 29 Dec 2023 15:28:18 -0500 Subject: [PATCH 2/5] Update princomp.Rd - Contrast with prcomp which is now implemented - Note maxcell argument --- man/princomp.Rd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man/princomp.Rd b/man/princomp.Rd index 203fe41d5..80431e06e 100644 --- a/man/princomp.Rd +++ b/man/princomp.Rd @@ -8,7 +8,8 @@ \description{ Compute principal components for SpatRaster layers. The benefit of this method is that it uses all values to compute the principal components, even for very large rasters. This is because it computes the covariance matrix by processing the data in chunks, if necessary, using \code{\link{layerCor}}. The population covariance is used (not the sample, with \code{n-1} denominator, covariance). -Alternatively, you can use \code{stats::\link[stats]{princomp}} or \code{stats::\link[stats]{prcomp}} with a data.frame of the raster values, using a sample for very large rasters (see the examples below). +Alternatively, you can specify \code{maxcell} or sample raster values to a data.frame to speed up calculations for for very large rasters (see the examples below). +See \code{\link{princomp}} for an alternative method that has better numerical accuracy, but is slower, and for very large rasters can only be accomplished with a sample since all values must be read into memory. } \usage{ @@ -30,7 +31,7 @@ princomp object \author{Alex Ilich and Robert Hijmans, based on a similar method by Benjamin Leutner} -\seealso{ \code{\link[stats]{princomp}}} +\seealso{ \code{\link{prcomp}} \code{\link[stats]{princomp}}} \examples{ f <- system.file("ex/logo.tif", package = "terra") From e2433b0da5b18eb9cb6d32628738d327e3b3685f Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 29 Dec 2023 15:32:06 -0500 Subject: [PATCH 3/5] Update prcomp2.Rd - List pros and cons --- man/prcomp.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/prcomp.Rd b/man/prcomp.Rd index 319c87433..9d699bf5a 100644 --- a/man/prcomp.Rd +++ b/man/prcomp.Rd @@ -6,7 +6,7 @@ \title{SpatRaster PCA with prcomp} \description{ -Compute principal components for SpatRaster layers. For very large rasters this can only be done with a sample. This may be good enough but see \code{\link{princomp}} if you want to use all values. +Compute principal components for SpatRaster layers. This method is may be preferred due to greater numerical accuracy, however it is slower and for very large rasters it can only be done with a sample. This may be good enough but see \code{\link{princomp}} if you want to use all values. } \usage{ From f60445fe4e8928439d65c5e27268bc098e1e4a1d Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 29 Dec 2023 15:33:35 -0500 Subject: [PATCH 4/5] Update princomp3.Rd Fix typo --- man/princomp.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/princomp.Rd b/man/princomp.Rd index 80431e06e..6476b21d1 100644 --- a/man/princomp.Rd +++ b/man/princomp.Rd @@ -8,7 +8,7 @@ \description{ Compute principal components for SpatRaster layers. The benefit of this method is that it uses all values to compute the principal components, even for very large rasters. This is because it computes the covariance matrix by processing the data in chunks, if necessary, using \code{\link{layerCor}}. The population covariance is used (not the sample, with \code{n-1} denominator, covariance). -Alternatively, you can specify \code{maxcell} or sample raster values to a data.frame to speed up calculations for for very large rasters (see the examples below). +Alternatively, you can specify \code{maxcell} or sample raster values to a data.frame to speed up calculations for very large rasters (see the examples below). See \code{\link{princomp}} for an alternative method that has better numerical accuracy, but is slower, and for very large rasters can only be accomplished with a sample since all values must be read into memory. } From 3891334e528171ba6f1f1ef944e4024021eda9a1 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 29 Dec 2023 15:44:32 -0500 Subject: [PATCH 5/5] Update prcomp2.Rd - Add how SD calculated --- man/prcomp.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/prcomp.Rd b/man/prcomp.Rd index 9d699bf5a..7a2b430d5 100644 --- a/man/prcomp.Rd +++ b/man/prcomp.Rd @@ -6,7 +6,7 @@ \title{SpatRaster PCA with prcomp} \description{ -Compute principal components for SpatRaster layers. This method is may be preferred due to greater numerical accuracy, however it is slower and for very large rasters it can only be done with a sample. This may be good enough but see \code{\link{princomp}} if you want to use all values. +Compute principal components for SpatRaster layers. This method is may be preferred due to greater numerical accuracy, however it is slower and for very large rasters it can only be done with a sample. This may be good enough but see \code{\link{princomp}} if you want to use all values. Unlike \code{\link{princomp}}, in this method the sample variances are used with \code{n-1} as the denominator. } \usage{