Package 'GWnnegPCA'

Title: Geographically Weighted Non-Negative Principal Components Analysis
Description: Implements a geographically weighted non-negative principal components analysis, which consists of the fusion of geographically weighted and sparse non-negative principal components analyses <doi:10.17608/k6.auckland.9850826.v1>.
Authors: Narumasa Tsutsumida [aut, cre]
Maintainer: Narumasa Tsutsumida <[email protected]>
License: GPL (>= 3)
Version: 0.0.5
Built: 2025-03-07 06:20:36 UTC
Source: https://github.com/naru-t/gwnnegpca

Help Index


Geographically Weighted Non-negative Principal Component Analysis

Description

Implementation of geographically weighted non-negative principal component analysis, which consists of the fusion of GWPCA and sparse non-negative PCA.

Usage

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,
  ...
)

Arguments

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

Value

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

Examples

# 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"
)