A new outlier detection method for spherical data

In this study, we propose a new method to detect outlying observations in spherical data. The method is based on the k-nearest neighbours distance theory. The proposed method is a good alternative to the existing tests of discordancy for detecting outliers in spherical data. In addition, the new method can be generalized to identify a patch of outliers in the data. We obtain the cut-off points and investigate the performance of the test statistic via simulation. The proposed test performs well in detecting a single and a patch of outliers in spherical data. As an illustration, we apply the method on an eye data set.


Introduction
Spherical data are concerned with directions in three dimensions. They may arise in many areas of scientific experimentation such as biological, geological and environmental sciences. For example, the wind direction measured by two different equipments (see [1]) or the altitudes of the moon and the sun observed at the beginning of the lunar month (see [2]) form spherical data. The analysis of spherical data generally concentrates on the directional vector of the auditory object and, in most cases, ignores the distance effects. Under this assumption, the representation of the data reduces to a more tractable two-dimensional spherical display of the data namely latitude θ and longitude φ. While normal distribution is common for linear data, the von Mises-Fisher distribution is regularly considered for spherical data. The distribution is also known as Fisher distribution and assumes the data to be rotationally symmetric [3,4].
Outliers are observations that are different in some way from the rest. For example, the wind direction on one particular day which is in the opposite direction to that observed on other days in the same monsoon season is a candidate to be an outlier. The existence of outliers in circular data has been shown to affect parameter estimation and weaken the accuracy of forecast (see for example [5,6] and warrants proper treatment in the early stage of data analysis. At present, several discordancy tests are developed to detect outlier in 2-dimensional directional data including [7][8][9][10]. Fewer similar studies are conducted for spherical data [11]. Used probability plot as part of a preliminary examination on a given spherical data set to detect outlier. On the other hand [4], proposed formal tests of discordancy by extending the idea used in [5] for circular data. In this paper, we propose a new outlier detection method for spherical data using the k-nearest neighbours distance on a unit sphere. The distance between two points on the surface of a sphere is measured using the law of cosine. The proposed method can detect not only single and multiple outliers but also a patch of outliers. This paper is organized as follows: Section 2 reviews two existing tests of discordancy in the Fisher distribution. Section 3 shows the distance between two-unit vectors. Section 4 reviews the definition of k-nearest neighbours distance. Section 5 presents a new test of discordancy for a patch of outliers. Through simulations, we obtain the percentage points of the test statistic and study its performance in Section 6. For illustration, an application of the methods on a real data set is presented in Section 7.

Tests of discordancy in the fisher distribution
Fisher distribution is a common unimodal distribution considered for spherical data. The probability density functions of a Fisher distribution for a given random vector (Θ, F) is given by f ðy; φÞ ¼ ½k=ð4p sinh kÞ�exp½kfcos a cos y þ sin a siny cosðφ À bÞg� sin y ð1Þ where 0�θ, α<π; 0�φ, β<2π; κ>0, (α, β) is the mean direction, and κ is a measure of the concentration about the mean direction. Let (θ 1 , φ 1 ),. . .,(θ n , φ n ) be a random sample from a Fisher distribution with mean direction (α, β). Let ð � y; � φÞ be the sample mean direction, R be the sample resultant length given by R ¼ ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ther, R ðÀ iÞ nÀ 1 and � R ðÀ iÞ nÀ 1 denote the values of resultant length and mean resultant length, respectively, with the observation (θ i , φ i ) omitted from the data set [4]. Recommended two test statistics, the C k and E k statistics. The analogue of Collett's C statistic is defined as While the analogue of Collett's M statistic is [4] noted that the C k statistic is a good statistic when κ is known or a good estimate if it is available. In addition, the E k statistic is developed by considering intuitive and formal likelihood-ratio, whose distribution is available in compact form, and is independent of the value of κ. The E k statistic is based on a generalized likelihood-ratio test against the alternative hypothesis that one observation is drawn from a Fisher distribution with different mean direction but the same concentration parameter. In addition, both test statistics can detect a single outlier and several outliers (see [4]).

The distance on a sphere
For any 3-dimensional data set, we can find a distance of any given point on a sphere by calculating the distance between two vectors. The distance between two-unit vectors x 1 and x 2 (where both have a length of unit radius) can be calculated by using the law of cosine. Let θ 12 be the angle between unit vectors x 1 = (x 1 , y 1 , z 1 ) and x 2 = (x 2 , y 2 , z 2 ). We can obtain the distance between the two points on a sphere by Therefore Eq (4) can be simplified to where 0�θ 12 �π. It is known that x 1 •x 2 = kx 1 kkx 2 k cos θ 12 . Then Given that x 1 and x 2 are two-unit vectors, it must be that cos y 12 ¼ x T 1 x 2 . In general, the spherical distance between two-unit vectors is given by For simplicity, we may remove the constant giving The K-nearest neighbours distance If k = 1, we consider the distance of first nearest neighbours for a given point, say x i . First, we denote d 1i (x i , x j ), for j = 1,2,. . .,n, i6 ¼j as the distance of first nearest neighbours between the ith observation and the rest of observations while d (1i) (x i , x j ) the corresponding ordered distances. The first-nearest distance for the i-th observation is then given by Note that fQ 1 i ; i ¼ 1; 2; . . . ; ng gives a sequence of distances between successive observations on the p-dimensional surface. The statistic (6) can be generalized to detect a patch of outliers in spherical data by calculating the k-nearest distance for the i-th observation. For that, we define Q k i as the k-nearest neighbours distance for the ith ordered observation, k = 1,2,3,. . . and i = 1,2,. . .,n such that We will use the statistic (7) in the development of a new method for detecting a single, multiple as well as a patch of outliers in the following section.

A new method of outlier detection for spherical data
In this section, we use the k-nearest neighbours distance as a basic idea to be used in the development of a new method to detect possible outliers in spherical data, denoted by Q k . Suppose x 1 , x 2 ,. . .,x n are (i.i.d) spherical observations from a Fisher distribution of sample size n. The sample vector of a spherical sample is given by x i = (x i , y i , z i ). Thus, the procedure to obtain the outlier detection method using the Q k statistic is described as follows: Step 1 Start with k = 1. Calculate Q 1 i , i = 1,2,. . .,n as given by Eq (7).
Step 2 If the value of Q 1 i exceeds a pre-determined cut-off point, say C Q , then the i-th observation corresponding to Q 1 i is identified as an outlier and the process is stopped. Otherwise, proceed to the next step.
Step 4 If the value of Q 2 i exceeds a pre-determined cut-off point, say C Q , then the observations corresponding to Q 2 i are identified as a patch of two outliers and the process is stopped. Otherwise, the process continues by increasing the value of k by one at a time in the subsequence steps.
First, we need to obtain the cut-off points C Q for the Q k statistic. We design a simulation study using the R software to find the percentage points under the null hypothesis of no outliers in the circular data set. Note that parameters α and β are spherical location parameters while κ is a concentration parameter. We found that the distances between observations generated from a Fisher distribution depend on n and κ but not on α and β (the detail is not given here). For each combination of n and κ, we generate a sample from Fisher distribution with both location parameters fixed (α = 0, β = 0) and calculate the Q k statistic. Then, we repeat the process 3000 times and estimate the percentage points of the Q k statistic at 10%, 5% and 1% upper percentiles when no outlier is present in the sample. Selected cut-off points C Q for the Q k statistic are tabulated in Tables 1-3 for k = 1, 2 and 3 respectively.
For most combinations of the concentration parameter κ and percentile level, the cut-off point decreases as the sample size increases. It can also be seen that, for small sample sizes, the cut-off points are a decreasing function of κ. For larger sample sizes, the cut-off points have a peak value at around κ = 30. The results indicate the proposed statistic depends on n and κ of the underlying assumed model. As one might expect, it is also noted that the cut-off point also increases as the value of the k-nearest distance increases due to larger distances on the sphere between the points of interest.  [4]. Investigated the performance of several methods to detect a single outlier in spherical

PLOS ONE
distribution. Therefore, we compare the performance of the Q k statistic with the existing methods of E k and C k statistics to detect a single outlier and a patch of outliers for various values of sample size and concentration parameters.
To study the performance of the Q k , E k and C k statistics to detect a single outlier, we first generate samples for two cases, a) n = 10, κ = 3 and b) n = 30, κ = 50. The samples are generated in such a way that n−1 of the observations come from Fisher distribution with α = 0, β = 0 while one observation (outlier) from Fisher distribution with α = λπ, β = 0, κ = 30, 0�λ�1. If the value of Q k i , E k i and C k i are greater than the corresponding cut-off point and the i th observation is located at the outlying value, then we have correctly detected an outlier. We repeat the simulation 3000 times and obtain the value of P5 or known as probability of correct detection of an outlier which has been introduced into the samples. Note that, the cut-off points for the E k and C k statistics are obtained from Monte Carlo simulation according to the procedure in obtaining the cut-off points for Q k statistic. Fig 1 plots the performance of the Q k , E k and C k statistics to detect a single outlier for small sample size and small concentration parameter value. Generally, for small sample size, the Q k statistic performs better than the E k statistic only. However, the performance is almost identical when larger sample size and larger concentration parameter values are considered as shown in Fig 2. We also investigate the performance to detect a patch of outliers for the three statistics. For small sample size and small concentration parameter value, the performance of the Q k statistic is comparable to the E k and C k statistics as shown in Fig 3. A much closer result is observed for larger sample size and larger concentration values as shown in Fig 4. The trend is observed for other combinations of sample size and concentration parameter values. This suggests that the Q k statistic can be a good alternative outlier detection method for spherical data.

