outlier.replace: Outlier detection and substitution

Description Usage Arguments Value See Also Examples

View source: R/fun.rav.R

Description

Starting by a previously estimated averaging model, this function detect outliers according to a Bonferroni method. The outliers can be substituted with a user-defined value.

Usage

1
outlier.replace(object, whichModel = NULL, alpha = 0.05, value = NA)

Arguments

object

An object of class 'rav', containing the estimated averaging models.

whichModel

Argument that specifies which of the predicted models has to be compared to the observed data. Options are:

  1. "null": null model

  2. "ESM": equal scale values model

  3. "SAM": simple averaging model

  4. "EAM": equal-weights averaging model

  5. "DAM": differential-weight averaging model

  6. "IC": information criteria

As default setting, the (first) best model is used.

alpha

Critical value for the z-test on residuals.

value

Argument that can be used to set a replacement for the outliers. If a function is specified, it is applied to each column of the final matrix: the resulting value is used to replace outliers detected on the same column.

Value

A data object in which outliers have been removed or replaced.

See Also

rav, rAverage-package,

Examples

1
2
3
4
data(pasta)
model <- rav(pasta, subset="s04", lev=c(3,3), names=c("Price","Packaging"))
outlier.replace(model, value=mean)
outlier.replace(model, whichModel="IC", value=NA)

Example output

Loading required package: tcltk
Parameter Estimation for the Averaging Model of Information
Integration Theory (version 0.5-8)
Warning message:
no DISPLAY variable so Tk is not available 
     Price1 Price2   Price3 Pack1 Pack2    Pack3 Price1.Pack1 Price1.Pack2
1  19.00000     18 17.00000     6    10 9.333333           14            9
2  19.00000     18 17.00000     6    10 9.000000           10           10
3  19.00000     18 17.00000     6     8 9.000000            8           11
13 19.00000     18 17.00000     6    10 9.000000            8           11
14 19.00000     18 17.00000     6     8 9.000000            9           10
15 19.16667     18 16.83333     6     8 9.000000            9            9
   Price1.Pack3 Price2.Pack1 Price2.Pack2 Price2.Pack3 Price3.Pack1
1            17           14            9           18            8
2            17           14           10           14            7
3            14            7           10           14            7
13           14            8            9           17            7
14           18            7           10           14            9
15           14            7           10           14            7
   Price3.Pack2 Price3.Pack3
1      9.000000           10
2      9.000000            9
3      9.166667           10
13     9.000000           14
14     9.000000           14
15     9.000000           10
   Price1 Price2 Price3 Pack1 Pack2 Pack3 Price1.Pack1 Price1.Pack2
1      19     18     17     6    10    NA           14            9
2      19     18     17     6    10     9           10           10
3      19     18     17     6     8     9            8           11
13     19     18     17     6    10     9            8           NA
14     19     18     17     6     8     9            9           10
15     NA     18     NA     6     8     9            9            9
   Price1.Pack3 Price2.Pack1 Price2.Pack2 Price2.Pack3 Price3.Pack1
1            17           14            9           18            8
2            17           14           10           14            7
3            14            7           10           14            7
13           14            8            9           17            7
14           18            7           10           14            9
15           14            7           10           14            7
   Price3.Pack2 Price3.Pack3
1             9           10
2             9            9
3            NA           10
13            9           14
14            9           14
15            9           10

rAverage documentation built on May 2, 2019, 6:40 a.m.