Re: [R] Winsorized mean and variance
Roberto Perdisci wrote: Hello everybody, after searching around for quite some time, I haven't been able to find a package that provides a function to compute the Windorized mean and variance. Also I haven't found a function that computes the trimmed variance. Is there any such package around? Hi Roberto, The Winsorized variance is similar to the trimmed variance, except that the extreme values are substituted rather than dropped. Define the quantiles within which you want to retain the original values and then substitute the values at the quantiles for all values more extreme in the respective sign direction. Like this: testdat-rnorm(20) winsorVar-function(x,probs=c(0.05,0.95)) { xq-quantile(x,probs=probs) x[x xq[1]]-xq[1] x[x xq[2]]-xq[2] return(var(x)) } Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Winsorized mean and variance
This is of great help, thanks! Roberto On Thu, Aug 27, 2009 at 7:20 AM, Jim Lemonj...@bitwrit.com.au wrote: Roberto Perdisci wrote: Hello everybody, after searching around for quite some time, I haven't been able to find a package that provides a function to compute the Windorized mean and variance. Also I haven't found a function that computes the trimmed variance. Is there any such package around? Hi Roberto, The Winsorized variance is similar to the trimmed variance, except that the extreme values are substituted rather than dropped. Define the quantiles within which you want to retain the original values and then substitute the values at the quantiles for all values more extreme in the respective sign direction. Like this: testdat-rnorm(20) winsorVar-function(x,probs=c(0.05,0.95)) { xq-quantile(x,probs=probs) x[x xq[1]]-xq[1] x[x xq[2]]-xq[2] return(var(x)) } Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Winsorized mean and variance
Roberto, Try winsor in the psych package. Bill At 10:21 AM -0400 8/27/09, Roberto Perdisci wrote: This is of great help, thanks! Roberto On Thu, Aug 27, 2009 at 7:20 AM, Jim Lemonj...@bitwrit.com.au wrote: Roberto Perdisci wrote: Hello everybody, after searching around for quite some time, I haven't been able to find a package that provides a function to compute the Windorized mean and variance. Also I haven't found a function that computes the trimmed variance. Is there any such package around? Hi Roberto, The Winsorized variance is similar to the trimmed variance, except that the extreme values are substituted rather than dropped. Define the quantiles within which you want to retain the original values and then substitute the values at the quantiles for all values more extreme in the respective sign direction. Like this: testdat-rnorm(20) winsorVar-function(x,probs=c(0.05,0.95)) { xq-quantile(x,probs=probs) x[x xq[1]]-xq[1] x[x xq[2]]-xq[2] return(var(x)) } Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Use R for psychology http://personality-project.org/r It is 5 minutes to midnight http://www.thebulletin.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Winsorized mean and variance
On Aug 26, 2009, at 8:58 PM, Roberto Perdisci wrote: Hello everybody, after searching around for quite some time, I haven't been able to find a package that provides a function to compute the Windorized mean and variance. Also I haven't found a function that computes the trimmed variance. Is there any such package around? Perhaps it was a spledding problem? http://search.r-project.org/cgi-bin/namazu.cgi?query=winsorizedmax=100result=normalsort=scoreidxname=functionsidxname=Rhelp08idxname=viewsidxname=Rhelp02 If you can define what you mean by trimmed variance, I suspect that building a function would be straightforward. thanks, Roberto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.