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
Multinomial Logit ModelingGreetings- I am looking for some advice on a multinomial logit model with marginal effects. The mod…
how to suppress display of the interval from -1 to 1 of x-axisHere is the code: Code: * Example generated by -dataex-. To install: ssc install dataex clear inpu…
keep variable with condition and time seriesHi all: I want to keep variable use condition with next year and last year data. Sample ID YEA…
Logistic regression with Effect Modification or Mantel-HaenszelHello. I'm trying to find an association between Sex of child and Exposure to or having a Defect fro…
Forval loop invalid syntaxHello, I am using forval code as below and then it says it is 'invalid syntax'. I checked that all …
Subscribe to:
Post Comments (Atom)
0 Response to rewriting the code
Post a Comment