------------------------------------------------------------------------------- help forinvcdf-------------------------------------------------------------------------------

Invert the cumulative distribution function (quantile function)

incdfvarname[ifexp] [inrange] [weight],generate(newvar)reference(refvar[ifexp] [inrange])[cdf(cdfvar)]

by...: may be used withinvcdf; see help by.

fweights andaweights are allowed; see help weights.

Description

invcdfapplies the inverse cumulative distribution function (the so called quantile function) ofrefvarto the values ofvarname. Technically,invcdffirst computes the empirical cumulative distribution function ofrefvar(see cumul) and then applies the inverse of this CDF to the values ofvarname. Note thatvarnamemust lie between 0 and 1 (inclusive).The values computed by

invcdfare equivalent to those obtained by _pctile, percentiles() (apart from possible precision problems). Also see therelrankcommand (available from the SSC Archive). An application ofinvcdfcan be found in the jmp package (also available from the SSC Archive).

Options

generate(newvar)it not optional. It specifies the name of the new variable to be created.

reference(refvar[ifexp] [inrange])is not optional. It specifies the variable representing the reference distribution. Useifandinwithinreference()to restrict the sample forrefvar(theifandinrestrictions outsidereference()do not apply torefvar). Note that the indicated samples forrefvarandvarnamemay overlap.

cdf(cdfvar)may be used to specify a variable representing the empirical cumulative distribution function (e.c.d.f.) ofrefvar. In this case,relrankskips the computation of the e.c.d.f. and usescdfvarinstead. Note thatcdfvarshould lie in [0,1] and must be defined for all values ofrefvarin the specified sample.

ExamplesCompute the hypothetical wages for women that would result if women had the male wage distribution:

. cumul wage if female==1, generate(cum) . invcdf cum, ref(wage if female==0) g(hypwage) . summarize hypwage

Methods and Formulas

invcdfinverts the empirical distribution function using averages where the function is flat. The formula can be found in[R] pctile(standard formula).

AuthorBen Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also seeOnline: help for pctile, cumul, relrank (if installed), jmp (if