Trend-Residual Dual Modeling for Detection of Outliers in Low-Cost GPS Trajectories

Low-cost GPS (receiver) has become a ubiquitous and integral part of our daily life. Despite noticeable advantages such as being cheap, small, light, and easy to use, its limited positioning accuracy devalues and hampers its wide applications for reliable mapping and analysis. Two conventional techniques to remove outliers in a GPS trajectory are thresholding and Kalman-based methods, which are difficult in selecting appropriate thresholds and modeling the trajectories. Moreover, they are insensitive to medium and small outliers, especially for low-sample-rate trajectories. This paper proposes a model-based GPS trajectory cleaner. Rather than examining speed and acceleration or assuming a pre-determined trajectory model, we first use cubic smooth spline to adaptively model the trend of the trajectory. The residuals, i.e., the differences between the trend and GPS measurements, are then further modeled by time series method. Outliers are detected by scoring the residuals at every GPS trajectory point. Comparing to the conventional procedures, the trend-residual dual modeling approach has the following features: (a) it is able to model trajectories and detect outliers adaptively; (b) only one critical value for outlier scores needs to be set; (c) it is able to robustly detect unapparent outliers; and (d) it is effective in cleaning outliers for GPS trajectories with low sample rates. Tests are carried out on three real-world GPS trajectories datasets. The evaluation demonstrates an average of 9.27 times better performance in outlier detection for GPS trajectories than thresholding and Kalman-based techniques.


Introduction
Low-cost, non-professional GPS (receiver) has become popular and grows in popularity at an ever increasing rate. Many devices in people's daily life are equipped with a built-in, low-cost GPS, such as mobile phones, watches, and cars. Compared with professional GPS, low-cost GPS has advantages of easy use and portability. Although these GPS-enabled devices are found useful in online mapping [1], traffic management [2], and localization of places of interest [3], their accuracy is limited due to existence of outliers. Erroneous or missing GPS readings may be caused due to various reasons, such as obscured line of sight, device cold starts, and other satellite signal disruptions [4][5][6]. Such aberrant data with inherent inconsistency may lead to difficulties, mistakes, or even failures in subsequent processing such as route prediction [7] and trajectory clustering [8]. Moreover, outliers in a GPS trajectory hold back estimating some high-order trajectory properties, e.g., speed, heading, and acceleration, which impair the quality and efficiency of trajectory comprehension [9,10].
For further processing or analysis of GPS trajectories, data cleaning is a prerequisite for any value-added analyses. One important purpose of data cleaning is to detect and remove outliers while retaining 'good' data. In view of this concept, data cleaning is different from data filtering. Filtering refers to estimating the current point based upon past points. It changes the data structure by reducing not only the influence of outliers but also data variations, which may lose original data information [11]. The common GPS trajectory processing techniques such as mean filter and median filter [12] mainly focus on filtering rather than cleaning. This paper aims to clean the trajectories, i.e., detect and remove outliers.
The majority of outlier detection methods for time-dependent data are either non-model-based or model-based, depending on whether a model is needed. Non-model-based method defines a specific measure without assuming the underlying data model. Some data are then deemed as outliers if the measured values are over a predefined threshold. Specific measures in GPS trajectory often use speed, acceleration, angle change, etc. [13][14][15][16]. Such non-model-based methods in GPS trajectories can be attributed as 'threshold methods'. Among reported studies of these methods, thresholding speed is probably the most popular one. When the speed estimated at a location exceeds a given threshold, the corresponding GPS record will be removed. However, such a non-model-based method faces the following difficulties. For a variety of trajectories in a dataset, it is hard for users to set thresholds without prior knowledge of the moving states [17]. Moreover, objects may move at an irregular speed and in varying directions, which makes it more difficult to choose the thresholds Threshold method is ineffective to detect less obvious or small outliers that influence location-critical applications such as map matching [18]. The same may occur for trajectories with a low-sample-rate. All of them may influence the performance of the threshold method for outlier detection in trajectories.
Model-based method scores potential outliers based on the degree they deviate from an ordinary pattern using a certain inherent statistical index. Generally, the first step of outlier detection for time-dependent data is to fit a model to the data and then examine its residuals [19,20]. Model-based method describes the data by the model and detects outliers according to the model, which, to a certain extent, avoids the difficulties of setting thresholds. Therefore, it is suitable for automated outlier detection. The model-based method is popular in a wide range of fields such as industrial quality control [11], network anomaly identification [21], and traffic flow investigation [22]. A traditional approach in GPS trajectory outlier detection is a Kalman-based method [23]. However, a major difficulty using this method for GPS trajectories arises from modeling the trajectories in practice. Not only because a trajectory could be quite irregular, but because various trajectories in a dataset may belong to vastly different classes of curves, which makes the modeling even more difficult [24]. As a result, although the model-based method is potentially appealing for outlier detection in GPS trajectories, its research is quite limited.
This paper proposes a new model-based approach for detecting outliers in GPS trajectories. It consists of two sequential steps. We first use a non-parameter, cubic smooth spline to extract the trend of a GPS trajectory, and then apply a time series method to model its residuals. Locations where significantly large residuals exist are considered as outliers. Compared with the existing model-based method, the new approach attempts not to model the trajectory directly but to adaptively model both the trend and residuals. It only requires setting one flexible critical value for outlier scores rather than setting various thresholds using prior knowledge. In addition, it is able to detect medium to small outliers in trajectories with low sample rates. Based on these properties of the proposed cleaning method, it is named as trend-residual dual modeling (TRDM). The remainder of the paper is organized as follows. Section 2 describes the theoretical aspects of the TRDM method. In Section 3, the performance of the TRDM method for real GPS trajectories data is analyzed and compared with the conventional threshold and Kalman-based method. Finally, concluding remarks and summary are given in Section 4.

