I have panel data, the time-variable is id, and value-variable is Time: xtset time id, monthly
I need to sort id into 5 groups/portfolios at each month t based on variable x(volatility) from low to high.
after I get 5 groups including different id in each group, I want to calculate the return (variable y) for each group (sorted in the month t) in next month. "the return for each group" means the average of returns of each id in each group. The groups is sorted in month t, the return I want to get is in month t+1.
I would be really grateful if some one could help me to figure out the command.
I need to sort id into 5 groups/portfolios at each month t based on variable x(volatility) from low to high.
after I get 5 groups including different id in each group, I want to calculate the return (variable y) for each group (sorted in the month t) in next month. "the return for each group" means the average of returns of each id in each group. The groups is sorted in month t, the return I want to get is in month t+1.
I would be really grateful if some one could help me to figure out the command.
Comment