# Dynamic panel data model with treatment

Consider a simple dynamic panel model with a single lag: $$y_{it} = \alpha_i + x_{it}'\beta + \rho y_{i,t-1}+\epsilon_{it}$$

Now assuming that $$x_{it}$$ is most ordinary covariates, this can be estimated either using GMM (Arellano-Bond etc.) or using MLE (Moral-Benito, Allison, and Williams, see e.g. https://www3.nd.edu/~rwilliam/dynamic/Benito_Allison_Williams.pdf).

However, both STATA and R seem to throw errors if $$x_{it}$$ is a treatment variable that goes for some individuals between being $$0$$ at some $$t$$ and $$1$$ thereafter. For instance, if $$x_{it}$$ is whether individual $$i$$ at time $$t$$ has taken out a particular financial product, undertaken a training course, or had a job loss event yet. I can work out the programming problem by myself, but I wonder if its actually valid to run a model like this in that context? Can anyone explain why or why not, or point me to a paper where someone has run a model like this with a binary treatment indicator in a dynamic panel context?

• It's impossible to say why you're getting the error. Can you provide a screenshot or example of the structure of your data? What specifically is the error you get from R or STATA? Aug 15, 2023 at 17:33
• That's fair -- was trying to ask whether its conceptually possible or there's an obvious statistical problem I've missed. That said, an example is using the dpm package in R (which in turn calls lavaan) when running fit <- dpm(y ~ x, data=test, information="observed", id="pidp", wave="t") gives " lavaan ERROR: some variables have no values (only missings) or no variance", where x here is a treatment variable that is 0 if either you were never treated or before treatment time, and only 1 for the treatment group in the post-treatment period. Aug 16, 2023 at 13:52
• The y is a current account balance -- which can be zero for some or all the time periods for some individuals. Aug 16, 2023 at 13:53
• I don't know why the model needs anything more complicated than OLS as its written. The error you copied is not helpful for understanding the data or the model syntactically as you've supplied it. There are no latent variables, there are no random effects. Why call lavaan? Why even call lmer? Aug 16, 2023 at 15:08