Methods
This section introduces the TRDM method. Section 2.1 addresses the cubic smooth spline and its application in determining the trend in a GPS trajectory. Section 2.2 models the residuals of the trajectory with reference to the trend by a time series method, and finds the outliers by scoring the residuals. An automated selection of the smoothness parameter for cubic smooth spline is described in Section 2.3. Finally, we summarize an iterative algorithm for TRDM in Section 2.4.

Trend Modeling
This section uses cubic smooth spline to model the trend of a GPS trajectory. A GPS trajectory consists of a sequence of points with at least three measurements: time, latitude, and longitude. As an example, Figure 1 shows a trajectory of a walking person where two outliers occurred.

Methods
This section introduces the TRDM method. Section 2.1 addresses the cubic smooth spline and its application in determining the trend in a GPS trajectory. Section 2.2 models the residuals of the trajectory with reference to the trend by a time series method, and finds the outliers by scoring the residuals. An automated selection of the smoothness parameter for cubic smooth spline is described in Section 2.3. Finally, we summarize an iterative algorithm for TRDM in Section 2.4.

Trend Modeling
This section uses cubic smooth spline to model the trend of a GPS trajectory. A GPS trajectory consists of a sequence of points with at least three measurements: time, latitude, and longitude. As an example, Figure 1 shows a trajectory of a walking person where two outliers occurred. As a function of time, the two coordinate components of the trajectory can be expressed as below where i t , i lat , and i lon are respectively the time, latitude, and longitude of the i-th location in the trajectory. Since the observations are recorded in order of time, we have 1 2 Intuitively, the true trajectory should not be far from the GPS observations and is expected to be smooth to a certain degree in both longitudinal and latitudinal directions. Therefore, the cubic smooth spline of nonparametric regression is appropriate for either the latitude or longitude trajectory. It is the minimizer of the following function where i Y : the observation at i t ;  : the pre-selected positive constant known as the smoothness (tradeoff) parameter; ( ) f t : the expected smooth curve to be determined.
then it can be shown [25] where I : the identity matrix; K : a non-negative definite band matrix determined by 1 , , n t t  , the detail calculation refers to [25]. As a function of time, the two coordinate components of the trajectory can be expressed as below where t i , lat i , and lon i are respectively the time, latitude, and longitude of the i-th location in the trajectory. Since the observations are recorded in order of time, we have t 1 < t 2 < · · · < t n . Intuitively, the true trajectory should not be far from the GPS observations and is expected to be smooth to a certain degree in both longitudinal and latitudinal directions. Therefore, the cubic smooth spline of nonparametric regression is appropriate for either the latitude or longitude trajectory. It is the minimizer of the following function where Y i : the observation at t i ; λ: the pre-selected positive constant known as the smoothness (tradeoff) parameter; f (t): the expected smooth curve to be determined. Let Y = (Y 1 , · · · , Y n ) T andF = (f (t 1 ), · · · ,f (t n )) T then it can be shown [25] where I: the identity matrix; K: a non-negative definite band matrix determined by t 1 , · · · , t n , the detail calculation refers to [25]. The solutionf (t) is a cubic spline with knots atf (t 1 ), · · · ,f (t n ). It is an optimal trade-off between the goodness of fit to the data and certain smoothing requirements determined by λ. Equation (3) is essentially a penalized least squares regression. Figure 2 shows the determined trend in longitude-trajectory and latitude-trajectory for the trajectory in Figure 1. The selection of the smoothness parameter λ is crucial for the solution of min f S( f ) and an adaptive selection method will be introduced in Section 2.3. The solutionˆ( ) f t is a cubic spline with knots at 1( ), , ( ) It is an optimal trade-off between the goodness of fit to the data and certain smoothing requirements determined by  . Equation (3) is essentially a penalized least squares regression. Figure 2 shows the determined trend in longitudetrajectory and latitude-trajectory for the trajectory in Figure 1. The selection of the smoothness parameter  is crucial for the solution of min ( ) f S f and an adaptive selection method will be introduced in Section 2.3.
(a) (b) Figure 2. Determined trend of the trajectory (shown in Figure 1) and the outlier score for each observation in (a) latitude direction and (b) longitude direction.

