Skip to content
Regularized Principal Component Analysis for Spatial Data
Branch: master
Clone or download
Latest commit be9cb4f Apr 1, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Update Nov 27, 2017
man Adjust description Apr 1, 2018
src Update Nov 27, 2017
.DS_Store Update the package Feb 20, 2018
.Rbuildignore Update travis.yml Jan 26, 2017
.gitignore no message Jan 24, 2017
.travis.yml Update travis.yml Jan 26, 2017
DESCRIPTION Update the package Feb 20, 2018
NAMESPACE Update Mar 17, 2017 Merge remote-tracking branch 'origin/master' Feb 20, 2018
SpatPCA.Rproj Update a new version of the pkg Nov 3, 2017

SpatPCA Package

CRAN_Status_Badge Downloads Travis-CI Build Status License Research software impact


SpatPCA is an R package that facilitates regularized principal component analysis,

  • seeking the dominant patterns (eigenfunctions), which can be smooth and localized
  • computing spatial prediction (Kriging) at new locations
  • suitable for either regularly or irregularly spaced data, including 1D, 2D, and 3D
  • by the alternating direction method of multipliers (ADMM) algorithm


To get the current released version from CRAN:


To get the current development version from GitHub:


To compile C++ code with the package RcppArmadillo,

  • Windows users require Rtools
  • Mac users require Xcode Command Line Tools, and install the library gfortran by typing the following lines into terminal
curl -O
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /

More details can be found here.



### location
x_1D <- as.matrix(seq(-5, 5, length = 50))

###underlying eigenfunction
Phi_1D <- exp(-x_1D^2)/norm(exp(-x_1D^2), "F")

### Realizations on x_1D
Y_1D <- rnorm(n = 100, sd = 3)%*%t(Phi_1D) + matrix(rnorm(n = 100*50), 100, 50)

### main function: spatpca()
cv_1D <- spatpca(x = x_1D, Y = Y_1D)

### Plot the estimate
plot(x_1D, cv_1D$eigenfn[,1], type = 'l', main = "1st eigenfunction")
lines(x_1D, svd(Y_1D)$v[,1], col='red')
legend('topleft', c('SpatPCA', 'PCA'), lty=1:1, col=1:2)


Wen-Ting Wang and Hsin-Cheng Huang


Wen-Ting Wang


Wang, W.-T. and Huang, H.-C. (2017). Regularized principal component analysis for spatial data. Journal of Computational and Graphical Statistics, 26, 14-25.



You can’t perform that action at this time.