I’m generating panel data and I am interested in generating a time-varying covariate that is correlated with previous values of a said covariate. For example, consider the variable x1 below:
panels <- fabricate( countries = add_level(N = 150, country_fe = runif(N, 1, 10)), years = add_level(N = 25, year_shock = runif(N, 1, 10), nest = FALSE), obs = cross_levels( by = join(countries, years), x1 = rnorm(N,0,1), new_variable = country_fe + year_shock*Ui + rnorm(N, 0, 2), Post = ifelse(tr==1 & years == '25', 1, 0) ) )
Instead of generating x1 at each year independent I want to generate it with a given correlation structure with prior x1 values that diminishes with time. Is it possible to do so in the fabricate call? Or am I better off generating it via mvnorm prior to fabricate and then plugging it in (as a long matrix)?