Outlier Detection from Residuals
Once the trend is determined, outliers will be detected by modeling its residuals with reference to the observations, i.e., the GPS measurements. This is carried out with a time series method. Let i Z denote the original residuals, i.e.,  Figure 1) and the outlier score for each observation in (a) latitude direction and (b) longitude direction.

Outlier Detection from Residuals
Once the trend is determined, outliers will be detected by modeling its residuals with reference to the observations, i.e., the GPS measurements. This is carried out with a time series method. Let Z i denote the original residuals, i.e., According to Fox [26], the residuals Z i contaminated by an outlier at a time stamp T can be represented by additive outlier (AO) model and innovation outlier (IO) model: IO : where ω: the magnitude of the outlier; I T (t): the indicator function, i.e., I T (t) = 1 if and only if t = T; X i : the background process of outlier-free residuals; α i : the parameters of X i 's infinite moving average representation [27]. The unobserved background process X i is supposed to follow the auto-regressive and moving average (ARMA) model: In this case, For further investigation of outliers in practice, the parameters of the ARMA model of X i should first be estimated by the observed residuals Z i using robust methods, e.g., the Extended Sample Autocorrelation Function (ESACF) [28], Durbin method [29] or the methods in [27].
To score outliers in time series, let π(B) = Φ(B) Θ(B) = 1 − ∞ ∑ j=1 π j B j . From the single outlier models (5) and (6), we can find the least squares estimation of the magnitude of the outlier where , F is the forward shift operator, i.e., Fe T = e T+1 . Since Φ(B) Θ(B) X T follows a normal distribution [27] with zero mean and var(ω AO (T)) = ρ 2 σ 2 , var(ω IO (T)) = σ 2 , the two estimators both follow standard normal distribution, where σ 2 is the variance of Gaussian white noise {ε i }. Then, by comparing the two estimators with a predefined critical value C r , one can determine the existence of outlier at time t T . As η AO (T) and η IO (T) both follow the standard normal distribution, the critical value C r is in fact the ratio between the magnitude of the residual's outlier and its standard deviation, which in general is selected as 3, 3.5, and 4, respectively for high, moderate, low sensitivities to outliers in the literature [30].
In practice, we do not know how many outliers there are in a trajectory and what their time stamps are. To address this problem, Chang and Tiao [30] proposed an iteration approach. It checks the magnitudes of the two estimators at all points and then detects the most obvious outlier one at a time. Based on this idea, we define the outlier score of a point by and regard the largest one, when larger than C r , as the most obvious outlier. Figure 2 shows the results of trend-residual dual modeling and outlier detection for the trajectory shown in Figure 1. This trajectory is for a time period of 122 s and consists of 120 GPS recorded locations. The raw GPS recordings are shown in circles, while the trend is in solid dark lines. As depicted, the trend is a smooth curve determined by cubic smooth spline. There exist residuals between each GPS recording and the corresponding trend locations. Such residuals are then scored by using Equation (12) to identify the potential outliers. At the end, the GPS observations with outlier scores above the predefined critical value C r are considered as outliers.
The predefined critical value C r influences the cleaning results with TRDM. Generally, the smaller the value, the stronger the outlier detection ability. But at the same time, it has a greater risk to wrongly detect 'good' data as outliers. The effects of different critical values will be further discussed in Section 3.3 through experiments. It will be shown that TRDM is able to have a high outlier detection capability while maintaining a relatively small risk to wrongly clean the 'good' data.

Selection of the Smoothness Parameter λ
Determining the smoothness parameter λ in Equation 2 is a key step to achieve an optimal outlier detection since it actually balances the smoothness and the allowed sudden change of a trajectory. To this end, we propose a criterion that combines the generalized cross-validation (GCV) and the corrected Akaike information criterion (AIC c ). The GCV approach is a modification of cross-validation in which the deleted residuals at points with large values are down-weighted [25]. Correcting the finite sample bias of AIC, AIC c is an improved version of AIC proposed by Hurvich et al. [31]. The corresponding criteria of the two methods are: where A = (I + λK) −1 is called the 'hat' matrix. Technically, λ should be chosen so that Equations (13) and (14) are minimized. For our application, we suggest the final smoothness parameter as where λ GCV and λ AIC C are the maximal values respectively making GCV(λ) and AIC C (λ) to be local minimum. Such a selection can be justified as below. The existence of GPS outliers is inconsistent with the assumption of Gaussian noise in cubic smooth spline. Larger smoothness parameters will mitigate potential influence of outliers and yield a smoother trend. In practice, since similar values of the smoothness parameters generate almost the same trends, we determine λ GCV and λ AIC C based on a limited number of λ ∈ 5 × 10 i−5 , i = 1, 2, . . . 10 .

Solution Procedure
In summary, the proposed TRDM method consists of the following steps: Use the cubic smooth spline to extract the trend within data and obtain residuals.
Calculate the residuals between the observations and the trend

