I wanna simulate an AR process like this (see section 2).


I've tried this
Code:
clear


set obs 200


cls


set seed 1


egen id = seq(), f(1) t(20) b(10)

expand 10

bys id: g time = _n

xtset id time, g


// 20 units, 100 periods each


// R CODE: x1 <- 100 + arima.sim(model = list(ar = 0.999), n = 100)


bys id: g x = 100 +runiform()

bys id: g y = 1.2 * x + runiform()



cls

line y time if id ==4
But I don't know how to simulate an AR process in the x variable. How might I do this?

Note that I want this (as my code implies) to be a panel dataset, where multiple units have their own AR process. At present, the one I've created is noisier than I'd like, and I suspect knowing how to create an AR(1) term might be the key here.