Learn R Programming

spherepc (version 0.1.2)

SPC: 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 = 30, 
type = "Intrinsic", thres = 1e-2, 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.

q

numeric value of the smoothing parameter. Intuitively speaking, the role of this argument is similar to the that of bandwidth for kernel regression. The value should be a numeric value between 0.01 and 0.5. The default is 0.1.

T

the number of points in the resulting curve.

step.size

step size of the PrincipalCircle function. The resulting principal circle is used by an initialization of the SPC.

maxit

maximum number of iterations.

type

type of mean on the sphere. The default is "Intrinsic" and the other choice is "Extrinsic".

thres

threshold of the stopping condition.

deletePoints

logical value. The argument is an option of whether to delete points or not. If deletePoints is FALSE, this function leaves the points in curves which do not have adjacent data for each expectation step. As a result, the function usually returns a closed curve, i.e., a curve without endpoints. If deletePoints is TRUE, this function deletes the points in curves which do not have adjacent data for each expectation step. As a result, The SPC function usually returns an open curve, i.e., a curve with endpoints. The default is FALSE.

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.

col2

color of points in the principal curves.

col3

color of line of the principal curves.

Value

plot and a list consisting of

prin.curves

spatial points of in the resulting principal curves.

line

connecting line bewteen points of prin.curves.

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.

Details

This function fits a spherical principal curves, and requires to load the 'rgl', 'sphereplot', and 'geosphere' R packages.

References

Jang-Hyun Kim, Jongmin Lee, Hee-Seok Oh. (2020). Spherical Principal Curves <arXiv:2003.02578>.

See Also

SPC.Hauberg.

Examples

Run this code
# NOT RUN {
library(rgl)
library(sphereplot)
library(geosphere)
#### example 1: earthquake data
data(Earthquake)
names(Earthquake)
earthquake <- cbind(Earthquake$longitude, Earthquake$latitude)   
# }
# NOT RUN {
SPC(earthquake, q = 0.1)
# }
# NOT RUN {
#### example 2: waveform data
n <- 200
alpha <- 1/3    # amplitude
freq <- 4       # frequency
sigma <- 2
lon <- seq(-180, 180, length.out = n)
lat <- alpha * 180/pi * sin(lon * pi/180 * freq) + 10 + sigma * rnorm(length(lon))
wave <- cbind(lon, lat)
# }
# NOT RUN {
SPC(wave, q = 0.05)
# }

Run the code above in your browser using DataLab