3.
Use the time series method to model residuals and score outliers for every observation.
(a) Model the ARMA (p,q) for outlier-free time series by the ESACF [28] and Durbin method [29].
Let the cleaned data be the new data sequence. Note that the number of the current data sequence A few notes need to be made for practical implementation of TRDM. Since a GPS trajectory is decomposed to longitudinal and latitudinal directions, the above procedure needs to run for longitudinal and latitudinal directions separately. The final cleaned trajectory is the records retained in both directions. Besides, for a long GPS trajectory, one may divide the trajectory into multiple segments. We suggest that one segment is at least 100 points to ensure correctly identifying time series model of residuals [32,33].

Experiments and Evaluation
This section presents the experimental results on two real datasets, one trajectory from a vehicle and another on foot, to demonstrate the performance of the TRDM method. The last part evaluates the performance of the TRDM method by simulating different outliers and using 10 RTK GPS trajectories as ground truth.
We compare TRDM with a traditional two-stage method. In this method, a popular threshold method that considers both velocity (V) and acceleration (A) is used, and then a Kalman-smoother based cleaner is further applied to remove outliers.
For the VA threshold method, two sets of thresholds are used. VA1 has a velocity and acceleration limit of 22 m/s and 10 m/s 2 , respectively, where the velocity limit is chosen for city zones and the acceleration limit is recommended by Chen [17]. The second threshold VA2 is set to the maximal velocity and maximal acceleration of the ground truth trajectory. VA1 threshold method is often used to clean outliers in practice. In the following examples, we compare the VA1 threshold method and TRDM method with critical value for the low-cost vehicle trajectory and walking trajectories. Since the VA2 threshold method is difficult to use in practice, it will only participate in the simulation study in Section 3.3.
The Kalman-smoother based cleaner (KSC) is a modified version of the standard Kalman smoother. KSC removes a point if it is more than certain times the standard deviation rather than smoothing every point as its earlier version does [23]. In this study, we use three times the standard deviation for comparison. To implement the KSC method, a process model for the trajectory is required. Our study uses the popular near-constant velocity model, which assumes the object moves at a constant velocity in a short time [12]. The variation parameters of KSC is estimated by Sage-Husa method [34]. KSC is a fair comparison method as both KSC and TRDM are model-based and offline, i.e., cleaning outliers based on all measurements of the trajectory [35].

Vehicle Trajectory
A real example of a vehicle trajectory is used to illustrate the capability of TRDM in detecting unapparent outliers. For evaluation purposes, the trajectory was recorded by a low-cost GPS receiver and a precise GPS receiver, both aboard a Chevrolet Captiva. The low-cost GPS receiver was an Android Phone (Samsung S4 with Android version 5.0), recording at a rate of 1 Hz by using a home-made application. A precise Trimble R7 GPS receiver, configured to use RTK corrections, was employed to record the path at a rate of 2 Hz. The entire route was about 90 km (Figure 3a).

Vehicle Trajectory
A real example of a vehicle trajectory is used to illustrate the capability of TRDM in detecting unapparent outliers. For evaluation purposes, the trajectory was recorded by a low-cost GPS receiver and a precise GPS receiver, both aboard a Chevrolet Captiva. The low-cost GPS receiver was an Android Phone (Samsung S4 with Android version 5.0), recording at a rate of 1 Hz by using a homemade application. A precise Trimble R7 GPS receiver, configured to use RTK corrections, was employed to record the path at a rate of 2 Hz. The entire route was about 90 km (Figure 3a).  Such marginal improvement is because the low-cost GPS trajectory overall did not deviate greatly from the RTK GPS trajectory. Figure 3b shows an example section of the route where the low-cost GPS returns a trajectory quite close to the RTK GPS trajectory.
However, the TRDM method shows its contribution in a complex, curving segment as shown in Figure 3c,d. The low-cost GPS recorded many erroneous points possibly due to the low driving speed (30 km/h) in this curved segment. Figure 3c shows many remaining outliers after VA1 + KSC method, since the velocity change is relatively small at this route segment. As a result, the KSC is less effective to identify the outliers due to its assumption of near-constant velocity. In contrast, the TRDM method ( Figure 3d) is able to remove many such small outliers (typically the ones in the circle). This is because the introduction of the trend in TRDM enables adaptive capture of the structure of the trajectory and detect points that are inconsistent with their neighboring ones.
The mechanism of the TRDM's satisfactory performance can be illustrated by examining the longitude direction of this problematic segment. Figure 4a shows the trend of raw data extracted by cubic smooth spline. The trend fluctuates around the precise GPS, and the points deviating from precise GPS significantly are also deviating from the trend further compared with other 'normal' points. A great deviation from the trend contributes a high outlier score. Notice that the trend near 5940s balances the points before and after in longitude direction, which helps us detect the deviations. However, some erroneous points such as the ones near 5870s and 5875s have outlier scores lower than C r = 3 at the start. After the fifth iteration (Figure 4b), the outlier scores of remaining points increase in certain degree (e.g., erroneous points near 5870s and 5875s) and have outlier scores higher than C r = 3. That is a more obvious outlier and it may suppress the outlier scores of other erroneous points. Therefore, detecting and removing all outliers at one time is difficult. This is one of the reasons we iterate to remove outliers one at a time. Finally, we stop the iteration until all the outlier scores are lower than 3. From Figure 4c, we find that the remaining points are all close enough to the precise GPS, and the trend is more similar with the one comparing with the raw data. deviate greatly from the RTK GPS trajectory. Figure 3b shows an example section of the route where the low-cost GPS returns a trajectory quite close to the RTK GPS trajectory.
However, the TRDM method shows its contribution in a complex, curving segment as shown in Figure 3c,d. The low-cost GPS recorded many erroneous points possibly due to the low driving speed (30 km/h) in this curved segment. Figure 3c shows many remaining outliers after VA1 + KSC method, since the velocity change is relatively small at this route segment. As a result, the KSC is less effective to identify the outliers due to its assumption of near-constant velocity. In contrast, the TRDM method ( Figure 3d) is able to remove many such small outliers (typically the ones in the circle). This is because the introduction of the trend in TRDM enables adaptive capture of the structure of the trajectory and detect points that are inconsistent with their neighboring ones.
The mechanism of the TRDM's satisfactory performance can be illustrated by examining the longitude direction of this problematic segment. Figure 4a shows the trend of raw data extracted by cubic smooth spline. The trend fluctuates around the precise GPS, and the points deviating from precise GPS significantly are also deviating from the trend further compared with other 'normal' points. A great deviation from the trend contributes a high outlier score. Notice that the trend near 5940s balances the points before and after in longitude direction, which helps us detect the deviations. However, some erroneous points such as the ones near 5870s and 5875s have outlier scores lower than 3 r C  at the start. After the fifth iteration (Figure 4b), the outlier scores of remaining points increase in certain degree (e.g. erroneous points near 5870s and 5875s) and have outlier scores higher than 3 r C  . That is a more obvious outlier and it may suppress the outlier scores of other erroneous points. Therefore, detecting and removing all outliers at one time is difficult. This is one of the reasons we iterate to remove outliers one at a time. Finally, we stop the iteration until all the outlier scores are lower than 3. From Figure 4c, we find that the remaining points are all close enough to the precise GPS, and the trend is more similar with the one comparing with the raw data.

