*! Version 1.1.0 by Francisco Perales & Reinhard Schunck 16-May-2017
help xthybrid

Title

xthybrid - Estimates hybrid and correlated random effect/Mundlak mixed effect models for linear and non-linear outcomes

Syntax

xthybrid depvar indepvars [if] [in] , clusterid(varname) [options]

options description

Main
clusterid(varname) specifies the cluster/grouping variable

family(type) specifies the distribution of the outcome variable

link(type) specifies the link function

cre requests a correlated random effect model instead of a hybrid model

nonlinearities(type) adds polynomial functions of the cluster means to the model

randomslope(varlist) requests random slopes on the random-effect and within-group coefficients of selected variables

use(varlist) splits between- and within-cluster effects only for selected explanatory variables

percentage(#) sets the minimum % within-cluster variance for explanatory variables to be considered cluster-varying

test presents results of tests of the random effect assumption for separate model variables

full prints the full model output

stats(list) allows users to select which model summary statistics are reported

se requests standard errors for the parameters on model variables

t requests t-values for the parameters on model variables

p requests p-values for the parameters on model variables

star requests stars to denote statistically significant parameters on model variables

vce specifies the type of standard error to be reported

iterations requests that the command is executed noisily

keepvars requests that any new variables created by the command are retained

meglmopts(list) enables the user to request options from the meglm command

Description

xthybrid estimates linear and non-linear mixed effect regression models that split the effects of cluster-varying covariates on
the outcome variable into within-cluster and between-cluster effects (Schunck 2013, Schunck & Perales 2017). This is accomplished by: (i)
specifyng cluster-varying variables in indepvars as deviations from the cluster mean, and (ii) adding the cluster means of the original cluster-varying variables
to the model. In the linear case, this can be expressed as:

Yij = A + B1*Zi + B2*(Xij-X_bari) + B3*X_bari + ui + eij

where B2 captures the within-cluster effect of cluster-varying variables on Yij, and B3 captures the between-cluster effect of
cluster-varying variables on Yij. This technique, discussed in Allison (2009), is related to the correlated random effect model originally
proposed by Mundlak (1978), also known as the Mundlak model. If no variables vary within clusters, xthybrid estimates a standard mixed effect
model and displays a warning. The between-cluster effects are given by the cluster-mean variables beginning with the prefix B__ while
the within-cluster effects are given by the cluster-mean differenced variables beginning with the prefix W__. The prefix R__ is used to
denote variables for which the coefficient is the 'standard' random effect coefficient. Model estimates are kept in Stata's background memory and
can be accessed via estimates dir.

The xthybrid routine is an expansion of the mundlak command, but unlike the latter it allows for non-linear models.
Specifically, xthybrid can fit any 2-level specification covered by Stata's native routine meglm.

Options

clusterid(variable) specifies the variable in the dataset that will be used as the cluster/grouping variable (i.e. the Level 2 ID variable).

family(type) specifies the distribution of the outcome variable. This option supports the following family types: gaussian, bernoulli,
binomial, gamma, nbinomial, ordinal, and poisson. When family is not specified, 'gaussian' is used by default.

link(type) specifies the link function. This option supports the following link types: identity, log, logit, probit, and cloglog.
When link is not specified, 'identity' is used by default. Note that certain combinations of families and links are not possible. Linear models
equivalent to those estimated by mundlak can be fitted in xthybrid by specifyng the family as 'gaussian' and the link as 'identity'.
The same can be accomplished by not specifying either of these options (i.e. linear models are the default).

cre estimates the model without transforming the original explanatory variables into cluster-mean deviations. In practice, when this option
is used xthybrid estimates a correlated random effect model as described in Mundlak (1978) (i.e. the Mundlak model). In the linear case, this can be expressed as:

Yij = A + B1*Zi + B2*Xij + B3*X_bari + vij

where B2 captures the within-cluster effect of cluster-varying variables on Yij, and B3 now captures the difference between the between-cluster
and within-cluster effects of cluster-varying variables on Yij. The within-cluster effects are denoted by variables with the prefix B__, the differences between
the between-and within-cluster effects are denoted by variables with the prefix D__, and the random effects are denoted by variables with the prefix R__.

nonlinearities(type) adds polynomial functions of the cluster means to the model. This option supports the following: quadratic, cubic, quartic.

randomslope(varlist) requests that random slopes are estimated on the random-effect and within-group coefficients of selected variables. Users need
only specify the name of the original variable. Note that estimation of these random slope models can be time consuming.

use(varlist) specifies the variables for which between- and within-cluster effects will be displayed in the model. The default is to
use all the variables in indepvars which vary within clusters. If the variables specified in use do not vary within clusters, xthybrid will
display a warning.

percentage(#) suppresses the separation of between- and within-cluster effects of variables for which within-cluster
variance accounts for a percentage of the total variance lower than #. When percentage is not specified xthybrid
operates as if # was 0. If use is also specified, xthybrid will evaluate the percentage of the total variance
which is within clusters for the variables set in this option.

test requests the results of tests of the random effect assumption for separate explanatory variables to be displayed. For the hybrid model,
these take the form: _b[B__varname] = _b[W__varname]. When the cre option is also specified, the tests take the form _b[D__varname] = 0.
When the test option is specified with the nonlinearities option, the results of tests of whether the nonlinear effects are equal to 0 are also shown.

full requests the full regression output for the estimated model.

stats allows users to request a different set of model summary statistics. This can include any scalars from Stata's meglm routine.

se requests the standard errors for the parameters on model variables to be reported. Note that specifying the option full overcomes this.

t requests the t-values for the parameters on model variables to be reported. Note that specifying the option full overcomes this.

p requests the p-values for the parameters on model variables to be reported. Note that specifying the option full overcomes this.

star requests that stars be used to denote statistically significant parameters on model variables at the 95 (5%), 99 (1%) and 99.9 (0.1%) levels.
Specyfying the star option overrules se, p and t. Note that specifying the option full overcomes this.

vce specifies the type of standard error to be reported. This option supports the following error types: 'oim', 'robust' and 'cluster' clustervar.

keepvars requests that any new variables created by the command are retained. The names for these new variables will begin with the prefix B__, W__ or R__.
Users will need to manually remove these variables from the data before executing xthybrid again.

iterations requests that the command is executed noisily.

meglmopts(list) enables the user to request additional options out of those available for the meglm command. Please note that not all
such options are compatible with xthybrid and that error messages produced by meglm will not be displayed.

Examples

. webuse nlswork, clear

. generate white = race==1 & race!=.

. xthybrid union age south white, clusterid(idcode) family(gaussian) link(identity)

. xthybrid union age south white, clusterid(idcode) family(gaussian) link(identity) cre

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) nonlinearities(cubic)

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) use(age)

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) percentage(45)

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) test

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) full

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) stats(N k df_m ll chi2 ll_c chi2_c df_c)

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) se t p

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) star

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) randomslope(age) star

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) randomslope(age) star iterations

. xthybrid union age south white, clusterid(idcode) family(binomial) link(logit) randomslope(age) cre star

Also see

Online: [R] meglm

Online: MUNDLAK - Stata module to estimate random-effects regressions adding group-means of independent variables to the model
https://ideas.repec.org/c/boc/bocode/s457601.html
. ssc install mundlak

References

Allison, P. D. (2009) "Fixed Effects Regression Models" Thousand Oaks

Mundlak, Y. (1978) "On the Pooling of Time Series and Cross-section Data" Econometrica, 46: 69-85

Schunck, R. (2013). "Within and Between Estimates in Random Effects Models: Advantages and Drawbacks of Correlated Random Effects and Hybrid Models".
Stata Journal, 13 (1): 65-76

Schunck, R. & Perales, F. (2017). "Within- and Between-Cluster Effects in Generalized Linear Mixed Models: A Discussion of Approaches and the xthybrid Command".
Stata Journal 17 (1): 89-115

Authors

Francisco Perales

School of Social Science, The University of Queensland

f.perales@uq.edu.au

Reinhard Schunck

School of Human and Social Sciences, University of Wuppertal

schunck@uni-wuppertal.de