Estimating covariate effects after gmm

In Stata 14.2, we added the ability to use margins to estimate covariate effects after gmm. In this post, I illustrate how to use margins and marginsplot after gmm to estimate covariate effects for a probit model.

Margins are statistics calculated from predictions of a previously fit model at fixed values of some covariates and averaging or otherwise integrating over the remaining covariates. They can be used to estimate population average parameters like the marginal mean, average treatment effect, or the average effect of a covariate on the conditional mean. I will demonstrate how using margins is useful after estimating a model with the generalized method of moments.

In addition to the model parameters \({\boldsymbol \beta}\), we may also be interested in the change in \(y_i\) as we change one of the covariates in \({\bf x}_i\). How do individuals that only differ in the value of one of the regressors compare?

Suppose we want to compare differences in the regressor \(x_{ij}\). The vector \({\bf x}_{i}^{\star}\) is \({\bf x}_{i}\) with the \(j\)th regressor \(x_{ij}\) replaced by \(x_{ij}+1\).

The effect of a unit change in \(x_{ij}\) on \(y_i\) at \({\bf x}_i\) is

The standard error for this mean effect needs to be adjusted for the estimation of \({\boldsymbol \beta}\). We can use gmm to estimate \({\boldsymbol \beta}\) and then use margins to estimate \(\delta\) and its properly adjusted standard error. This provides flexibility. You can estimate a model with few moment conditions and then estimate multiple margins.

Covariate effects

We estimate the mean effects for a probit regression model using gmm and margins from simulated data. We regress the binary \(y_i\) on binary \(d_i\) and continuous \(x_i\) and \(z_i\). A quadratic term for \(x_i\) is included in the model, and we interact both powers of \(x_i\) and \(z_i\) with \(d_i\).

First, we use gmm to estimate \({\boldsymbol \beta}\). Factor-variable notation is used to specify the quadratic power of \(x_i\) and the interactions of the powers of \(x_i\) and \(z_i\) with \(d_i\).

Now, we use margins to estimate the mean effect of changing \(x_i\) to \(x_i+1\). We specify vce(unconditional) to estimate the mean effect over the population of \(x_i\), \(z_i\), and \(d_i\). The normal probability expression is specified in the expression() option. The expression function xb() is used to get the linear prediction. We specify the at(generate()) option and atcontrast(r) under the contrast option so that the expression at \(x_i\) will be subtracted from the expression at \(x_i+1\). nowald is specified to suppress the Wald test of the contrast.

Unit changes are particularly useful for evaluating the effect of discrete covariates. When a discrete covariate is specified using factor-variable notation, we can use contrast notation in margins to estimate the covariate effect.

We estimate the mean effect of changing from \(d_i=0\) to \(d_i=1\) over the population of covariates with margins. We specify the contrast r.d and the conditional mean in the expression() option. The expression will be evaluated at \(d_i=0\) and then subtracted from the expression evaluated at \(d_i=1\). We specify contrast(nowald) to suppress the Wald test of the contrast.

So on average over the population, changing from \(d_i=0\) to \(d_i=1\) and keeping other covariates constant will increase the probability of success by 0.14.

Graphing covariate effects

We have used margins to estimate the mean covariate effect over the population of covariates. We can also use margins to estimate covariate effects at fixed values of the other covariates or to average the covariate effect over certain covariates while fixing others. We may examine multiple effects to find a pattern. The marginsplot command graphs effects estimated by margins and can be helpful in these situations.

Suppose we wanted to see how the effect of a unit change in \(d_i\) varied over \(x_i\). We can use margins with the at() option to estimate the effect at different values of \(x_i\), averaged over the other covariates. We suppress the legend of fixed covariate values by specifying noatlegend.

So the effect increases over small \(x_i\) and decreases as \(x_i\) grows large. We can use margins and marginsplot again to examine the conditional means at different values of \(x_i\). This time, we specify the over() option so that separate predictions are made for \(d_i=1\) and \(d_i=0\). We expect to see the lines cross at a certain point, as the covariate effect crossed zero in the previous plot.

We see that the conditional means for \(d_{i}=0\) rise above the means for \(d_{i}=0\) at slightly below \(x_i = 1.75\).

Differential effects

Instead of a unit change, we may be interested in the differential effect. This is the normalized effect on the mean of a small change in the covariate, the derivative of the mean with regard to the covariate \(x_{ij}\). This is called the marginal or partial effect of \(x_{ij}\) on \(E(y_i\vert {\bf x}_i)\). See section 2.2.5 of Wooldridge (2010), section 5.2.4 of Cameron and Trivedi (2005), or section 10.6 of Cameron and Trivedi (2010) for more details. We can estimate the partial effect using margins, at fixed values of the regressors, or the mean partial effect over the population or sample.

We will use margins to estimate the mean marginal effects for the continuous covariates over the population of covariates. margins will take the derivatives for us if we specify dydx(). We only need to specify the form of the prediction. We again use the expression() option for this purpose.