Walker Trajectories
We now discuss the performance of TRDM in more complex low-sample-rate walker trajectories. A walking trajectory (Figure 5a) was collected by a volunteer with a smartphone under Android OS in an urban setup at a sample rate 5 Hz. Due to the obstructions from buildings and the weather at that time or other unknown reasons, there were many missing points. The actual mean sample rate was 40 s. The route was from Place 1 to Place 5, and at Places 2 and 4 the volunteer wandered in a small range, causing a large deviation from the main trajectory. The VA1 + KSC method shown in Figure 5b has little ability to detect and remove the deviations near Places 2 and 4, while the TRDM cleans most of deviations, especially at Place 4. The cleaned trajectory in Figure 5c converges closely at Place 4 and all the points wrongly cross the streets are excluded. This is helpful for understanding the volunteer's movement more clearly.

Walker Trajectories
We now discuss the performance of TRDM in more complex low-sample-rate walker trajectories. A walking trajectory (Figure 5a) was collected by a volunteer with a smartphone under Android OS in an urban setup at a sample rate 5 Hz. Due to the obstructions from buildings and the weather at that time or other unknown reasons, there were many missing points. The actual mean sample rate was 40 s. The route was from Place 1 to Place 5, and at Places 2 and 4 the volunteer wandered in a small range, causing a large deviation from the main trajectory. The VA1 + KSC method shown in Figure 5b has little ability to detect and remove the deviations near Places 2 and 4, while the TRDM cleans most of deviations, especially at Place 4. The cleaned trajectory in Figure 5c converges closely at Place 4 and all the points wrongly cross the streets are excluded. This is helpful for understanding the volunteer's movement more clearly.  Figure 6 shows the velocity of the volunteer after using the TRDM method. At Places 2 and 4, the original velocities of many points exceed 10 m/s which are beyond walking speed limit, and the variation is large. After the TRDM method, most of velocities are less than 10 m/s. What is more, the standard deviation and the 95th-pencentile range are computed and shown in Table 1, in which the standard deviation and 95th-pecentile are reduced by 42.89% and 40.65%, respectively. It implies that, after applying the TRDM method, the velocity is relatively stable in a more reasonable range of common sense than before.  14 Finally, Figure 7 shows the TRDM results of the other four volunteers' trajectories with low sample rates collected with smartphones under Android OS. The arrows show the wandering places of the volunteers. After using the TRDM method, many large deviations are removed. These wandering places then become much apparent, although a few suspected outliers (e.g., those in black circles) still exist. The possible reason for the remaining outliers after the TRDM method is that the suspected outliers influence the trends, and then the remaining outliers do not deviate from the trends obviously enough. Therefore, the time series method is unable to detect them.  Figure 6 shows the velocity of the volunteer after using the TRDM method. At Places 2 and 4, the original velocities of many points exceed 10 m/s which are beyond walking speed limit, and the variation is large. After the TRDM method, most of velocities are less than 10 m/s. What is more, the standard deviation and the 95th-pencentile range are computed and shown in Table 1, in which the standard deviation and 95th-pecentile are reduced by 42.89% and 40.65%, respectively. It implies that, after applying the TRDM method, the velocity is relatively stable in a more reasonable range of common sense than before.  Figure 6 shows the velocity of the volunteer after using the TRDM method. At Places 2 and 4, the original velocities of many points exceed 10 m/s which are beyond walking speed limit, and the variation is large. After the TRDM method, most of velocities are less than 10 m/s. What is more, the standard deviation and the 95th-pencentile range are computed and shown in Table 1, in which the standard deviation and 95th-pecentile are reduced by 42.89% and 40.65%, respectively. It implies that, after applying the TRDM method, the velocity is relatively stable in a more reasonable range of common sense than before.  14 Finally, Figure 7 shows the TRDM results of the other four volunteers' trajectories with low sample rates collected with smartphones under Android OS. The arrows show the wandering places of the volunteers. After using the TRDM method, many large deviations are removed. These wandering places then become much apparent, although a few suspected outliers (e.g., those in black circles) still exist. The possible reason for the remaining outliers after the TRDM method is that the suspected outliers influence the trends, and then the remaining outliers do not deviate from the trends obviously enough. Therefore, the time series method is unable to detect them.  Finally, Figure 7 shows the TRDM results of the other four volunteers' trajectories with low sample rates collected with smartphones under Android OS. The arrows show the wandering places of the volunteers. After using the TRDM method, many large deviations are removed. These wandering places then become much apparent, although a few suspected outliers (e.g., those in black circles) still exist. The possible reason for the remaining outliers after the TRDM method is that the suspected outliers influence the trends, and then the remaining outliers do not deviate from the trends obviously enough. Therefore, the time series method is unable to detect them.

