SPC {spherepc} | R Documentation |
Spherical principal curves
Description
This function fits a spherical principal curve.
Usage
SPC(data, q = 0.1, T = nrow(data), step.size = 1e-3, maxit = 10,
type = "Intrinsic", thres = 0.1, deletePoints = FALSE, plot.proj = FALSE,
kernel = "quartic", col1 = "blue", col2 = "green", col3 = "red")
Arguments
data |
matrix or data frame consisting of spatial locations with two columns. Each row represents a longitude and latitude (denoted by degrees). |
q |
numeric value of the smoothing parameter. The parameter plays the same role, as the bandwidth does in kernel regression, in the |
T |
the number of points making up the resulting curve. The default is 1000. |
step.size |
step size of the |
maxit |
maximum number of iterations. The default is 30. |
type |
type of mean on the sphere. The default is "Intrinsic" and the other choice is "Extrinsic". |
thres |
threshold of the stopping condition. The default is 0.1 |
deletePoints |
logical value. The argument is an option of whether to delete points or not. If |
plot.proj |
logical value. If the argument is TRUE, the projection line for each data is plotted. The default is FALSE. |
kernel |
kind of kernel function. The default is quartic kernel and alternatives are indicator or Gaussian. |
col1 |
color of data. The default is blue. |
col2 |
color of points in the principal curves. The default is green. |
col3 |
color of resulting principal curves. The default is red. |
Details
This function fits a spherical principal curves, and requires to load the 'rgl', 'sphereplot', and 'geosphere' R packages.
Value
plot and a list consisting of
prin.curves |
spatial locations (denoted by degrees) of points in the resulting principal curves. |
line |
connecting line bewteen points of |
converged |
whether or not the algorithm converged. |
iteration |
the number of iterations of the algorithm. |
recon.error |
sum of squared distances from the data to their projections. |
num.dist.pt |
the number of distinct projections. |
Note
This function requires to load 'rgl', 'sphereplot', and 'geosphere' R packages.
Author(s)
Jongmin Lee
References
Jang-Hyun Kim, Jongmin Lee and Hee-Seok Oh. (2020). Spherical Principal Curves <arXiv:2003.02578>.
Jongmin Lee, Jang-Hyun Kim and Hee-Seok Oh. (2021). Spherical principal curves. IEEE Transactions on Pattern Analysis and Machine Intelligence, 43, 2165-2171. <doi.org/10.1109/TPAMI.2020.3025327>.
See Also
Examples
library(rgl)
library(sphereplot)
library(geosphere)
#### example 2: waveform data
n <- 200
alpha <- 1/3; freq <- 4 # amplitude and frequency of wave
sigma1 <- 2; sigma2 <- 10 # noise levels
lon <- seq(-180, 180, length.out = n) # uniformly sampled longitude
lat <- alpha * 180/pi * sin(freq * lon * pi/180) + 10. # latitude vector
## add Gaussian noises on latitude vector
lat1 <- lat + sigma1 * rnorm(length(lon)); lat2 <- lat + sigma2 * rnorm(length(lon))
wave1 <- cbind(lon, lat1); wave2 <- cbind(lon, lat2)
## implement SPC to the (noisy) waveform data
SPC(wave1, q = 0.05)
SPC(wave2, q = 0.05)
#### example 1: earthquake data
data(Earthquake)
names(Earthquake)
earthquake <- cbind(Earthquake$longitude, Earthquake$latitude)
SPC(earthquake, q = 0.1)
## options 1: plot the projection lines (use option of plot.proj = TRUE)
SPC(earthquake, q = 0.1, plot.proj = TRUE)
## option 2: open principal curves (use option of deletePoints = TRUE)
SPC(earthquake, q = 0.04, deletePoints = TRUE)