Hi, I'm doing a monte carlo experiment to create some panel data.
To do this i need a colum vector for the ID and time_ID of the observations (together with the y and x values which should have been correctly calculated - not included)
I made the following loop:
id and time_id have both been created before the loop begins with the dimensions [N*T, 1]
T is 50 and sample size N differs, but let's say it's 100 this time.
The time_id column vector looks exactly like I want, with the first 100 observations = 1, the next 100 = 2 and etc.
The column vector id doesn't, however, and I can't seem to grasp why.
In this, the first 50 observations are listed as id = 1, the next 50 id = 2 and etc until obs. 4951-5000 where id = 100.
I would like the first 100 observations, corresponding to the 100 people in the sample at T = 1, to have the id from 1-100 and then repeat until end.
Any help is appreciated
To do this i need a colum vector for the ID and time_ID of the observations (together with the y and x values which should have been correctly calculated - not included)
I made the following loop:
Code:
// Loop for the time period for(t=1; t<=T;t++) { // Loop for sample size for(i=1; i<=N;i++) { id[(t-1)*N+i,1] = i time_id[(t-1)*N+i,1] = t } }
T is 50 and sample size N differs, but let's say it's 100 this time.
The time_id column vector looks exactly like I want, with the first 100 observations = 1, the next 100 = 2 and etc.
The column vector id doesn't, however, and I can't seem to grasp why.
In this, the first 50 observations are listed as id = 1, the next 50 id = 2 and etc until obs. 4951-5000 where id = 100.
I would like the first 100 observations, corresponding to the 100 people in the sample at T = 1, to have the id from 1-100 and then repeat until end.
Any help is appreciated
Comment