Title: | Robust Statistical Methods |
---|---|
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'. |
Authors: | Jonathon Love, Maurizio Agosti, Patrick Mair |
Maintainer: | Jonathon Love <[email protected]> |
License: | GPL-3 |
Version: | 2.0.0 |
Built: | 2024-11-01 04:39:15 UTC |
Source: | https://github.com/jamovi/walrus |
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.
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
Useful links:
Robust Analysis of Variance
ranova( data, dep, factors = NULL, method = "trim", ph = FALSE, tr = 0.2, est = "mom", nboot = 599, dist = "proj" )
ranova( data, dep, factors = NULL, method = "trim", ph = FALSE, tr = 0.2, est = "mom", nboot = 599, dist = "proj" )
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 |
|
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)
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 # ------------------------------------------------------------- #
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
rdesc( data, vars, splitBy = NULL, mean = TRUE, trim = TRUE, tr = 0.2, win = FALSE, wl = 0.2, mest = FALSE, bend = 1.28, med = FALSE )
rdesc( data, vars, splitBy = NULL, mean = TRUE, trim = TRUE, tr = 0.2, win = FALSE, wl = 0.2, mest = FALSE, bend = 1.28, med = FALSE )
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 |
|
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)
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 # ---------------------------------------------------------- #
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
rplots( data, vars, splitBy = NULL, violin = TRUE, boxplot = FALSE, dot = TRUE, dotType = "stack" )
rplots( data, vars, splitBy = NULL, violin = TRUE, boxplot = FALSE, dot = TRUE, dotType = "stack" )
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 |
|
A results object containing:
results$plots |
an array of images | ||||
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)
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
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 )
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 )
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 |
|
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)
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 # --------------------------------------------------------- #
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
rttestPS(data, pairs, tr = 0.2, md = FALSE, es = FALSE, ci = FALSE)
rttestPS(data, pairs, tr = 0.2, md = FALSE, es = FALSE, ci = FALSE)
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 |
|
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)
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 # --------------------------------------------- #
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 # --------------------------------------------- #