Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue calculating medians in gegen pctile and gcollapse w/ small groups #38

Closed
mdroste opened this issue May 1, 2018 · 1 comment
Closed
Assignees
Labels

Comments

@mdroste
Copy link

mdroste commented May 1, 2018

Medians appear to be calculated wrong in at least this simple case:

clear all
set obs 3
gen x = 1
replace x = 3 in 2
replace x = 5 in 3
egen med_egen = pctile(x), p(50)
gegen med_gegen = pctile(x), p(50)
list

The same problem also emerges in gcollapse:

clear all
set obs 3
gen x = 1
replace x = 3 in 2
replace x = 5 in 3
tempfile t1
save `t1'
collapse (p50) x
list
use `t1', clear
gcollapse (p50) x
list
@mdroste mdroste changed the title Serious issue w/ p50 in gegen pctile and gcollapse Issue calculating medians in gegen pctile and gcollapse w/ small groups May 1, 2018
@mcaceresb mcaceresb self-assigned this May 2, 2018
@mcaceresb mcaceresb added the bug label May 2, 2018
@mcaceresb
Copy link
Owner

This is fixed in the develop branch. See changelog.md for details. Will merge to master soon.

mcaceresb added a commit that referenced this issue May 2, 2018
Pending

- For now, throws error for strL variable; see
  #39

Plugin version 2.0 makes no mention of strL variables; however, plugin
version 3.0 notes that they are actually not supported by the macros
that I use to access strings. I think I'll have to compile a sepparate
version of the plugin for Stata 13 and Stata 14 and above. The Stata
13 version will throw an error for strL variables. This is currently
the only version until I figure out where to test Stata 14 and how to
implement this switch.

Bug fixes

- Fixes #38

When the quantile requested was N - 1 out of an array of length N, I
makde an exception so the function picked up the largest value, instead
of passing N - 1 to the selection algorithm. However, I made a mistake
and quantiles between 100 - 150 / N and 100 - 100 / N, left-inclusive
right-exclusive, would give the wrong quantile.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants