Hello,
I need to do some operations over all the lags up to the current value, but the loop I wrote takes forever, could you please tell me how to speed it up?
levelsof permno, local(levels)
foreach lev of local levels {
gen l1_new=(retex-b_cons-b_mktrf*mktrf)*(mktrf-mktrf_mean)^2
local lag=_n
forval i=1/`lag'-1{
replace l1_new=l1_new+(l`i'.retex-b_cons-b_mktrf*l`i'.mktrf)*(l`i'.mktrf-mktrf_mean)^2
}
}
Thank you in advance,
Alina
Later edit: I am also getting errors in the code, but I don't know why.
Related Posts with Operations over lags
Log variableHi I am working with panel data (T = 23 and N (countries) = 22), I'd like to now when shouk i take…
Prepare data in order to create value weighted returns.Dear all, I am currently working on my last steps in my master thesis. I calculated buy and hold- an…
ivprobit produces same coef and se for marginal effectThis problem seems to be present in any dataset but I will give an example from Stata official datas…
correct marginal effects after ivprobitDear all, Couple of recent posts point out difficulties obtaining the marginal effects after IVprobi…
prepare date in order to create value weighted returnsDear all, I am currently working on my last steps in my master thesis. I calculated buy and hold- an…
Subscribe to:
Post Comments (Atom)
0 Response to Operations over lags
Post a Comment