Use the trim function to remove outliers from a data set before processing the data set.
1. Define a dataset that describes the heatflow.
2. Detect outliers using the Grubbs function.
3. Create a vector containing the indices of the outliers.
4. Assign a number to each row of the y data set.
5. Remove the outliers.
The datanew array has fewer rows than the original data sets:
6. Plot the original and the trimmed data sets.
When outliers are expected to skew the results, they can be removed to improve the results. For the heatflow data:
The mean remains almost the same with or without outliers in the data, but the standard deviation decreases. This change strongly affects models of the data.