September 16, 2013 Filed in: R | Statistics

Today a new version (0.23.1) of the WRS package (Wilcox’ Robust Statistics) has been released. This package is the companion to his rather exhaustive book on robust statistics, “Introduction to Robust Estimation and Hypothesis Testing” (Amazon Link de/us).

For a fail-safe installation of the package, follow this instruction.

As a guest post, Rand Wilcox describes the new functions of the newest WRS version – have fun!

“Hi everyone,

As you probably know, when standard assumptions are violated, classic methods for comparing groups and studying associations can have very poor power and yield highly misleading results. The better known methods for dealing with these problem (transforming the data or testing assumptions) are ineffective compared to more modern methods. Simply removing outliers among the dependent variable and applying standard techniques to the remaining data is disastrous.

Methods I derive to deal with these problems can be applied with R functions stored in an R package (WRS) maintained by Felix Schönbrodt. Felix asked me to briefly describe my recent efforts for a newsletter he posts. In case this might help some of you, a brief description of my recently developed methods and corresponding R functions are provided below. (The papers I cite illustrate that they can make a substantial difference compared to extant techniques.)

Sometimes it can be important and more informative to compare the tails (upper and lower quantiles) of two groups rather than a measure of location that is centrally located. Example: have been involved in a study aimed at determining whether intervention reduced depressive symptoms. But the typical individual was not very depressed prior to intervention and no difference is found using the more obvious techniques. Simply ignoring the less depressed individuals results in using the wrong standard error – a very serious problem. But comparing quantiles, it was found that the more depressed individuals benefitted the most from intervention.

The new method beats the shift function. See

Wilcox, R. R., Erceg-Hurn, D., Clark, F. & Carlson, M. (2013). Comparing two independent groups via the lower and upper quantiles. Journal of Statistical Computation and Simulation. DOI: 10.1080/00949655.2012.754026

Use the R function `qcomhd`

.

For **dependent groups** must use another method. There are, in fact, two distinct ways of viewing the problem. See

Wilcox, R. R. & Erceg-Hurn, D. (2012). Comparing two dependent groups via quantiles. Journal of Applied Statistics, 39, 2655–2664.

Use the R function `Dqcomhd`

.

When comparing two groups based on a Likert scale, use the function `disc2com`

.

It performs a global test of P(X=x)=P(Y=x) for all x using a generalization of the Storer–Kim method for comparing binomials.

`binband`

: a multiple comparison method for the individual cell probabilities.

`tshdreg`

: This is a modification of the Theil–Sen estimator. When there are tied values among the dependent variable, this modification might result in substantially higher power. A paper (Wilcox & Clark, in press) provides details. The function `tsreg`

now checks whether there are any tied values and prints a message suggesting that you might want to use `tshdreg`

instead.

`qhdsm`

: A quantile regression smoother. That is, plot the regression line when predicting some quantile without specifying a parametric form for the regression line. Multiple quantile regression lines can be plotted. The method can be more satisfactory than using the function `qsmcobs`

(a spline-type method), which often creates waves and curvature that give an incorrect sense of the association. Another advantage of `qhsdm`

is that it can be used with more than one predictor; `qsmcobs`

is limited to one predictor only. The strategy behind `qhdsm`

is to get an initial approximation of the regression line using a running interval smoother in conjunction with the Harrell–Davis quantile estimator and then smoothed again via LOESS.

It is surprising how often an association is found when dealing with the higher and lower quantiles of the dependent variable that are not detected by least squares and other robust estimators.

`qhdsm2g`

: Plots regression lines for two groups using the function `qhdsm`

.

`rplot`

has been updated: setting the argument `LP=TRUE`

gives a smoother regression line.

`rplotCI`

. Same as `rplot`

but includes lines indicating a confidence interval for the predicted Y values

`rplotpbCI`

. Same as `rplotCI`

, only use a bootstrap method to compute confidence intervals.

`ancJN`

: The function fits a robust regression line for each group and then determines whether the predicted Y values differ significantly at specified points. So it has connections to the classic Johnson-Neyman method. That is, the method provides an indication of where the regression lines cross. Both types of heteroscedasticity are allowed, which can result in improved power beyond the improved power stemming from a robust estimator. See

Wilcox, R. R. (2013). A heteroscedastic method for comparing regression lines at specified design points when using a robust regression estimator. Journal of Data Science, 11, 281–291

`anctspb`

: Like `ancJN`

but uses a percentile bootstrap method that might help when there are tied values among the dependent variable.

`ancGLOB`

. A robust global ANCOVA method. Like the function ancova, it provides a flexible way of dealing with curvature and heteroscedasticity is allowed. But this function can reject in situations where ancova does not reject. The function returns a p-value and the hypothesis of identical regression lines is rejected if the p-value is less than or equal to a critical p-value. In essence, it can beat reliance on improved versions of the Bonferroni method. (Details are in a paper submitted for publication.) It does not dominate my original ANCOVA method (applied with the R function `ancova`

) in terms of power, but have encountered situations where it makes a practical difference.

It determines a critical p-value via the R function `ancGLOB_pv`

.

In essence, simulations are used. By default, the number of replications is `iter=500`

. But suggest using `iter=2000`

or larger. Execution time can be reduced substantially with `cpp=TRUE`

, which calls a C++ version of the function written by Xiao He. Here are the commands to install the C++ version:

For a global test that two parametric regression lines are identical, see

Wilcox, R. R. & Clark, F. (in press). Heteroscedastic global tests that the regression parameters for two or more independent groups are identical. Communications in Statistics– Simulation and Computation.

`ancGpar`

performs the robust method. The paper includes a different method when using least squares regression. It is based in part on the HC4 estimator, which deals with heteroscedasticity. But if there are outliers among the dependent variable, you are much better off using a robust estimator.

`Dancova`

: ANCOVA for two dependent groups that provides a flexible way of dealing with curvature. Both types of heteroscedasticity are allowed. Roughly, approximate the regression lines with a running interval smoother and at specified design points compare the regression lines. This is an extension of the R function `ancova`

to dependent groups. The function can do an analysis on either the marginal measures of location or a measure of location based on the difference scores. When using a robust estimator, the choice between these two approaches can be important. Defaults to using a trimmed mean.

`Dancovamp`

: Like `Dancova`

only designed to handle multiple covariates.

`Danctspb`

: Compare regression lines of two dependent groups using a robust regression estimator. The default is to use Theil–Sen, but any estimator can be used via the argument regfun. So in contrast to `Dancova`

, a parametric form for the regression line is made. As usual, can eliminate outliers among the independent variable by setting the argument `xout=TRUE`

. When a parametric regression line provides a more accurate fit, can have more power compared to using a smoother. But when there is curvature that is not modeled well with a parametric fit, the reverse can happen.

Note: a version of `ancGLOB`

for dependent groups is being studied.

`Rcoefalpha`

: computes a robust analog of coefficient alpha. Developed this method some years ago but just got around to writing an R function. See

Wilcox, R. R. (1992). Robust generalizations of classical test reliability and Cronbach’s alpha. British Journal of Mathematical and Statistical Psychology, 45, 239–254.

*R. R. Wilcox*”

Have fun exploring these new methods!

Thank you so much for this post. Very informative. I just wish we could have better documentation on WRS so that it could also be more easily installed (I always struggle installing all dependencies in RStudio). Regardless, your work is remarkable and I hope more and more people are exposed to this package and your publications.

[…] FelixS Today a new version (0.23.1) of the WRS package (Wilcox’ Robust Statistics) has been […]

[…] Wilcox pioneered in developing many robust methods (see, for example, this blog post by him), and the methods are implemented in the WRS package for R (Wilcox & Schönbrodt, […]

Hi,

I found this post extremely useful. I would really like to get some more information on the ‘binband’ function which does exactly what I needed. Is it described anywhere?

Thank you so much for this great resource!

-Ilja

Generally, you should consult Rand Wilcox’ books for information about the functions – or maybe contact him by email?