# Dynamic panel data models in Julia

**URL:** <https://discourse.julialang.org/t/dynamic-panel-data-models-in-julia/126979>\
**Category:** Finance and Economics\
**Tags:** econometrics, panel-data\
**Created:** [March 15, 2025, 12:01pm UTC](https://discourse.julialang.org/t/dynamic-panel-data-models-in-julia/126979 "2025-03-15T12:01:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![keynescoefen](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Post date:** [March 15, 2025, 12:01pm UTC](https://discourse.julialang.org/t/dynamic-panel-data-models-in-julia/126979/1 "2025-03-15T12:01:35Z")

</div>

Hello!  
Does anyone know whether any packages implement dynamic panel data models, like `xtabond` would in Stata?  
Thank you!

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [March 17, 2025, 11:35am UTC](https://discourse.julialang.org/t/dynamic-panel-data-models-in-julia/126979/2 "2025-03-17T11:35:47Z")

</div>

The FixedEffectsModels.jl package will let you estimate models using instrumental variables. I have used it to estimate models from Arellano-Bond.

---

<div class="post-metadata">

**Author:** ![keynescoefen](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Post date:** [March 17, 2025, 1:04pm UTC](https://discourse.julialang.org/t/dynamic-panel-data-models-in-julia/126979/3 "2025-03-17T13:04:26Z")

</div>

Thank you @mcreel how would I instruct the FixedEffectModels package so that they implement the GMM estimator?

I would like to implement a model like so

y\_{it} = \alpha y\_{it-1} + x\_{it} \beta + \eta\_{i} + \varepsilon\_{it}

and estimate it using AB’s GMM methodology. My data look like

 ![data](https://global.discourse-cdn.com/julialang/original/3X/9/a/9abffc02e667bd410d466a96c4f55b3bad6b92fa.png)

where `Country` and `Year` are individual and time indices.

What formula would implement AB if I want to use lagged values of `EVCentrality` as an instrument (here `L1` and `L2` for lag 1 and lag 2, respectively)?

I was thinking of something along those lines:  
`reg(formal,@formula(EVCentrality ~ (L1 ~ L2) + fe(Country)))`

Perhaps to make this answer even more useful for people other than myself (time permitting), it would be good to have a Julia implementation of the example from Section 6.1 from [here](https://cran.r-project.org/web/packages/pdynmc/vignettes/pdynmc-introLong.pdf).

That is reconstruct the formula (in `R`) and then it could even go into the documentation.

This is the `R` code I would like to translate:

```julia
data(EmplUK, package = "plm")
dat <- EmplUK
dat[,c(4:7)] <- log(dat[,c(4:7)])
names(dat[,c(4:7)]) <- c("n", "w", "k", "ys")
m1 <- pdynmc(dat = dat, varname.i = "firm", varname.t = "year",
use.mc.diff = TRUE, use.mc.lev = FALSE, use.mc.nonlin = FALSE,
include.y = TRUE, varname.y = "emp", lagTerms.y = 2,
fur.con = TRUE, fur.con.diff = TRUE, fur.con.lev = FALSE,
varname.reg.fur = c("wage", "capital", "output"),
lagTerms.reg.fur = c(1,2,2),
include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = "year",
w.mat = "iid.err", std.err = "corrected",
estimation = "onestep", opt.meth = "none")

```

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [March 17, 2025, 3:51pm UTC](https://discourse.julialang.org/t/dynamic-panel-data-models-in-julia/126979/4 "2025-03-17T15:51:33Z")

</div>

Some code which estimates a similar model is here: [Econometrics/PracticalSummaries/20-PanelData.jl at main · mcreel/Econometrics · GitHub](https://github.com/mcreel/Econometrics/blob/main/PracticalSummaries/20-PanelData.jl)

This sets up regressors and instruments. The results very similar but not identical to what I get from the GRETL package. I think that the differing treatment of missings accounts for this, as well as the way covariances are estimated, perhaps. I haven’t gone into it in detail, though. So, please treat this as a starting point, but perhaps with some corrections/improvements needed.
