gw_nsprcomp | R Documentation |
Implementation of geographically weighted non-negative principal component analysis, which consists of the fusion of GWPCA and sparse non-negative PCA.
gw_nsprcomp(
data,
elocat,
vars,
bw,
k = 2,
kernel = "gaussian",
adaptive = TRUE,
p = 2,
theta = 0,
longlat = FALSE,
geodisic_measure = "cheap",
dMat = NULL,
n.obs = NA,
n.iter = 1,
ncomp = k,
nneg = TRUE,
localcenter = TRUE,
localscale = FALSE,
...
)
data |
An sf object containing the spatial data and attributes for analysis |
elocat |
Two-column numeric array or sf object for providing evaluation locations |
vars |
Character vector of variable names to be used in the analysis |
bw |
Bandwidth used in the weighting function |
k |
The number of retained components (default: 2) |
kernel |
Kernel function type: "gaussian", "exponential", "bisquare", "tricube", or "boxcar" |
adaptive |
If TRUE, calculate adaptive kernel (default: TRUE) |
p |
Power of the Minkowski distance (default: 2) |
theta |
Angle in radians to rotate coordinate system (default: 0) |
longlat |
If TRUE, great circle distances will be calculated (default: FALSE) |
geodisic_measure |
Method for geodesic distance calculation (default: "cheap") |
dMat |
Pre-specified distance matrix (default: NULL) |
n.obs |
Number of observations for correlation matrix (default: NA) |
n.iter |
Number of bootstrap iterations (default: 1) |
ncomp |
Number of principal components to compute (default: k) |
nneg |
If TRUE, constrain loadings to be non-negative (default: TRUE) |
localcenter |
If TRUE, center local weighted x (default: TRUE) |
localscale |
If TRUE, scale local weighted x (default: FALSE) |
... |
Additional arguments passed to methods |
A list containing:
loadings |
The localized loadings matrix |
score |
The PC score matrix from the localized non-negative PCA |
sdev |
The localized standard deviation vector of the principal components |
# Read North Carolina SIDS data from sf package
nc <- sf::st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
# Scale selected variables for analysis
vars_to_use <- c("SID74", "NWBIR74", "BIR74")
Data.scaled <- scale(as.matrix(sf::st_drop_geometry(nc[, vars_to_use])))
# Create sf object with scaled data
nc_scaled <- nc
nc_scaled[vars_to_use] <- Data.scaled
gwnnegpca_ans <- gw_nsprcomp(
data = nc_scaled,
vars = vars_to_use,
bw = 0.25,
k = 3,
longlat = TRUE,
kernel = "bisquare",
adaptive = TRUE,
nneg = TRUE,
geodisic_measure = "geodesic"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.