devtools::load_all()
library(MathematicaVsRData)
library(OutlierIdentifiers)

Quantile Regression fit

qrObj <- 
  QRMonUnit( dfTemperatureData ) %>% 
  QRMonQuantileRegression( df = 12, probabilities = 0.5 ) %>% 
  QRMonPlot( datePlotQ = TRUE ) %>% 
  QRMonErrorsPlot( relativeErrorsQ = FALSE )

By threshold

dfOutliers1 <- 
  qrObj %>% 
  QRMonFindAnomaliesByResiduals( threshold = 5, relativeErrorsQ = FALSE ) %>% 
  QRMonTakeValue
ggplot(dfTemperatureData) +
  geom_point( aes( x = Time, y = Temperature ), color = "gray" ) +
  geom_point( data = dfOutliers1, aes( x = Regressor, y = Value ), color = "red" )

By outlier identifiers

dfOutliers2 <- 
  qrObj %>% 
  QRMonFindAnomaliesByResiduals( threshold = NULL, 
                                 #outlierIdentifier = function(x) TopOutlierPosition( x, identifier = SPLUSQuartileIdentifierParameters ), 
                                 outlierIdentifier = NULL,
                                 relativeErrorsQ = FALSE ) %>% 
  QRMonTakeValue
ggplot(dfTemperatureData) +
  geom_point( aes( x = Time, y = Temperature ), color = "gray" ) +
  geom_point( data = dfOutliers2, aes( x = Regressor, y = Value ), color = "red" )


antononcube/QRMon-R documentation built on July 26, 2021, 1:07 p.m.