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
Recoding into an existing variableHello, I am trying to add text responses to an existing variable. I have a variable Q33_20_TEXT th…
Confusion about FE and DIDHello everyone, this is my first post here so please excuse me if the formatting is not great yet. I…
plotting interaction after XTSCC commandHow do I plot interactions after the XTSCC command? …
3 Level Hierarchical Models in STATA; Null model failed to convergeAbout the Dataset I am working with DHS (Demographic and Health Survey Data) data. DHS uses a two-s…
Collapse (count) ifDear Stata Users My data is in a panel format at the daily frequency (id, date). I run time-series …
Subscribe to:
Post Comments (Atom)
0 Response to Operations over lags
Post a Comment