I would like to calculate relative_all forecast accuracy and I intend to use the following code. However, it spends too much time (1 year/day). I am wondering is there any better/efficient way to do this? Thank you so much.
gen max_relative_fe_all =.
gen min_relative_fe_all =.
su fiscal_year
scalar a= r(min)
scalar b= r(max)
forvalues i= `=scalar(a)'/`=scalar(b)' {
vallist gvkey if fiscal_year ==`i'
local d=r(list)
foreach k in `d' {
vallist analys if fiscal_year ==`i' & gvkey==`k'
local c=r(list)
foreach j in `c' {
su absoluteFE if analys!=`j' & fiscal_year==`i' & gvkey==`k'
replace max_relative_fe_all=r(max) if analys==`j' & fiscal_year==`i' & gvkey==`k'
replace min_relative_fe_all=r(min) if analys==`j' & fiscal_year==`i' & gvkey==`k'
di `i'
di `j'
di `k'
}
}
}
Related Posts with rewriting the code
Xtreg, illustrate regression in graph?Friends, I have a panel data set, looking like: Units Variable Year Unit 1 5 2000 Unit 1 2 2001 Un…
tabulate two variables to show the value of a third variable; save dataset as matrix; multiple plots using plotmatrixHi all, I have data: Code: * Example generated by -dataex-. To install: ssc install dataex clear…
Out-of-sample logit: applying estimated coefficients on a new series (w/o observing 0s/1s)Hello STATA community, This is both a methodological question and a programming question, for which…
Fixed-Effect Poisson with an Instrumental VariableHi, I have an unbalanced panel (N=1,350 and T=130), and an outcome variable that is a count (around…
Assessing agreement in several binary variables in longitudinal datasetHi all! I've got a longitudinal dataset that consists of binary "ratings" collected from participant…
Subscribe to:
Post Comments (Atom)
0 Response to rewriting the code
Post a Comment