I want to calculate exponentially weighted moving average of past performance in an unbalanced panel dataset. Panel variable is firm_id and time variable is year. The time period is between 2010 and 2015 (six years). I have been trying to compute the exponentially weighted average of past performance. Thus, I picked tssmooth exponential. However, when I applied the tssmooth exponential, all the firms without all six-year observations generated missing values for the exponential smoothed performance. For example, if Firm 2 has only 2010, 2011, and 2012, the exponentially weighted average of past performance for Firm 2 will be missing. I get stuck on how to deal with these missing values because they are a lot (about 40% in my data). Are there any other ways to compute the exponentially weighted average of past performance? I am looking forward to any suggestions! Thank you in advance!
Here is sample data:
Code:
*To install: ssc install dataex clear input int year int firm_id float performance 2010 1 0.053 2011 1 0.075 2012 1 0.088 2013 1 0.036 2014 1 0.049 2015 1 -0.109 2010 2 0.464 2011 2 -0.014 2012 2 -0.002 2010 3 0.120 2012 3 0.018 2010 4 0.038 2011 4 0.045 2012 4 0.051 2013 4 0.127 2014 4 0.057 2015 4 0.059 2010 5 0.134 2011 5 0.117 end
Code:
tsset firm_id year tssmooth e double p1=performance, parms(0.1) tssmooth e double p2=performance, parms(0.2) tssmooth e double p3= performance, parms(0.3) tssmooth e double p4= performance, parms(0.4) tssmooth e double p5= performance, parms(0.5) tssmooth e double p6= performance, parms(0.6) tssmooth e double p7= performance, parms(0.7) tssmooth e double p8= performance, parms(0.8) tssmooth e double p9= performance, parms(0.9)
Array
0 Response to Calculate Exponentially Weighted Moving Average for Unbalanced Panel Data
Post a Comment