Danielle Navarro issues a clear warning: dplyr::ntile() is a SQL-derived convenience that does not perform genuine quantile binning and should not be used where statistical accuracy matters, especially in regulatory submissions. The function implements an equal-count tiling inherited from SQL and relies on row order, so it can produce bins that split tied values arbitrarily rather than grouping identical measurements together. Because real data often contain ties (for example, weights recorded to one decimal place), ntile()’s behavior can create misleading strata and biased summaries when analysts expect true quantile-based groups.
To demonstrate, a fabricated exposure-response data set common in pharmacometrics is used where wt_kg is rounded to 0.1 kg and many subjects share the same value (14 of 175 rows at the median). Applying mutate(wt_bin = factor(ntile(wt_kg, n = 4))) produces weight bins that cut through these ties and reflect row ordering (study, dose, subject) rather than value-based quantiles. The remedy is to compute explicit quantile cutpoints or use functions that respect ties (e.g., cut or findInterval on quantiles) so identical measurements remain in the same bin. The root cause is SQL convention, not a statistical tool, and ntile() is unsuitable for rigorous analysis.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.