New robust statistical functions in WRS package – Guest post by Rand Wilcox
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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.)
Comparing groups:
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 [cci]qcomhd[/cci].
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 [cci]Dqcomhd[/cci].
When comparing two groups based on a Likert scale, use the function [cci]disc2com[/cci].
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.
[cci]binband[/cci]: a multiple comparison method for the individual cell probabilities.
Regression:
[cci]tshdreg[/cci]: 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 [cci]tsreg[/cci] now checks whether there are any tied values and prints a message suggesting that you might want to use [cci]tshdreg[/cci] instead.
[cci]qhdsm[/cci]: 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 [cci]qsmcobs[/cci] (a spline-type method), which often creates waves and curvature that give an incorrect sense of the association. Another advantage of [cci]qhsdm[/cci] is that it can be used with more than one predictor; [cci]qsmcobs[/cci] is limited to one predictor only. The strategy behind [cci]qhdsm[/cci] 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.
[cci]qhdsm2g[/cci]: Plots regression lines for two groups using the function [cci]qhdsm[/cci].
[cci]rplot[/cci] has been updated: setting the argument [cci]LP=TRUE[/cci] gives a smoother regression line.
[cci]rplotCI[/cci]. Same as [cci]rplot[/cci] but includes lines indicating a confidence interval for the predicted Y values
[cci]rplotpbCI[/cci]. Same as [cci]rplotCI[/cci], only use a bootstrap method to compute confidence intervals.
ANCOVA or comparing regression lines associated with independent groups:
[cci]ancJN[/cci]: 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
[cci]anctspb[/cci]: Like [cci]ancJN[/cci] but uses a percentile bootstrap method that might help when there are tied values among the dependent variable.
[cci]ancGLOB[/cci]. 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 [cci]ancova[/cci]) in terms of power, but have encountered situations where it makes a practical difference.
It determines a critical p-value via the R function [cci]ancGLOB_pv[/cci].
In essence, simulations are used. By default, the number of replications is [cci]iter=500[/cci]. But suggest using [cci]iter=2000[/cci] or larger. Execution time can be reduced substantially with [cci]cpp=TRUE[/cci], which calls a C++ version of the function written by Xiao He. Here are the commands to install the C++ version:
[cc lang=”rsplus” escaped=”true”]
install.packages(‘devtools’)
library(‘devtools’)
install_github(‘WRScpp’, ‘mrxiaohe’)
[/cc]
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.
[cci]ancGpar[/cci] 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.
ANCOVA or comparing regression lines associated with dependent groups:
[cci]Dancova[/cci]: 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 [cci]ancova[/cci] 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.
[cci]Dancovamp[/cci]: Like [cci]Dancova[/cci] only designed to handle multiple covariates.
[cci]Danctspb[/cci]: 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 [cci]Dancova[/cci], a parametric form for the regression line is made. As usual, can eliminate outliers among the independent variable by setting the argument [cci]xout=TRUE[/cci]. 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 [cci]ancGLOB[/cci] for dependent groups is being studied.
Coefficient alpha
[cci]Rcoefalpha[/cci]: 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!
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.