quantile function - RDocumentation (2024)

Description

The generic function quantile produces sample quantiles corresponding to the given probabilities. The smallest observation corresponds to a probability of 0 and the largest to a probability of 1.

Usage

quantile(x, …)

# S3 method for defaultquantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type = 7, …)

Arguments

x

numeric vector whose sample quantiles are wanted, or an object of a class for which a method has been defined (see also ‘details’). NA and NaN values are not allowed in numeric vectors unless na.rm is TRUE.

probs

numeric vector of probabilities with values in \([0,1]\). (Values up to 2e-14 outside that range are accepted and moved to the nearby endpoint.)

na.rm

logical; if true, any NA and NaN's are removed from x before the quantiles are computed.

names

logical; if true, the result has a names attribute. Set to FALSE for speedup with many probs.

type

an integer between 1 and 9 selecting one of the nine quantile algorithms detailed below to be used.

further arguments passed to or from other methods.

Types

quantile returns estimates of underlying distribution quantiles based on one or two order statistics from the supplied elements in x at probabilities in probs. One of the nine quantile algorithms discussed in Hyndman and Fan (1996), selected by type, is employed.

All sample quantiles are defined as weighted averages of consecutive order statistics. Sample quantiles of type \(i\) are defined by: $$Q_{i}(p) = (1 - \gamma)x_{j} + \gamma x_{j+1}$$ where \(1 \le i \le 9\), \(\frac{j - m}{n} \le p < \frac{j - m + 1}{n}\), \(x_{j}\) is the \(j\)th order statistic, \(n\) is the sample size, the value of \(\gamma\) is a function of \(j = \lfloor np + m\rfloor\) and \(g = np + m - j\), and \(m\) is a constant determined by the sample quantile type.

Discontinuous sample quantile types 1, 2, and 3

For types 1, 2 and 3, \(Q_i(p)\) is a discontinuous function of \(p\), with \(m = 0\) when \(i = 1\) and \(i = 2\), and \(m = -1/2\) when \(i = 3\).

Type 1

Inverse of empirical distribution function. \(\gamma = 0\) if \(g = 0\), and 1 otherwise.

Type 2

Similar to type 1 but with averaging at discontinuities. \(\gamma = 0.5\) if \(g = 0\), and 1 otherwise.

Type 3

SAS definition: nearest even order statistic. \(\gamma = 0\) if \(g = 0\) and \(j\) is even, and 1 otherwise.

Continuous sample quantile types 4 through 9

For types 4 through 9, \(Q_i(p)\) is a continuous function of \(p\), with \(\gamma = g\) and \(m\) given below. The sample quantiles can be obtained equivalently by linear interpolation between the points \((p_k,x_k)\) where \(x_k\) is the \(k\)th order statistic. Specific expressions for \(p_k\) are given below.

Type 4

\(m = 0\). \(p_k = \frac{k}{n}\). That is, linear interpolation of the empirical cdf.

Type 5

\(m = 1/2\). \(p_k = \frac{k - 0.5}{n}\). That is a piecewise linear function where the knots are the values midway through the steps of the empirical cdf. This is popular amongst hydrologists.

Type 6

\(m = p\). \(p_k = \frac{k}{n + 1}\). Thus \(p_k = \mbox{E}[F(x_{k})]\). This is used by Minitab and by SPSS.

Type 7

\(m = 1-p\). \(p_k = \frac{k - 1}{n - 1}\). In this case, \(p_k = \mbox{mode}[F(x_{k})]\). This is used by S.

Type 8

\(m = (p+1)/3\). \(p_k = \frac{k - 1/3}{n + 1/3}\). Then \(p_k \approx \mbox{median}[F(x_{k})]\). The resulting quantile estimates are approximately median-unbiased regardless of the distribution of x.

Type 9

\(m = p/4 + 3/8\). \(p_k = \frac{k - 3/8}{n + 1/4}\). The resulting quantile estimates are approximately unbiased for the expected order statistics if x is normally distributed.

Further details are provided in Hyndman and Fan (1996) who recommended type 8. The default method is type 7, as used by S and by R < 2.0.0.

Details

A vector of length length(probs) is returned; if names = TRUE, it has a names attribute.

NA and NaN values in probs are propagated to the result.

