Quartile: Detection of outliers using quartiles and by comparing with...

QuartileR Documentation

Detection of outliers using quartiles and by comparing with other data in same or previous period.

Description

Detection of outliers using quartiles and by comparing with other data in same or previous period.

Usage

Quartile(
  data,
  id,
  x1,
  y1,
  x2 = NULL,
  y2 = NULL,
  strataName = NULL,
  pKL = 1.5,
  pKU = 1.5
)

Arguments

data

Input of Quartile is a data set of class data.frame.

id

Name of the identification variable.

x1

Name of x variable in period t.

y1

Name of y variable in period t.

x2

Name of x variable in period t-1. Optional

y2

Name of y variable in period t-1. Optional

strataName

Name of the stratification variable. Optional

pKL

Parameter for lower limit.

pKU

Parameter for upper limit.

Value

Output of Quartile is a data set of class data.frame. Only units with both x1 and y1 not missing and greater than zero are included. The variables are:

id

The input identification variable

x1

The input x1 variable

y1

The input y1 variable

x2

The input x2 variable

y2

The input y2 variable

ratio

The ratio between x1 and y1

ratio2

The ratio between x2 and y2

ratioAll

The ratio between the sum of x1 and the sum of y1 aggregated over the whole data set

ratioAll2

The ratio between the sum of x2 and the sum of y2 aggregated over the whole data set

ratioStr

The ratio between the sum of x1 and the sum of y1 aggregated over the stratum

ratioStr2

The ratio between the sum of x2 and the sum of y2 aggregated over the stratum

lowerLimit

The lower limit of the ratio

upperLimit

The upper limit of the ratio

outlier

A binary variable indicating whether the observation is outside the limits [q1 - pKL*(M - q1), q3 + pKU*(q3 - M)]

, where M is the median and q1 and q3 the 1st an 3rd quartile respectively.

strata

Strata name or number

ranking

The rank of ratio. For plotting purposes

Author(s)

Magnar Lillegård

References

Datarevisjon: Kontroll, granskning og retting av data. Anbefalt praksis, Statistisk sentralbyrås håndbøker, 2005/84.

Examples

 minedata <- KostraData("testdata")
 minedata$strata <- as.character(c(rep(1, 61), rep(2, 91), rep(3, 98), rep(4, 81), rep(5, 85)))
 Quartile(data = minedata, id = "Region", x1 = "areal_130_eier_2015", y1 = "areal_130_leier_2015", pKL = 2, pKU = 2)
 Quartile(data = minedata, id = "Region", x1 = "areal_130_eier_2015", y1 = "areal_130_leier_2015", strataName = "strata")
 Quartile(data = minedata, id = "Region", x1 = "areal_130_eier_2015", y1 = "areal_130_leier_2015",
          x2 = "areal_130_eier_2014", y2 = "areal_130_leier_2014", strataName = "strata")

statisticsnorway/Kostra documentation built on Nov. 2, 2024, 6:40 p.m.