Input
year | etype | category | value | avg_freq |
1996 | 1 | 1 | 25526966.0 | 8 |
1997 | 1 | 1 | 3266403.0 | 8 |
1998 | 1 | 1 | 1870628.0 | 8 |
Code:
import excel "\\inputdata.xlsx", firstrow case(lower)
levelsof category, l(smoothingcategory)
foreach i of local smoothingcategory {
keep if etype==1 & value != . & category==`i'
tsset year
tssmooth exponential smoothed=value, samp0(2) forecast(1)
gen parameter=r(alpha)
if (parameter > .5 & avg_freq > 50) {
drop smoothed parameter
tssmooth exponential smoothed=value, parms(.5) samp0(2) forecast(1)
gen parameter=r(alpha)
}
else if (avg_freq < 50 & parameter > .1) {
drop smoothed parameter
tssmooth exponential smoothed=value, parms(.1) samp0(2) forecast(1)
gen parameter=r(alpha)
}
replace category=`i' if missing(category)
}
Output
Can someone explain how "smoothed" and "parameter" are calculated? anyone have a formula they can share?
year | etype | category | value | avg_freq | smoothed | parameter |
1996 | 1 | 1 | 25526966 | 8 | 14396684 | 0.0001305 |
1997 | 1 | 1 | 3266403 | 8 | 14398137 | 0.0001305 |
1998 | 1 | 1 | 1870628 | 8 | 14396684 | 0.0001305 |
0 Response to how to calculate output of r(alpha) (short example included)?
Post a Comment