The default method works with classed objects sufficiently like numeric vectors that sort and (not needed by types 1 and 3) addition of elements and multiplication by a number work correctly. Note that as this is in a namespace, the copy of sort in base will be used, not some S4 generic of that name. Also note that that is no check on the ‘correctly’, and so e.g.quantile can be applied to complex vectors which (apart from ties) will be ordered on their real parts.

There is a method for the date-time classes (see "POSIXt"). Types 1 and 3 can be used for class "Date" and for ordered factors.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician 50, 361--365. 10.2307/2684934.

See Also

ecdf for empirical distributions of which quantile is an inverse; boxplot.stats and fivenum for computing other versions of quartiles, etc.

Examples

Run this code

# NOT RUN {quantile(x <- rnorm(1001)) # Extremes & Quartiles by defaultquantile(x, probs = c(0.1, 0.5, 1, 2, 5, 10, 50, NA)/100)### Compare different typesquantAll <- function(x, prob, ...) t(vapply(1:9, function(typ) quantile(x, prob=prob, type = typ, ...), quantile(x, prob, type=1)))p <- c(0.1, 0.5, 1, 2, 5, 10, 50)/100signif(quantAll(x, p), 4)## for complex numbers:z <- complex(re=x, im = -10*x)signif(quantAll(z, p), 4)# }

Run the code above in your browser using DataLab

quantile function - RDocumentation (2024)

FAQs

What does quantile function in R return? ›

quantile returns estimates of underlying distribution quantiles based on one or two order statistics from the supplied elements in x at probabilities in probs .

What is the 90% quantile? ›

The 90th percentile indicates the point where 90% percent of the data have values less than this number. More generally, the pth percentile is the number n for which p% of the data is less than n.

What does 75% quantile mean? ›

75th Percentile - Also known as the third, or upper, quartile. The 75th percentile is the value at which 25% of the answers lie above that value and 75% of the answers lie below that value.

What does the quantile function tell you? ›

In probability and statistics, the quantile function outputs the value of a random variable such that its probability is less than or equal to an input probability value.

How do you interpret quantile regression results? ›

The short answer is that you interpret quantile regression coefficients just like you do ordinary regression coefficients. The long answer is that you interpret quantile regression coefficients almost just like ordinary regression coefficients. We can illustrate this with a couple of examples using the hsb2 dataset.

What is the normal quantile function? ›

The quantile function of a normal distribution is equal to the inverse of the distribution function since the latter is continuous and strictly increasing. However, as we explained in the lecture on normal distribution values, the distribution function of a normal variable has no simple analytical expression.

What is a good quantile score? ›

For example, a student's Quantile measure should be at 1350Q by high school graduation to handle the math needed in college and most careers. A student Quantile measure helps you to know: Which skills and concepts students are ready to learn.

What do quantiles tell you? ›

Quantiles are values that split sorted data or a probability distribution into equal parts. In general terms, a q-quantile divides sorted data into q parts. The most commonly used quantiles have special names: Quartiles (4-quantiles): Three quartiles split the data into four parts.

What is the 95% quantile? ›

A quantile is called a percentile when it is based on a 0-100 scale. The 0.95-quantile is equivalent to the 95-percentile and is such that 95 % of the sample is below its value and 5 % is above.

Is quantile the same as percentile in R? ›

The 0.95 quantile point is exactly the same as the 95th percentile point. R does not work with percentiles, rather R works with quantiles. The R command for this is quantile() where we need to give that function the variable holding the data we are using and we need to give the function one or more decimal values.

What is the formula for quantile? ›

The quantile function is defined on the unit interval (0, 1). For F continuous and strictly increasing at t, then Q(u)=t iff F(t)=u. Thus, if u is a probability value, t=Q(u) is the value of t for which P(X≤t)=u.

What does .99 quantile mean? ›

The 99th percentile is a statistical concept that represents the value below which 99% of a given data set falls. In other words, it's the value that puts you just below the top 1% of the population.

How to write quantile function? ›

Therefore, the quantile function is QX(p)=−log(1−p) Q X ( p ) = − log ⁡ ( 1 − p ) for 0<p<1 0 < p < 1 . X=QX(U) X = Q X ( U ) . The Uniform(0, 1) spinner lands uniformly on values between 0 and 1.