Practical example
For illustration, we now apply the proposed and existing spherical discordancy tests into a set of eye data. We consider the eye data consisting of 23 patients (unit in radians) recorded using optical coherence tomography (OCT) at the University Malaya Medical Centre (UMMC).

PLOS ONE
OCT technology originally is used in ophthalmology to image the posterior segment and has also been used to image anterior segment structures such as the cornea. The angle imaging of the anterior segment OCT in UMMC patients' eyes were obtained with Anterior Segment OCT (AS-OCT). The measurements selected are the angle of the posterior corneal curvature, φ, and the angle of the eye (between posterior corneal curvature to iris), θ. As such, we are keen to identify possible outliers in this data set as given in Table 4.
The summary statistics for the given spherical data set are calculated; the sample mean direction is given in a longitude and latitude expression, ðŷ ¼ 0:6833;φ ¼ 1:5744Þ with the

PLOS ONE
concentration parameterk ¼ 17:9100. The spherical plot of the data is given in Fig 5. The samples are located around a north pole. This indicates that both variables, namely the posterior and angle of the eye, recorded these 23 observations to be in the same direction. However, there is one observation lying further away from the rest. It is known that Q-Q plot and probability plotting are commonly used to investigate the goodness of fit of linear, circular and spherical data samples (see for example [14][15][16]). It is used to visualize the goodness of fit and to identify the presence of outlier(s) at earlier stage [11]. Provided procedures of plotting an ordered value for spherical data which is assumed to follow a Fisher distribution. They proposed three types of procedures, namely, colatitudes, longitude and two-variable plotting procedure for a Fisher model. The procedures considered three-ordered-value plots. Two of them examine the marginal distributions of the two variables and one of them is to find the association between these two variables. The details of the procedures can be obtained in [11]. Note that, the quantile of the unit exponential distribution  ð Þ n for the uniform model is denoted by u and the quantile of the N (0,1) distribution is denoted by q.
The colatitude plot of the eye data as shown in Fig 6(A) indicates that the data follow Fisher distribution as the plot gives almost a straight line through the origin. This is further supported by the longitude plot as shown in Fig 6(B) which gives an approximately straight linear plot of slope close to 45˚passing through the origin. From Fig 6(C), we can clearly see one observation that lies far from the rest, indicating the existence of one possible outlier. Therefore, we apply the proposed discordancy test on the data. Upon applying the maximum likelihood estimation method, we obtain the estimate parameters of the Fisher distribution. The values of the parameters areâ ¼ 0:6833 andb ¼ 1:5744.
Based on the estimated parameters, we obtain the critical values of three test statistics using the R statistical software. The values are shown in Table 5 Table 5 shows the cut-off points for the three methods at 10% significance levels. Based on Table 5, only Q 2 and Q 3 statistics can detect observation 17 as an outlier at 10% upper level. This observation corresponds to a patient with

