*! version 1.0.0 march2026

Title

margins_dynxteprobit -- Marginal effects for a dynamic xteprobit with attrition.

Syntax

margins_dynxteprobit
[if] [in]
,
[options]

Main
dydx(var) estimates continuous marginal effect of variable in var

diff(var = num1 num2) estimates marginal effect of discrete variable in var from num1 to num2

at(atlist) estimates marginal effects at specified values of the covariates*

Reporting
post post margins and their VCE as estimation results

*atlist can only specify at most one value for each specified covariate.

Description

margins_dynxteprobit is a post-estimation command that produces marginal effects estimates following a dynamic xteprobit model with endogenous attrition as proposed and studied by Carlson and Semykina (2026).

In using the xteprobit command for a dynamic xteprobit model with endogenous attrition, estimation occurs on a subset of the data, the time periods that are observed and only the first time period of attrition. The margins command is confined to compute marginal effects on this subset sample. The margins_dynxteprobit command computes unconditional marginal effects (not conditional on non-attrition) averaged over the entire sample.

The default is calculating marginal effects with respect to the binary lagged dependent variable in the dynamic model. Other capabilities include estimating marginal effects of other continuous variables (evaluated at fixed values of the lagged binary dependent variable); estimating marginal effects of discrete variables as specified differences (evaluated at fixed values of the lagged biinary dependent variable); and estimating marginal effects at specified values of the covariates.

Options

Main

dydx(var) requests that the marginal effects be computed as a derivative with respect to var rather than the lagged dependent variable. Marginal effects are evaluated for the lagged dependent variable equal to 0 and 1. At most, either dydx() or diff() option may be specified but not both.

diff(var = (num1 num2)) requests that the marginal effects be computed as a difference with respect to var from num1 to num2 rather than the lagged dependent variable. Marginal effects are evaluated for the lagged dependent variable equal to 0 and 1. At most, either dydx() or diff() option may be specified but not both.

at(atlist) specifies values for covariates to be treated as fixed. By default, margins are calculated by averaging over observed values of covariates.

at(age = 20) fixes covariate age to the value specified.

at(age = 20 sex = 1) fixes covariate age and sex to the values specified.

Current version of the command can only accomodate a single specified value for each covariate (not a numlist).

Reporting

post causes margins_dynxteprobit to behave like a Stata estimation (e-class) command. margins_dynxteprobit posts the vector of estimated margins along with the estimated variance-covariance matrix to e(), so you can treat the estimated margins just as you would results from any other estimation command. For example, you could use test to perform simultaneous tests of hypotheses on the margins, or you could use lincom to create linear combinations.

Examples

Setup

. webuse womenhlthre, clear

. xtset personid year

. bysort personid: replace select = 0 if select[_n-1] == 0 // Generates selection indicator as attrition so the first time an individual is unobserved for a time period, they leave the sample.

. generate goodhlth = health>3 if select == 1 // Generate the outcome variable with attrition.

. bysort personid: generate attrit = select[_n-1] != 0 // Generate an attrition indicator that is a binary variable equal to 1 if the outcome is observed or it is the first instance of attrition.

Obtain marginal effects estimates when restricted to the attrition sample using margins command. (Note: xteprobit is more likely to converge when extra data is dropped rather than using if condition.)

. preserve

. keep if attrit == 1

. xteprobit goodhlth l.i.goodhlth exercise grade, select(select = exercise grade regcheck)

. margins, dydx(1L.goodhlth)

. restore

Obtain marginal effects with respect to lagged dependent variable over the entire sample. Note that the lagged dependent variable must be specified with factor notation (l.i.dependvar) and must be listed as first independent variable in the preceding xteprobit command.

. margins_dynxteprobit

Obtain marginal effects estimates when restricted to the attrition sample using margins_dynxteprobit command.

. margins_dynxteprobit if attrit == 1

Obtain marginal effects with respsect to continuous covariate.

. margins_dynxteprobit, dydx(grade)

Obtain marginal effects with respect to discrete covariate from one value in the support to another.

. margins_dynxteprobit, diff(exercise = (0 1))

Obtain marginal effects with respect to lagged dependent variable at specific covariate values.

. margins_dynxteprobit, at(exercise = 0 grade = 12)

Obtain marginal effects with estimates stored in e(), then testing with the estimates.

. margins_dynxteprobit, dydx(grade) post

. test 1._at = 2._at

Stored results

margins_dynxteprobit stores the following in e():

Scalars

e(N) number of observations

Macros

e(cmd) margins_dynxteprobit

e(estimator) xteprobit

e(title) title in estimation output

e(vcetype) title used to label Std. Err.

e(properties) b V

Matrices

e(b) estimates

e(V) variance-covariance matrix of the estimates

Functions

e(sample) estimation sample

Author

Alyssa H. Carlson
Department of Economics, University of Missouri

carlsonah@missouri.edu
https://carlsonah.mufaculty.umsystem.edu/

References

Carlson, A. H., and Semykina, A. 2026.
Addressing Attrition in Nonlinear Dynamic Panel Data Models with an Application to Health.
Working Paper.
URL: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5190611