Home  /  Products  /  Stata 19  /  Bayesian asymmetric Laplace model

← See Stata 19's new features

Highlights

  • Asymmetric Laplace distribution (ALD) to model skewed outcomes

  • Flexible prior specifications

  • Include random effects at multiple levels of hierarchy

  • Support of Bayesian postestimation features

  • See more Bayesian analysis features

The bayesmh command now includes an asymmetric Laplace distribution (ALD) as a new likelihood function. You can use ALD to model nonnormal outcomes with pronounced skewness and kurtosis.

Let's see it work

Consider the mathscores dataset, which contains math scores of pupils in the third year (math3) and fifth year (math5) from different schools (school) in Inner London (Mortimore et al. 1988).

. webuse mathscores

. describe

Contains data from https://www.stata-press.com/data/r19/mathscores.dta
 Observations:           887
    Variables:             3                  9 May 2022 23:31
Variable Storage Display Value                                     
name type format label Variable label
school float %9.0g School ID
math3 float %9.0g Year 3 math score
math5 float %9.0g Year 5 math score
Sorted by:

We use ALD to examine the skewness (asymmetry) of the math5 variable. For this purpose, we use asymlaplaceq() with a random quantile parameter {tau}. A negative skewness is indicated by {tau} greater than 0.5; positive skewness is indicated by {tau} less than 0.5; and {tau} of 0.5 indicates no skewness, a perfect symmetry. We apply a flat uniform(0, 1) prior for {tau}. We specify a regression model with only a constant term for math5, which corresponds to the location parameter of ALD, and a scale parameter {scale} as in the previous examples.

. bayesmh math5, likelihood(asymlaplaceq({scale}, {tau}))
     prior({math5:}, normal(0,10000)) 
     prior({scale},  igamma(0.01,0.01))
     prior({tau},    uniform(0,1))
     block({math5:} {scale}{tau}, split)
     initial({tau} 0.5) rseed(19)

Burn-in ...
Simulation ...

Model summary
Likelihood: math5 ~ asymlaplaceq({math5:_cons},{scale},{tau}) Priors: {math5:_cons} ~ normal(0,10000) {scale} ~ igamma(0.01,0.01) {tau} ~ uniform(0,1)
Bayesian asymm. Laplace (quantile) regression MCMC iterations = 12,500 Random-walk Metropolis–Hastings sampling Burn-in = 2,500 MCMC sample size = 10,000 Number of obs = 887 Acceptance rate = .424 Efficiency: min = .03815 avg = .05242 Log marginal-likelihood = -2846.2182 max = .07833
Equal-tailed
Mean Std. dev. MCSE Median [95% cred. interval]
math5
_cons 37.00486 .045309 .001619 37.00222 36.9161 37.10699
scale 1.073886 .0655504 .003246 1.071063 .9511403 1.211991
tau .8602184 .0085491 .000438 .8601294 .843211 .8767714

We see that the estimated 95% credible interval of [0.84, 0.88] suggests that {tau} is greater than 0.5, indicating a strong negative skewness. A more formal test for negative skewness can be conducted by using the bayestest interval command.

. bayestest interval {tau}, lower(0.5)

Interval tests     MCMC sample size =    10,000

       prob1 : {tau} > 0.5
 
Mean Std. dev. MCSE
prob1 1 0.00000 0

Indeed, the posterior probability of {tau} greater than 0.5 is 1.

Reference

Mortimore, P., P. Sammons, L. Stoll, D. Lewis, and R. Ecob. 1988. School Matters: The Junior Years. Wells, Somerset, UK: Open Books.

Tell me more

Read more about fitting asymmetric Laplace Bayesian models in [BAYES] bayesmh in the Stata Bayesian Analysis Reference Manual.

Learn more about Stata's Bayesian analysis features.

Also see Bayesian quantile regression.

View all the new features in Stata 19, and, in particular, new in Bayesian analysis.

Ready to get started?

Experience powerful statistical tools, reproducible workflows, and a seamless user experience—all in one trusted platform.