| Type: | Package | 
| Title: | Robust Statistical Methods | 
| Version: | 1.0.5 | 
| Date: | 2022-09-07 | 
| Author: | Jonathon Love, Patrick Mair | 
| Maintainer: | Jonathon Love <jon@thon.cc> | 
| Description: | A toolbox of common robust statistical tests, including robust descriptives, robust t-tests, and robust ANOVA. It is also available as a module for 'jamovi' (see https://www.jamovi.org for more information). Walrus is based on the WRS2 package by Patrick Mair, which is in turn based on the scripts and work of Rand Wilcox. These analyses are described in depth in the book 'Introduction to Robust Estimation & Hypothesis Testing'. | 
| License: | GPL-3 | 
| Encoding: | UTF-8 | 
| Imports: | WRS2, ggplot2, jmvcore (≥ 2.2), R6 | 
| Suggests: | MASS | 
| URL: | https://github.com/jamovi/walrus | 
| BugReports: | https://github.com/jamovi/walrus/issues | 
| RoxygenNote: | 6.1.1 | 
| NeedsCompilation: | no | 
| Packaged: | 2022-09-08 02:54:49 UTC; c3113592 | 
| Repository: | CRAN | 
| Date/Publication: | 2022-09-08 03:50:02 UTC | 
Walrus
Description
A toolbox of common robust statistical tests, including robust
descriptives, robust t-tests, and robust ANOVA. It is also available as a
module for 'jamovi' (see www.jamovi.org for
more information).
Walrus is based on the WRS2 package by Patrick Mair, which is in turn based on
the scripts and work of Rand Wilcox. These analyses are described in depth in
the book Introduction to Robust Estimation & Hypothesis Testing.
Details
| Box & Violin Plots | rplots() | |||
| Robust Descriptives | rdesc() | |||
| Robust Independent Samples T-Test | rttestIS() | |||
| Robust Paired Samples T-Test | rttestIS() | |||
| Robust ANOVA | ranova() | |||
Ravi:
    "Should we create a logo for walrus?"
Jonathon:
    "Yeah, I guess. Maybe a walrus, or a
    skewed distribution?
    Bonus points if it somehow contains both."
Ravi gets bonus points
See Also
Useful links:
Robust ANOVA
Description
Robust Analysis of Variance
Usage
ranova(
  data,
  dep,
  factors = NULL,
  method = "trim",
  ph = FALSE,
  tr = 0.2,
  est = "mom",
  nboot = 599,
  dist = "proj"
)
Arguments
| data | the data as a data frame | 
| dep | a string naming the dependent variable from  | 
| factors | a vector of strings naming the fixed factors from
 | 
| method | 
 | 
| ph | 
 | 
| tr | a number between 0 and 0.5, (default: 0.2), the proportion of measurements to trim from each end, when using the trim and bootstrap methods | 
| est | 
 | 
| nboot | a number (default: 599) specifying the number of bootstrap samples to use when using the bootstrap method | 
| dist | 
 | 
Value
A results object containing:
| results$main | the table of ANOVA results | ||||
| results$phs | the table of posthoc tests | ||||
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$main$asDF
as.data.frame(results$main)
Examples
data('goggles', package='WRS2')
ranova(goggles,
       dep = 'attractiveness',
       factors = c('gender', 'alcohol'),
       ph = TRUE)
#
#  ROBUST ANOVA
#
#  Robust ANOVA
#  ------------------------------------
#                      Q        p
#  ------------------------------------
#    gender             1.67    0.209
#    alcohol           48.28    0.001
#    gender:alcohol    26.26    0.001
#  ------------------------------------
#   Note. Method of trimmed means,
#   trim level 0.2
#
#
#  POST HOC TESTS
#
#  Post Hoc Tests - gender
#  --------------------------------------------------------
#                       psi-hat   p        Lower    Upper
#  --------------------------------------------------------
#    Female    Male     10.0      0.209    -6.00    26.0
#  --------------------------------------------------------
#
#
#  Post Hoc Tests - alcohol
#  -------------------------------------------------------------
#                           psi-hat   p         Lower    Upper
#  -------------------------------------------------------------
#    None       2 Pints     -3.33      0.611    -20.5     13.8
#    None       4 Pints     35.83     < .001     19.3     52.3
#    2 Pints    4 Pints     39.17     < .001     22.5     55.9
#  -------------------------------------------------------------
#
Robust Descriptives
Description
Robust Descriptives
Usage
rdesc(
  data,
  vars,
  splitBy = NULL,
  mean = TRUE,
  trim = TRUE,
  tr = 0.2,
  win = FALSE,
  wl = 0.2,
  mest = FALSE,
  bend = 1.28,
  med = FALSE
)
Arguments
| data | the data as a data frame | 
| vars | a vector of strings naming the variables in  | 
| splitBy | a string naming the variable in  | 
| mean | 
 | 
| trim | 
 | 
| tr | a number between 0 and 0.5 (default: 0.2); the proportion of measurements to trim from each end when producing trimmed means | 
| win | 
 | 
| wl | a number between 0 and 0.5 (default: 0.2); the level of 'winsorizing' when producing winsorized means | 
| mest | 
 | 
| bend | a number (default: 1.28), the bending constant to use when using M-estimators | 
| med | 
 | 
Value
A results object containing:
| results$table | the table of descriptives | ||||
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$table$asDF
as.data.frame(results$table)
Examples
data('eurosoccer', package='WRS2')
SpainGermany <- subset(eurosoccer, eurosoccer$League == 'Spain' | eurosoccer$League == 'Germany')
SpainGermany <- droplevels(SpainGermany)
walrus::rdesc(
    data = SpainGermany,
    vars = "GoalsGame",
    splitBy = "League",
    med = TRUE)
#
#  ROBUST DESCRIPTIVES
#
#  Robust Descriptives
#  ----------------------------------------------------------
#                                                    SE
#  ----------------------------------------------------------
#    GoalsGame    Germany    Mean            1.46     0.105
#                            Trimmed mean    1.45    0.1341
#                            Median          1.43    0.1599
#
#                 Spain      Mean            1.45     0.101
#                            Trimmed mean    1.33    0.0601
#                            Median          1.30    0.0766
#  ----------------------------------------------------------
#
Box & Violin Plots
Description
Box & Violin Plots
Usage
rplots(
  data,
  vars,
  splitBy = NULL,
  violin = TRUE,
  boxplot = FALSE,
  dot = TRUE,
  dotType = "stack"
)
Arguments
| data | the data as a data frame | 
| vars | a vector of strings naming the variables in  | 
| splitBy | a string naming the variable in  | 
| violin | 
 | 
| boxplot | 
 | 
| dot | 
 | 
| dotType | 
 | 
Value
A results object containing:
| results$plots | an array of images | ||||
Examples
data('eurosoccer', package='WRS2')
# violin plots
walrus::rplots(
    data = eurosoccer,
    vars = "GoalsGame",
    splitBy = "League")
# box plots
walrus::rplots(
    data = eurosoccer,
    vars = "GoalsGame",
    splitBy = "League",
    violin = FALSE,
    boxplot = TRUE,
    dot = FALSE)
Robust Independent Samples T-Test
Description
Robust Independent Samples T-Test
Usage
rttestIS(
  data,
  deps,
  group,
  yuen = TRUE,
  tr = 0.2,
  mest = FALSE,
  method = "mom",
  yuenbt = FALSE,
  nboot = 599,
  md = FALSE,
  ci = FALSE,
  es = FALSE,
  esci = FALSE
)
Arguments
| data | the data as a data frame | 
| deps | a vector of strings naming the dependent variables in
 | 
| group | a string naming the grouping variable in  | 
| yuen | 
 | 
| tr | a number between 0 and 0.5, (default: 0.2), the proportion of measurements to trim from each end, when using the trim and bootstrap methods | 
| mest | 
 | 
| method | 
 | 
| yuenbt | 
 | 
| nboot | a number (default: 599) specifying the number of bootstrap samples to use when using the bootstrap method | 
| md | 
 | 
| ci | 
 | 
| es | 
 | 
| esci | 
 | 
Value
A results object containing:
| results$ttest | the table of t-test results | ||||
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$ttest$asDF
as.data.frame(results$ttest)
Examples
data('eurosoccer', package='WRS2')
SpainGermany <- subset(eurosoccer, eurosoccer$League == 'Spain' | eurosoccer$League == 'Germany')
SpainGermany <- droplevels(SpainGermany)
rttestIS(SpainGermany,
         dep = 'GoalsScored',
         group = 'League',
         yuen = TRUE,
         mest = TRUE)
#
#  ROBUST INDEPENDENT SAMPLES T-TEST
#
#  Robust Independent Samples T-Test
#  ---------------------------------------------------------
#                                  t         df      p
#  ---------------------------------------------------------
#    GoalsScored    Yuen's test     0.297    17.3    0.770
#                   M-estimator    -0.933            0.993
#  ---------------------------------------------------------
#
Robust Paired Samples T-Test
Description
Robust Paired Samples T-Test
Usage
rttestPS(data, pairs, tr = 0.2, md = FALSE, es = FALSE, ci = FALSE)
Arguments
| data | the data as a data frame | 
| pairs | a list of lists specifying the pairs of measurement in
 | 
| tr | a number between 0 and 0.5, (default: 0.2), the proportion of measurements to trim from each end, when using the trim and bootstrap methods | 
| md | 
 | 
| es | 
 | 
| ci | 
 | 
Value
A results object containing:
| results$ttest | the table of t-test results | ||||
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$ttest$asDF
as.data.frame(results$ttest)
Examples
data(anorexia, package='MASS')
anorexiaFT <- subset(anorexia, subset = Treat == "FT")
rttestPS(anorexiaFT,
         pairs = list(
             list(i1 = 'Prewt', i2 = 'Postwt')))
#
#  ROBUST PAIRED SAMPLES T-TEST
#
#  Robust Paired Samples T-Test
#  ---------------------------------------------
#                       t        df      p
#  ---------------------------------------------
#    Prewt    Postwt    -3.83    10.0    0.003
#  ---------------------------------------------
#