Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: random coefficients & general truncation now in cmp

 From "David Roodman (droodman@cgdev.org)" To "statalist@hsphsun2.harvard.edu" Subject st: random coefficients & general truncation now in cmp Date Wed, 28 Nov 2012 16:46:46 +0000

```The latest version of cmp, just posted on SSC, adds two significant new features:

1. Truncated regression, instead of being a distinct model type analogous to the built-in -truncreg- command, is a general feature applicable to most model types. You can now fit models in which the latent dependent variables are first truncated and then, optionally, pass through a censoring process (probit, tobit, ordered probit, interval regression). Truncation is not allowed with rank-ordered or multinomial probit models.

2. cmp can now model random coefficients as well as random effects/intercepts. The syntax is like that of xtmixed. Estimation is done with simulation rather than quadrature. A simple example is:

use http://www.stata-press.com/data/mlmus3/gcse, clear
cmp setup
cmp  (gcse = lrt || school: lrt), ind(\$cmp_cont) redraws(101, anti) tech(dfp)

[Comparable:
xtmixed gcse lrt || school: lrt, cov(unstructured)

eq slope: lrt
generate cons = 1
eq inter: cons
gllamm gcse lrt, i(school) nrf(2) eqs(inter slope) ip(m) nip(15) adapt]

Effects and coefficients can be correlated within and across equations. But that can be a lot of correlation parameters to fit, so there are covariance() options to limit them. Constraints can do the same thing. Examples:

cmp (y1 = x1 x2 || id: x1 x2) (y2 = x1 x2 || id: x1 x2), cov(indep .) redraws(53, scramble) ind(\$cmp_probit \$cmp_probit)
cmp (y1 = x1 x2 || id: x1 x2, cov(indep)) (y2 = x1 x2 || id: x1 x2),  redraws(53, scramble) ind(\$cmp_probit \$cmp_probit)

The first states that id-level effects are uncorrelated across equations (but the observation-level residuals can still be cross-correlated). The second states that effects are uncorrelated only within the first equation. Both set up bivariate probit models in which all regressors, including the constant, have random coefficients at the id level.

In comparison to other Stata options for modeling with random effects and coefficients, cmp is most useful for models with more than one effect or equation. For models with one equation and one random effect/coefficient, cmp tends to be slower than the quadrature-based gllamm (and way slower than built-in quadrature-based commands like xtprobit and xtmixed where applicable). Also, gllamm can fit many models that cmp cannot, notably ones involving non-Gaussian errors. But the built-in commands don't do random coefficients (except for uncensored models, where xtmixed works) and gllamm doesn't fully handle multi-equation models like cmp. And gllamm's run-time increases much faster than cmp's with the number of effects.

To install, type "ssc install cmp, replace".

--David

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```