PLOS ONE
small values of angle of the posterior corneal curvature compared to other patients and thus may warrant further investigation. Next, we are keen to demonstrate the application of the tests to detect a patch of outliers. Observation 10 is chosen and located closely to observation 17 so that a patch of two outliers exist in the data. The new coordinate for observation 10 is θ = 0.9599, φ = 0.6109. From Fig 7, it can be seen clearly that both observations (observations 10 and 17) are located far from the rest. Upon applying descriptive statistics, the value of the sample mean direction is given in a longitude and latitude expression, ðŷ ¼ 0:6939;φ ¼ 1:5607Þ and the concentration parameterk ¼ 16:5789. The values of the test statistics and the cut-off points for the three methods at 10% significance levels are given in Table 6. As a result, the Q 2 and Q 3 statistics successfully detected observations 10 and 17 as a patch of two outliers at 10% upper level while the other test statistics failed.

Conclusion
In this paper, we proposed a new discordancy test for detecting outliers in spherical data based on the k-nearest neighbours distance. We further demonstrated the applicability of the proposed Q k statistic on the eye data set by successfully identifying a single outlier and a patch of outliers in the data. A novel aspect of this method is in its ability to detect a patch of outliers which can be enhanced for cluster analysis in spherical data. The proposed procedure should work for other spherical distributions.