I have a panel data set for individual i=1,2,…,n. The panel is unbalanced, so individual i shows up in the data Ti times, leading to a total of N=T1+T2+…+Tn observations. I also have a n*1 matrix of individual fixed effects, i.e. A=[theta1, theta2, …, theta_n]'. Then, I want to create a N*1 matrix B of individual fixed effects that fit into the original panel.
For example, if T1=3, T2=1, T3=2,…, my goal is to create B=[theta1, theta1, theta1, theta2, theta3, theta3, …]'. I can create B using a loop, but n is too big to rely on coding with a loop. Is there any efficient vectorization way to overcome this hurdle?
Thank your very much for your help.
Best Answer