Statistics function incorrectly computing median
Ben Abbott
bpabbott at mac.com
Sun Jan 27 09:49:39 CST 2008
On Jan 27, 2008, at 7:57 AM, Miguel Garcia-Blanco wrote:
>> I struggled quite a bit with #3. To be honest, I had little hope it
>> was working properly. The part below was added to obtain agreement
>> with R in several cases.
>>
>> --------------------------------------------
>> ----- from __quantile__.m, lines 92:96 -----
>> --------------------------------------------
>> if (x(k(q)) <= 0.5)
>> inv(k(q)) = v(find(dx == min(dx), 1, "first"));
>> else
>> inv(k(q)) = v(find(dx == min(dx), 1, "last"));
>> endif
>> --------------------------------------------
>>
>> I'm skeptical that part should be there. Any idea on what the proper
>> algorithm for #3 might look like?
>
> I found the R help to be ambiguous, so I went to the SAS website and
> found
> an appropriate help page
> (http://support.sas.com/onlinedoc/913/getDoc/en/statug.hlp/stdize_sect14.htm
> ).
> I've crudely coded up SAS method PCTLDEF=2 and it seems to work (but
> it's
> not in anyway optimised).
>
> -Miguel
> <quant3.m>
Thanks Miguel, you script was very helpful.
I've modified the algorithm to be consistent with the other cases, and
the results remain consistent with yours.
I've attached the three new functions (__quantile__.m, quantile.m, &
prctile.m), as well as the modified statistics.m.
If there are no other problems, I'll generate a patch.
Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: __quantile__.m
Type: application/octet-stream
Size: 4954 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080127/b063c537/attachment-0004.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prctile.m
Type: application/octet-stream
Size: 4412 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080127/b063c537/attachment-0005.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quantile.m
Type: application/octet-stream
Size: 8829 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080127/b063c537/attachment-0006.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: statistics.m
Type: application/octet-stream
Size: 2639 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080127/b063c537/attachment-0007.obj
More information about the Bug-octave
mailing list