I'm looking for a way to concisely and flexibly simulate cross-lag panel data in R.
Considering a 2-variable use case for X and Y over some arbitrary number of time units n, I'd like to be able to specify:
- Autoregressive relationships for each variable independently (so, AR(1) for each of X & Y)
- Overall mean for each variable
- Variance for each variable
- Cross-lagged relationships between X and Y (so, the b in X_n = b * Y_(n-1), and vice versa)
- [less important, but useful] Change over time (slope from 1 to n for each variable)
The single-variable version of this seems possible with something like arima.sim()
, but I'm not sure how to best to approach this in the multivariate case.
Custom approaches are fine, but any packages implementing a solution would be even better.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…