{smcl} {* *! version 1.0.1 08aug2019}{...} {cmd:help qmodel} {hline} {title:Title} {p2colset 5 15 17 2}{...} {p2col :{cmd:qmodel} {hline 1}}Parametric quantile models{p_end} {p2colreset}{...} {marker syntax}{...} {title:Syntax} {p 4 11 2} {cmd:qmodel} {it:exp_varname} = {it:quantile_function} {ifin} [{cmd:,} {it:{help qmodel##option_table:options}}] {synoptset 18 tabbed}{...} {marker option_table}{...} {synopthdr} {synoptline} {synopt :{opt cluster(varname)}}the cluster variable{p_end} {synopt :{opth np:oints(integer)}}number of equally-spaced points for numeric integration{p_end} {synopt :{opth qp:oints(numlist)}}list of points for numeric integration{p_end} {synopt :{opt init:ial(values)}}initial values of the parameters for the optimization algorithm; the varlues are separated by commas{p_end} {synopt :{opt log}}shows the iteration log{p_end} {synoptline} {p 4 6 2}{it:exp_varname} is the variable whose quantile function is modeled, or an expression of it, such as log({it:varname}) and logit({it:varname}). {p 4 6 2}{it:quantile_function} is an expression representing the parametric quantile model. It can be any combination of {help qmodel##builtin:built-in functions}, {help mlexp##remarks:substitutable expressions}, and {help math_functions: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 {phang2}qmodel y = _exponential {phang}or equivalently the substitutable expression {phang2}qmodel y = -log({mean})*log(1-p) {phang}If a variable named, or abbreviated as, p is included in {it: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;.{p_end} {pstd} {helpb qmodel_postestimation:qmodel postestimation} include {cmd:predict}, {cmd:qmodel_quantile}, and {cmd:qmodel_plot}.{p_end} {p2colreset}{...} {marker description}{...} {title:Description} {pstd} {cmd: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. {marker options}{...} {title:Options} {phang}{cmd: cluster(}{it:varname}{cmd:)} specifies the cluster variable used in the cluster-robust sandwich estimator for the standard errors. {phang}{cmd: npoints(}{help datatype:integer}{cmd:)} 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. {phang}{cmd: qpoints(}{help numlist}{cmd:)} specifies a list of points for the numerical integration. For example, qpoints(.05 .1(.1).9 .95). If both {hi:qpoints()} and {hi:npoints()} are specified, {hi:npoints()} is ignored. {phang}{cmd: initial(}{it:string}{cmd:)} 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 {it:quantile_function}. For example, {cmd:initial(}10, 0, -1{cmd:)}. {phang}{cmd: log} shows the iteration log. {marker builtin}{...} {title:Built-in functions} {p 4 8 2} {opt _alogistic}{break} Description: asymmetric logistic quantile function{break} Expression: (exp({alogistic:log(a)})*log(p)-exp({alogistic:log(b)})*log(1-p)) {p_end} {p 4 8 2} {opt _beta}{break} Description: beta quantile function{break} Expression: invibeta(exp({beta:log(a)}),exp({beta:log(b)}),p){break} {p_end} {p 4 8 2} {opt _chi2}{break} Alias: _chi-square{break} Description: chi-square quantile function{break} Expression: invchi2(exp({chi2:log(df)}),p){break} {p_end} {p 4 8 2} {opt _clog}{break} Description: complementary log term{break} Expression: ({clog:log(1-p)}*log(1-p)){break} {p_end} {p 4 8 2} {opt _cnormal}{break} Description: centered normal quantile function{break} Expression: (exp({cnormal:log(sd)})*invnormal(p)){break} {p_end} {p 4 8 2} {opt _cubic}{break} Alias: _poly3{break} Description: centered cubic polynomial{break} Expression: ({cubic:constant}+{cubic:p}*(p-.5)+{cubic:p^2}*(p-.5)^2+{cubic:p^3}*(p-.5)^3){break}) {p_end} {p 4 8 2} {opt _cp3}{break} Description: centered cubic term{break} Expression: ({cp3:(p-.5)^3}*(p-.5)^3){break} {p_end} {p 4 8 2} {opt _cp2}{break} Description: centered quadratic term{break} Expression: ({cp2:(p-.5)^2}*(p-.5)^2){break} {p_end} {p 4 8 2} {opt _cp}{break} Description: centered linear term{break} Expression: ({cp:p-.5}*(p-.5)){break} {p_end} {p 4 8 2} {opt _exponential}{break} Description: exponential quantile function{break} Expression: (-exp({exponential:log(mean)})*log(1-p)){break} {p_end} {p 4 8 2} {opt _flat}{break} Alias: _cons, _poly0{break} Description: flat quantile function{break} Expression: ({flat:constant}){break} {p_end} {p 4 8 2} {opt _gamma}{break} Description: gamma quantile function{break} Expression: (exp({gamma:log(scale)})*invgammap(exp({gamma:log(shape)}),p)){break} {p_end} {p 4 8 2} {opt _lognormal}{break} Description: log-normal quantile function{break} Expression: (exp({lognormal:mean}+exp({lognormal:log(sd)})*invnormal(p))){break} {p_end} {p 4 8 2} {opt _logitnormal}{break} Description: logit-normal quantile function{break} Expression: invlogit({logitnormal:mean}+exp({logitnormal:log(sd)})*invnormal(p)){break} {p_end} {p 4 8 2} {opt _linear}{break} Alias: _uniform, poly1{break} Description: centered linear (uniform) quantile function{break} Expression: ({linear:constant}+{linear:p}*(p-.5)){break} {p_end} {p 4 8 2} {opt _log}{break} Description: log term{break} Expression: ({log:log(p)}*log(p)){break} {p_end} {p 4 8 2} {opt _normal}{break} Description: normal quantile function{break} Expression: ({normal:mean}+exp({normal:log(sd)})*invnormal(p)){break} {p_end} {p 4 8 2} {opt _p3}{break} Alias: _p-cubed{break} Description: cubic term{break} Expression: {p3:p^3}*p^3{break} {p_end} {p 4 8 2} {opt _p2}{break} Alias: _p-squared{break} Description: quadratic term{break} Expression: {p2:p^2}*p^2{break} {p_end} {p 4 8 2} {opt _p}{break} Description: linear term{break} Expression: {p:p}*p{break} {p_end} {p 4 8 2} {opt _quadratic}{break} Alias: _poly2{break} Description: centered quadratic polynomial{break} Expression: ({quadratic:constant}+{quadratic:p}*(p-.5)+{quadratic:p^2}*(p-.5)^2){break} {p_end} {p 4 8 2} {opt _root2}{break} Alias: _sqrt{break} Description: square root term{break} Expression: ({root2:p^(1/2)}*p^.5){break} {p_end} {p 4 8 2} {opt _root3}{break} Description: cubic root term{break} Expression: ({root3:p^(1/3)}*p^(1/3)){break} {p_end} {p 4 8 2} {hi: _spline{it:D}_{it:K}}{break} Description: spline of order {it:{hi:D}} with {it:{hi:K}} equally-spaced internal knots between 0 and 1{break} Expression for linear splines with one knot: {spline:constant}+{spline:p}*p^1+{spline:spline^1_1}*(p-1/2)^1*(p>(1/2)){break} {p_end} {p 4 8 2} {hi: _weibull}{break} Description: Weibull quantile function{break} Expression: (exp({weibull:log(mean)})*(-log(1-p))^exp(-{weibull:log(shape)})){break} {marker results}{...} {title:Examples} {pstd}Normal quantile function{p_end} {phang2}{stata "clear"}{p_end} {phang2}{stata "set obs 1000"}{p_end} {phang2}{stata "gen y = rnormal()"}{p_end} {phang2}{stata "qmodel y = _normal"}{p_end} {pstd}Normal quantile function by using substitutable expressions{p_end} {phang2}{stata "qmodel y = {mean} + exp({log(sd)})*invnormal(p)"}{p_end} {pstd}Log-normal quantile function using three alternative model expressions{p_end} {phang2}{stata "clear"}{p_end} {phang2}{stata "set obs 1000"}{p_end} {phang2}{stata "gen y = exp(rnormal())"}{p_end} {phang2}{stata "qmodel y = _lognormal"}{p_end} {phang2}{stata "qmodel y = exp(_normal)"}{p_end} {phang2}{stata "qmodel log(y) = _normal"}{p_end} {pstd}Logit-normal quantile function using three alternative model expressions{p_end} {phang2}{stata "clear"}{p_end} {phang2}{stata "set obs 1000"}{p_end} {phang2}{stata "generate y = invlogit(rnormal())"}{p_end} {phang2}{stata "qmodel y = _logitnormal"}{p_end} {phang2}{stata "qmodel y = invlogit(_normal)"}{p_end} {phang2}{stata "qmodel logit(y) = _normal"}{p_end} {pstd}Mixtures for modeling skewness and kurtosis{p_end} {phang2}{stata "clear"}{p_end} {phang2}{stata "set obs 1000"}{p_end} {phang2}{stata "generate p = runiform()"}{p_end} {phang2}{stata "generate y = invnormal(p) + invexponential(1,p)"}{p_end} {phang2}{stata "qmodel y = _normal + _exponential"}{p_end} {pstd}Modeling conditional parametric quantile functions{p_end} {phang2}{stata "clear"}{p_end} {phang2}{stata "set obs 1000"}{p_end} {phang2}{stata "generate x1 = rbinomial(1,.5)"}{p_end} {phang2}{stata "generate x2 = rnormal()"}{p_end} {phang2}{stata "generate y = rnormal() - x1 + x2"}{p_end} {phang2}{stata "qmodel y = _normal + _flat*x1 + _flat*x2"}{p_end} {phang2}{stata "regress y x1 x2, noheader vce(robust)"}{p_end} {title:Stored results} {cmd:qmodel} stores the following in {cmd:e()}: {synoptset 20 tabbed}{...} {p2col 5 20 24 2: Scalars}{p_end} {synopt:{cmd:e(N)}}number of observations{p_end} {synopt:{cmd:e(bic)}}Bayesian information criterion{p_end} {synopt:{cmd:e(aic)}}Akaike's information criterion{p_end} {synopt:{cmd:e(loss)}}loss function{p_end} {synoptset 20 tabbed}{...} {p2col 5 20 24 2: Macros}{p_end} {synopt:{cmd:e(cmd)}}{cmd:qmodel}{p_end} {synopt:{cmd:e(cmdline)}}command as typed{p_end} {synopt:{cmd:e(Q_b)}}quantile model for Mata{p_end} {synopt:{cmd:e(Q)}}quantile model with substitutable expressions{p_end} {synopt:{cmd:e(properties)}}{cmd:b V}{p_end} {synopt:{cmd:e(predict)}}program used for {cmd:predict}{p_end} {synoptset 20 tabbed}{...} {p2col 5 20 24 2: Matrices}{p_end} {synopt:{cmd:e(b)}}coefficient vector{p_end} {synopt:{cmd:e(V)}}variance-covariance matrix of the estimators{p_end} {synoptset 20 tabbed}{...} {p2col 5 20 24 2: Functions}{p_end} {synopt:{cmd:e(sample)}}marks estimation sample{p_end} {space 4}{hline 20} {p 4 6 2} {marker reference}{...} {title:Reference} {marker FB2016}{...} {phang} Bottai M, Orsini N. qmodel: A command for fitting parametric quantile models. The Stata Journal (2019) 19, Number 2, pp. 261–293. {title:Authors} {pstd}Matteo Bottai{p_end} {pstd}Unit of Biostatistics{p_end} {pstd}Institute of Environmental Medicine, Karolinska Institutet{p_end} {pstd}Stockholm, Sweden{p_end} {pstd}matteo.bottai@ki.se{p_end} {pstd}Nicola Orsini{p_end} {pstd}Biostatistics Team{p_end} {pstd}Department of Public Health Sciences, Karolinska Institutet{p_end} {pstd}Stockholm, Sweden{p_end} {pstd}nicola.orsini@ki.se{p_end}