Performance Evaluation
This section evaluates the performance for the TRDM method by adding a range of outliers to a set of precise RTK GPS trajectories. For comparative purpose, results from the VA1 + KSC and VA2 + KSC methods are provided. Finally, the time consumption of TRDM and VA1 + KSC is discussed.
Ten precise GPS trajectories are used as ground truth in this study (Figure 8). They were collected by a Leador Spatial mobile mapping system equipped with a precise Trimble R8 GPS receiver with RTK corrections. The sample frequency was 1 Hz for most of the time, whereas there was a small part of data collected at a lower rate. We define small, medium, and large three outlier classes that respectively have a magnitude of errors of 0.00015 degree (about 15.7 m), 0.0004 degree (about 41.9 m), and 0.001 degree (about 104.7 m). We create four groups of simulated datasets by contaminating 10% of every trajectory respectively with small, medium, large outliers, and a mixture of the above three. Every contamination version is simulated 100 times for each trajectory. Outliers are added randomly to the original trajectories.

Performance Evaluation
This section evaluates the performance for the TRDM method by adding a range of outliers to a set of precise RTK GPS trajectories. For comparative purpose, results from the VA1 + KSC and VA2 + KSC methods are provided. Finally, the time consumption of TRDM and VA1 + KSC is discussed.
Ten precise GPS trajectories are used as ground truth in this study (Figure 8). They were collected by a Leador Spatial mobile mapping system equipped with a precise Trimble R8 GPS receiver with RTK corrections. The sample frequency was 1 Hz for most of the time, whereas there was a small part of data collected at a lower rate. We define small, medium, and large three outlier classes that respectively have a magnitude of errors of 0.00015 degree (about 15.7 m), 0.0004 degree (about 41.9 m), and 0.001 degree (about 104.7 m). We create four groups of simulated datasets by contaminating 10% of every trajectory respectively with small, medium, large outliers, and a mixture of the above three. Every contamination version is simulated 100 times for each trajectory. Outliers are added randomly to the original trajectories. We use two metrics for evaluation: FP rate (i.e., false positive or type  error) and FN rate (i.e., false negative or type  error). FP rate is the rate of wrongly detecting normal observations as outliers, while FN rate is the rate of undetected outliers. Shown in Figure 9 are the statistical averages for all 4000 simulations from TRDM and VA + KSC methods under different contamination modes. The VA + KSC methods could detect almost all of the large deviations, but VA1 + KSC could not detect as many as VA2 + KSC does when the outlier magnitudes are medium. Notice that both VA + KSC methods perform poorly for small outliers and outliers of mixture magnitudes. Since we often do not know the actual maximum speed and acceleration, the adoption of VA1 + KSC would only be able to handle large outliers and some medium outliers in practice. On the other hand, the TRDM method never performs worse than the VA + KSC methods (though all working well for large outliers), especially in detecting small and mixture outliers. Moreover, the TRDM method can detect most of the outliers no matter which critical values are set. However, the detection efficiencies of TRDM with critical value r C  3.5 and 4 performed slightly poor for small and mixed contaminated outliers, though they still correctly remove much more outliers than the VA + KSC methods.  We use two metrics for evaluation: FP rate (i.e., false positive or type I error) and FN rate (i.e., false negative or type Π error). FP rate is the rate of wrongly detecting normal observations as outliers, while FN rate is the rate of undetected outliers. Shown in Figure 9 are the statistical averages for all 4000 simulations from TRDM and VA + KSC methods under different contamination modes. The VA + KSC methods could detect almost all of the large deviations, but VA1 + KSC could not detect as many as VA2 + KSC does when the outlier magnitudes are medium. Notice that both VA + KSC methods perform poorly for small outliers and outliers of mixture magnitudes. Since we often do not know the actual maximum speed and acceleration, the adoption of VA1 + KSC would only be able to handle large outliers and some medium outliers in practice. On the other hand, the TRDM method never performs worse than the VA + KSC methods (though all working well for large outliers), especially in detecting small and mixture outliers. Moreover, the TRDM method can detect most of the outliers no matter which critical values are set. However, the detection efficiencies of TRDM with critical value C r = 3.5 and 4 performed slightly poor for small and mixed contaminated outliers, though they still correctly remove much more outliers than the VA + KSC methods. We use two metrics for evaluation: FP rate (i.e., false positive or type  error) and FN rate (i.e., false negative or type  error). FP rate is the rate of wrongly detecting normal observations as outliers, while FN rate is the rate of undetected outliers. Shown in Figure 9 are the statistical averages for all 4000 simulations from TRDM and VA + KSC methods under different contamination modes. The VA + KSC methods could detect almost all of the large deviations, but VA1 + KSC could not detect as many as VA2 + KSC does when the outlier magnitudes are medium. Notice that both VA + KSC methods perform poorly for small outliers and outliers of mixture magnitudes. Since we often do not know the actual maximum speed and acceleration, the adoption of VA1 + KSC would only be able to handle large outliers and some medium outliers in practice. On the other hand, the TRDM method never performs worse than the VA + KSC methods (though all working well for large outliers), especially in detecting small and mixture outliers. Moreover, the TRDM method can detect most of the outliers no matter which critical values are set. However, the detection efficiencies of TRDM with critical value r C  3.5 and 4 performed slightly poor for small and mixed contaminated outliers, though they still correctly remove much more outliers than the VA + KSC methods.  With the decrease of the critical values from C r = 4 to 3.5 and 3, the false negative rates of TRDM decrease while false positive rates increase. It implies that TRDM with a smaller critical value filters out more outliers and more normal data at the same time which agreed with general knowledge. In addition, the false positive rates of TRDM with the smallest critical value of 3 are just a little higher than VA1 + KSC method. It shows that the TRDM method retains most of normal data as the popular VA1 + KSC method. Among the four contamination modes, the mixture outlier mode is the most similar one to the reality. Therefore, loosely speaking, the most aggressive TRDM method (with critical value C r = 3) can reach an average FN rate 9.27 (34.2/3.33−1) times lower than the VA1 + KSC method, while the FP rate is only 0.05 (6.89/6.57−1) times higher, as shown in Figure 9d.
Taking the mixed outliers as an example, Figure 10 shows a snapshot of outlier detection and removing by the VA + KSC and TRDM methods. Thanks to appropriate thresholds, the VA2 + KSC method is able to detect five additional outliers (as shown by black circles in Figure 10a) than the VA1 + KSC method. It is, however, unable to clean less obvious outliers (see Figure 10b). Figure 10c shows that the TRDM method is sensitive in detecting medium and small outliers and removes all outliers in this segment where the VA2 + KSC method fails. This is because that the TRDM method removes the points against the trend rather than some pre-determined features and model, which makes it more effective. As a result, the cleaned trajectory segment using the TRDM method satisfactorily coincides with the ground truth. With the decrease of the critical values from r C  4 to 3.5 and 3, the false negative rates of TRDM decrease while false positive rates increase. It implies that TRDM with a smaller critical value filters out more outliers and more normal data at the same time which agreed with general knowledge. In addition, the false positive rates of TRDM with the smallest critical value of 3 are just a little higher than VA1 + KSC method. It shows that the TRDM method retains most of normal data as the popular VA1 + KSC method. Among the four contamination modes, the mixture outlier mode is the most similar one to the reality. Therefore, loosely speaking, the most aggressive TRDM method (with critical value 3 r C  ) can reach an average FN rate 9.27 (34.2/3.33−1) times lower than the VA1 + KSC method, while the FP rate is only 0.05 (6.89/6.57−1) times higher, as shown in Figure 9d. Taking the mixed outliers as an example, Figure 10 shows a snapshot of outlier detection and removing by the VA + KSC and TRDM methods. Thanks to appropriate thresholds, the VA2 + KSC method is able to detect five additional outliers (as shown by black circles in Figure 10a) than the VA1 + KSC method. It is, however, unable to clean less obvious outliers (see Figure 10b). Figure 10c shows that the TRDM method is sensitive in detecting medium and small outliers and removes all outliers in this segment where the VA2 + KSC method fails. This is because that the TRDM method removes the points against the trend rather than some pre-determined features and model, which makes it more effective. As a result, the cleaned trajectory segment using the TRDM method satisfactorily coincides with the ground truth. In order to determine which critical value ( r C  4, 3.5, or 3) to use in practice, we suggest users to choose a lower one (e.g., 3 r C  ) since a smaller critical value tends to be more restrictive in keeping a potential outlier and only have a small risk of cleaning 'good' data. However, users can adjust this value to meet their own needs. For example, users can choose a larger critical value to retain more points if the number of records in the trajectory is relatively small, or they use robust analysis tools to reduce the influence of small outliers. Finally, we address the time consumption of TRDM ( 3 r C  ) and VA1+KSC. Since the two methods generally remove different numbers of points in a trajectory, the time cost of removing one point will be discussed. The scenario is based on 10 precise trajectories under the mixture outlier contamination mode with each having 100 simulations. With Inter Core i7-4790 CPU, the average times for removing one point for TRDM and VA1 + KSC are respectively 0.68 s and 0.10 s. This shows that TRDM is more time-consuming than VA1 + KSC since TRDM involves matrix inversion which is computationally costly. However, considering TRDM is an offline cleaning method and performs much better than VA1 + KSC, high-performance computing environments will be helpful for TRDM cleaning trajectories. Furthermore, there is a great potential to improve the TRDM implementation since our coding at this time is with Matlab without engineering optimization.