What is φ quantile? ›

Quantiles. You can use both summaries and histograms to calculate so-called φ-quantiles, where 0 ≤ φ ≤ 1. The φ-quantile is the observation value that ranks at number φ*N among the N observations. Examples for φ-quantiles: The 0.5-quantile is known as the median. The 0.95-quantile is the 95th percentile.

Is quantile a Z score? ›

The Z-score is a quantile, and takes values from −∞ to ∞. The cumulative percentile is bounded from 0 to 1.

What does quantile regression tell you? ›

Quantile regression allows the analyst to drop the assumption that variables operate the same at the upper tails of the distribution as at the mean and to identify the factors that are important determinants of expenditures and quality of care for different subgroups of patients.

What does a quantile quantile plot show? ›

The quantile-quantile (q-q) plot is a graphical technique for determining if two data sets come from populations with a common distribution.

What is the purpose of a quantile? ›

Quantiles give some information about the shape of a distribution - in particular whether a distribution is skewed or not. For example if the upper quartile is further from the median than the lower quartile, we can conclude that the distribution is skewed to the right, and vice versa.

Top Articles
دانلود بازی Ben 10 بن تن برای کامپیوتر PC
New Jersey Transit : 05-25-2021 - NJ TRANSIT UNVEILS ROADMAP TO 100% ZERO-EMISSIONS BUS FLEET
Rosy Boa Snake — Turtle Bay
Forozdz
#ridwork guides | fountainpenguin
Lexi Vonn
Jazmen Jafar Linkedin
Craigslist In South Carolina - Craigslist Near You
Cinepacks.store
T&G Pallet Liquidation
Braums Pay Per Hour
Cube Combination Wiki Roblox
Capitulo 2B Answers Page 40
Palace Pizza Joplin
How Many Cc's Is A 96 Cubic Inch Engine
Washington, D.C. - Capital, Founding, Monumental
Dumb Money
Michaels W2 Online
The Banshees Of Inisherin Showtimes Near Regal Thornton Place
Odfl4Us Driver Login
Keurig Refillable Pods Walmart
Craigslist Pinellas County Rentals
Hennens Chattanooga Dress Code
St Clair County Mi Mugshots
Talkstreamlive
Academy Sports Meridian Ms
Publix Near 12401 International Drive
1636 Pokemon Fire Red U Squirrels Download
TMO GRC Fortworth TX | T-Mobile Community
This Is How We Roll (Remix) - Florida Georgia Line, Jason Derulo, Luke Bryan - NhacCuaTui
Current Students - Pace University Online
Past Weather by Zip Code - Data Table
lol Did he score on me ?
Ewg Eucerin
Babydepot Registry
Wells Fargo Bank Florida Locations
Panchitos Harlingen Tx
Jennifer Reimold Ex Husband Scott Porter
Pensacola 311 Citizen Support | City of Pensacola, Florida Official Website
State Legislatures Icivics Answer Key
Collier Urgent Care Park Shore
Finland’s Satanic Warmaster’s Werwolf Discusses His Projects
968 woorden beginnen met kruis
Mugshots Journal Star
Walmart Pharmacy Hours: What Time Does The Pharmacy Open and Close?
Promo Code Blackout Bingo 2023
2024-09-13 | Iveda Solutions, Inc. Announces Reverse Stock Split to be Effective September 17, 2024; Publicly Traded Warrant Adjustment | NDAQ:IVDA | Press Release
Craigslist Woodward
Sinai Sdn 2023
Wzzm Weather Forecast
Zalog Forum
Qvc Com Blogs
Latest Posts
Article information

Author: Laurine Ryan

Last Updated:

Views: 5819

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Laurine Ryan

Birthday: 1994-12-23

Address: Suite 751 871 Lissette Throughway, West Kittie, NH 41603

Phone: +2366831109631

Job: Sales Producer

Hobby: Creative writing, Motor sports, Do it yourself, Skateboarding, Coffee roasting, Calligraphy, Stand-up comedy

Introduction: My name is Laurine Ryan, I am a adorable, fair, graceful, spotless, gorgeous, homely, cooperative person who loves writing and wants to share my knowledge and understanding with you.