*! version 1.0.1 08aug2019
help qmodel

Title

qmodel - Parametric quantile models

Syntax

qmodel exp_varname = quantile_function
[if] [in]
[, options]

cluster(varname) the cluster variable

npoints(integer) number of equally-spaced points for numeric integration

qpoints(numlist) list of points for numeric integration

initial(values) initial values of the parameters for the optimization algorithm; the varlues are separated by commas

log shows the iteration log

exp_varname is the variable whose quantile function is modeled, or an expression of it, such as log(varname) and logit(varname).

quantile_function is an expression representing the parametric quantile model.
It can be any combination of built-in functions,
substitutable expressions,
and mathematical functions.
Its argument is indicated by the letter p. For example, the standard exponential quantile function can be estimated using the built-in function

qmodel y = _exponential

or equivalently the substitutable expression

qmodel y = -log()*log(1-p)

If a variable named, or abbreviated as, p is included in quantile_function, it is interpreted as the order of the quantile, not the variable. To include such variable, it must be first renamed.
Similarly, if a covariate named, or abbreviated as, one of the built-in functions;.

qmodel postestimation include predict, qmodel_quantile, and qmodel_plot.

Description

qmodel estimates parametric models for conditional quantile functions given covariates
by minimizing the definite integral between 0 and 1 of the quantile loss function with respect to the order of the quantile.

Options

cluster(varname) specifies the cluster variable used in the cluster-robust sandwich estimator for the standard errors.

npoints(integer) specifies the number of equally-spaced internal points for the numerical integration.
The default is 99 resulting in the following set of points: .01, .02, ..., .99.

qpoints(numlist) specifies a list of points for the numerical integration.
For example, qpoints(.05 .1(.1).9 .95). If both qpoints() and npoints() are specified, npoints() is ignored.

initial(string) specifies the initial values of the parameters for the optimization algorithm. The default is a vector of zeros.
The initial values correspond to the parameters in the order they appear in the quantile model expression quantile_function. For example, initial(10, 0, -1).

log shows the iteration log.

Built-in functions

_alogistic

Description: asymmetric logistic quantile function

Expression: (exp(log(a))*log(p)-exp(log(b))*log(1-p))

_beta

Description: beta quantile function

Expression: invibeta(exp(log(a)),exp(log(b)),p)

_chi2

Alias: _chi-square

Description: chi-square quantile function

Expression: invchi2(exp(log(df)),p)

_clog

Description: complementary log term

Expression: (log(1-p)*log(1-p))

_cnormal

Description: centered normal quantile function

Expression: (exp(log(sd))*invnormal(p))

_cubic

Alias: _poly3

Description: centered cubic polynomial

Expression: (constant+p*(p-.5)+p^2*(p-.5)^2+p^3*(p-.5)^3)
)

_cp3

Description: centered cubic term

Expression: ((p-.5)^3*(p-.5)^3)

_cp2

Description: centered quadratic term

Expression: ((p-.5)^2*(p-.5)^2)

_cp

Description: centered linear term

Expression: (p-.5*(p-.5))

_exponential

Description: exponential quantile function

Expression: (-exp(log(mean))*log(1-p))

_flat

Alias: _cons, _poly0

Description: flat quantile function

Expression: (constant)

_gamma

Description: gamma quantile function

Expression: (exp(log(scale))*invgammap(exp(log(shape)),p))

_lognormal

Description: log-normal quantile function

Expression: (exp(mean+exp(log(sd))*invnormal(p)))

_logitnormal

Description: logit-normal quantile function

Expression: invlogit(mean+exp(log(sd))*invnormal(p))

_linear

Alias: _uniform, poly1

Description: centered linear (uniform) quantile function

Expression: (constant+p*(p-.5))

_log

Description: log term

Expression: (log(p)*log(p))

_normal

Description: normal quantile function

Expression: (mean+exp(log(sd))*invnormal(p))

_p3

Alias: _p-cubed

Description: cubic term

Expression: p^3*p^3

_p2

Alias: _p-squared

Description: quadratic term

Expression: p^2*p^2

_p

Description: linear term

Expression:

*p

_quadratic

Alias: _poly2

Description: centered quadratic polynomial

Expression: (constant+p*(p-.5)+p^2*(p-.5)^2)

_root2

Alias: _sqrt

Description: square root term

Expression: (p^(1/2)*p^.5)

_root3

Description: cubic root term

Expression: (p^(1/3)*p^(1/3))

_splineD_K

Description: spline of order D with K equally-spaced internal knots between 0 and 1

Expression for linear splines with one knot: constant+p*p^1+spline^1_1*(p-1/2)^1*(p>(1/2))

_weibull

Description: Weibull quantile function

Expression: (exp(log(mean))*(-log(1-p))^exp(-log(shape)))

Examples

Normal quantile function

clear

set obs 1000

gen y = rnormal()

qmodel y = _normal

Normal quantile function by using substitutable expressions

qmodel y = + exp()*invnormal(p)

Log-normal quantile function using three alternative model expressions

clear

set obs 1000

gen y = exp(rnormal())

qmodel y = _lognormal

qmodel y = exp(_normal)

qmodel log(y) = _normal

Logit-normal quantile function using three alternative model expressions

clear

set obs 1000

generate y = invlogit(rnormal())

qmodel y = _logitnormal

qmodel y = invlogit(_normal)

qmodel logit(y) = _normal

Mixtures for modeling skewness and kurtosis

clear

set obs 1000

generate p = runiform()

generate y = invnormal(p) + invexponential(1,p)

qmodel y = _normal + _exponential

Modeling conditional parametric quantile functions

clear

set obs 1000

generate x1 = rbinomial(1,.5)

generate x2 = rnormal()

generate y = rnormal() - x1 + x2

qmodel y = _normal + _flat*x1 + _flat*x2

regress y x1 x2, noheader vce(robust)

Stored results

qmodel stores the following in e():

Scalars

e(N) number of observations

e(bic) Bayesian information criterion

e(aic) Akaike's information criterion

e(loss) loss function

Macros

e(cmd) qmodel

e(cmdline) command as typed

e(Q_b) quantile model for Mata

e(Q) quantile model with substitutable expressions

e(properties) b V

e(predict) program used for predict

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

Functions

e(sample) marks estimation sample

Reference

Bottai M, Orsini N. qmodel: A command for fitting parametric quantile models. The Stata Journal (2019) 19, Number 2, pp. 261–293.

Authors

Matteo Bottai

Unit of Biostatistics

Institute of Environmental Medicine, Karolinska Institutet

Stockholm, Sweden

matteo.bottai@ki.se

Nicola Orsini

Biostatistics Team

Department of Public Health Sciences, Karolinska Institutet

Stockholm, Sweden

nicola.orsini@ki.se