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
Subgroups with coefplot allowing each graph to have its own scale and adjust location of legendDear all I am using the following code to create a graph with 5 plots: Code: coefplot (hba1c1, …
Spatial Panel Data TestsHello, I am relatively new to Stata and have been estimating different spatial panels, such as the …
Conditional drop if command within a certain firm year levelHi, I am working on my master thesis and I am currently busy with the data cleaning process. One of…
Missing Axis Labels only for some GraphsDear All I am working with a simple panel dataset of 40 individuals' characteristics over 2000 to 2…
insheeting excel files using loop and extracting filename as variable valueHello, I am trying to use insheet multiple .xlxs files and then extract filename. This is my code: …
Subscribe to:
Post Comments (Atom)
0 Response to Operations over lags
Post a Comment