The structure of my data is as follows (simpliefied example)
id
date
x
id date x
1 1 3214324
1 2 3456435
1 3 3253455
1 4 345435
....
1 T 345435
.
.
.
2 1 323424
2 2 346435
2 3 6563455
2 4 564546
....
2 T 3532
.
.
.
3 1 324524
3 2 126435
3 3 363455
3 4 54546
....
3 T 32245
.
.
.
N 1 324524
N 2 126435
N 3 363455
N 4 54546
....
N T 34345
What I want is a rolling window correlation between the realizations of x across ids at each date so, for example between the first n observations of x where id==1 and the first n observations where id==2, and the the first n observations of x where id==1 and the first n observations where id==3, and so on. at each date.
Do I need to reorganize the data to have variables such as id1x and id2x with unique identifier date for one observation? if so, how do I do it ideally?
Thanks for your help!
Best,
Guenther
id
date
x
id date x
1 1 3214324
1 2 3456435
1 3 3253455
1 4 345435
....
1 T 345435
.
.
.
2 1 323424
2 2 346435
2 3 6563455
2 4 564546
....
2 T 3532
.
.
.
3 1 324524
3 2 126435
3 3 363455
3 4 54546
....
3 T 32245
.
.
.
N 1 324524
N 2 126435
N 3 363455
N 4 54546
....
N T 34345
What I want is a rolling window correlation between the realizations of x across ids at each date so, for example between the first n observations of x where id==1 and the first n observations where id==2, and the the first n observations of x where id==1 and the first n observations where id==3, and so on. at each date.
Do I need to reorganize the data to have variables such as id1x and id2x with unique identifier date for one observation? if so, how do I do it ideally?
Thanks for your help!
Best,
Guenther
Comment