Conclusions
This paper proposed a model-based outlier detection approach to clean trajectories recorded by low-cost GPS. The main procedure of TRDM involved trend extraction and outlier score computation through residuals. To model the trend, we applied the cubic smooth spline to the longitude trajectory and latitude trajectory separately. The residuals of GPS trajectories with reference to the trends were In order to determine which critical value (C r = 4, 3.5, or 3) to use in practice, we suggest users to choose a lower one (e.g., C r = 3) since a smaller critical value tends to be more restrictive in keeping a potential outlier and only have a small risk of cleaning 'good' data. However, users can adjust this value to meet their own needs. For example, users can choose a larger critical value to retain more points if the number of records in the trajectory is relatively small, or they use robust analysis tools to reduce the influence of small outliers.
Finally, we address the time consumption of TRDM (C r = 3) and VA1+KSC. Since the two methods generally remove different numbers of points in a trajectory, the time cost of removing one point will be discussed. The scenario is based on 10 precise trajectories under the mixture outlier contamination mode with each having 100 simulations. With Inter Core i7-4790 CPU, the average times for removing one point for TRDM and VA1 + KSC are respectively 0.68 s and 0.10 s. This shows that TRDM is more time-consuming than VA1 + KSC since TRDM involves matrix inversion which is computationally costly. However, considering TRDM is an offline cleaning method and performs much better than VA1 + KSC, high-performance computing environments will be helpful for TRDM cleaning trajectories. Furthermore, there is a great potential to improve the TRDM implementation since our coding at this time is with Matlab without engineering optimization.

