VINOD@FORDHAM.EDU
2005-Sep-18 19:37 UTC
[R] trimmed mean in R seems to round the trimming fraction
subject: trimmed mean in R seems to round the trimming fraction to r-help at stat.math.ethz.ch. Consider the following example of 10 numbers. 10% trimmed mean is correct but you can see that the result is the same for many trimming fractions till 0.20! For example 13% trimmed mean should use interpolation of second and eighth ordered observation. R does not seem to do this. The correct 13% trimmed mean is the average of 7.4 middle observations (28+46+50+52+54+63+82+64.4)/7.4 Answer=(439.4)/7.4= 59.3784> z=c(23, 40, 46, 50, 52, 54, 63, 82,92,98) > mean(z, trim=0.10)[1] 59.875> mean(z, trim=0.13) # wrong result is 59.875[1] 59.875> mean(z, trim=0.15)[1] 59.875> mean(z, trim=0.18)[1] 59.875> mean(z, trim=0.1999999)[1] 59.875> mean(z, trim=0.20)[1] 57.83333> mean(z, trim=0.40)[1] 53 Hrishikesh D. Vinod Professor of Economics, Fordham University E-Mail: Vinod at fordham.edu Tel 718-817-4065, Secretary 718-817-4048, Fax 718-817-3518 Web page: http://www.fordham.edu/economics/vinod
Sundar Dorai-Raj
2005-Sep-18 20:11 UTC
[R] trimmed mean in R seems to round the trimming fraction
VINOD at FORDHAM.EDU wrote:> > > subject: trimmed mean in R seems to round the trimming fraction > to r-help at stat.math.ethz.ch. > > Consider the following example of 10 numbers. 10% trimmed mean is correct > but you can see that the result is the same for many trimming fractions > till 0.20! > > For example 13% trimmed mean should use interpolation of second and > eighth ordered observation. R does not seem to do this. > The correct 13% trimmed mean is the average of 7.4 middle observations > (28+46+50+52+54+63+82+64.4)/7.4 > Answer=(439.4)/7.4= 59.3784 > > > >>z=c(23, 40, 46, 50, 52, 54, 63, 82,92,98) >>mean(z, trim=0.10) > > [1] 59.875 > >>mean(z, trim=0.13) # wrong result is 59.875 > > [1] 59.875 > >>mean(z, trim=0.15) > > [1] 59.875 > >>mean(z, trim=0.18) > > [1] 59.875 > >>mean(z, trim=0.1999999) > > [1] 59.875 > >>mean(z, trim=0.20) > > [1] 57.83333 > >>mean(z, trim=0.40) > > [1] 53 > >Hi, The "trim" argument works as documented. Did you read ?mean: If 'trim' is non-zero, a symmetrically trimmed mean is computed with a fraction of 'trim' observations deleted from each end before the mean is computed. Also, I don't recall ever learning your method for trimmed mean, but R is a programming language and you can always write your own trimmed mean function. HTH, --sundar
Maybe Matching Threads
- configuring Dovecot with wforced and auth_policy_server_url with https results in assertion failed
- configuring Dovecot with wforced and auth_policy_server_url with https results in assertion failed
- SPSS Statistics-R Integration Plug-In
- makeSOCKcluster
- Playing captured speex frames