Conclusions
This paper proposed a model-based outlier detection approach to clean trajectories recorded by low-cost GPS. The main procedure of TRDM involved trend extraction and outlier score computation through residuals. To model the trend, we applied the cubic smooth spline to the longitude trajectory and latitude trajectory separately. The residuals of GPS trajectories with reference to the trends were then evaluated by the time series method to determine potential outliers one at a time. All outliers were found through iteration to reach a reliable, outlier-free trajectory.
Unlike other model-based methods such as KSC which face difficulty when modeling GPS trajectories, TRDM extracts the trend of a trajectory adaptively and then models the residuals. As a result, TRDM is able to clean trajectories regardless what kinds of the curves they actually belong to. Compared with various common non-model-based threshold methods, TRDM focuses on removing outliers against the intrinsic consistency of the GPS trajectory rather than some predetermined simple thresholds. Moreover, adaptive parameter estimations are introduced in TRDM and only one critical value C r for outlier scores needs to be set without much difficulty and prior knowledge.
Our experiments showed that TRDM could be applied to various complex GPS trajectories and it performs much better than popular velocity or acceleration threshold methods, especially when small and medium outliers exist. TRDM can yield an average false positive rate 9.27 times better than the conventional VA+KSC method, whereas its false negative is only 0.05 times higher than the VA + KSC method. More importantly, TRDM is able to detect outliers in moving objects that behave 'normal' in velocity or acceleration and 'wander' in a stop-and-go mode even if the recording time intervals are long. The resultant outlier-free trajectories are all closer to the actual trajectories and accord with common sense.
However, there are still some limitations of TRDM method which need to be improved in the future work. First, the window size in this paper is chosen by authors' experiences to balance the speed variation and sufficient number of points to model the time series. A more reasonable adaptive selection method is desired. One may use some trajectory partition approaches (see [36] and references therein) to preprocess trajectories and then apply TRDM to clean the sub-trajectories. Second, the TRDM method may still fail to identify relatively small outliers. This problem may be solved if a digital vector map is incorporated into the TRDM method. Finally, the processing speed of TRDM is slow at this time, since the matrix inversion in trend-residual modeling is computationally costly. It may cause limitations in some time-critical, dynamic cleaning applications.