Viewing 7 posts - 1 through 7 (of 7 total)
• Author
Posts
• APARECIDA DE FATIMA ALVES DE LIMA
Guest
Post count: 118

Can you please help me to calculate the standard deviation of the moving average of the last 4 years of ebitda, in an 18-year data panel?

Attaullah Shah
Keymaster
Post count: 69

This can be easily done using asrol. Let’s assume that your panel identifier is id and time identifier is year. The asrol code you would use is given below.

bysort id : asrol ebitda, gen(sd_ebitda) stat(sd) window(year 4) min(4)

The min(4) option ensures that at least 4 observations are available for the calculation of the standard deviation.

APARECIDA DE FATIMA ALVES DE LIMA
Guest
Post count: 118

very good! I will follow this path. Thanks!!

APARECIDA DE FATIMA ALVES DE LIMA
Guest
Post count: 118

Thanks, I have got the results.

___________________________________________________
EBITDA_w	empresa	        ano2	sd_EBITDA_w
___________________________________________________
0	        524 Particip	2001
.6949924	524 Particip	2002
.7736318	524 Particip	2003
.2955975	524 Particip	2004	.36091502
.1612284	524 Particip	2005	.29891669
.2536765	524 Particip	2006	.27420603
.1506352	524 Particip	2007	.07077126
.1462069	524 Particip	2008	.05088494
.254717	        524 Particip	2009	.06109785
3.082896	524 Particip	2010	1.4503886
3.342857	524 Particip	2011	1.7430165
.7713718	524 Particip	2012	1.576531
.1252485	524 Particip	2013	1.6212501
.5900621	524 Particip	2014	1.4494201
.4056225	524 Particip	2015	.27580191
.7866667	524 Particip	2016	.28136591
1.56	        524 Particip	2017	.50738521
1.430107	524 Particip	2018	.54438681
_________________________________________________
APARECIDA DE FATIMA ALVES DE LIMA
Guest
Post count: 118

Hello! now i need to calculate only the moving average of the last 4 years of the ebitda value, in an 18-year data panel. Can you help me please?

Attaullah Shah
Guest
Post count: 118

The code is the same as used in my earlier reply. That calculates the moving average of the last 4 years. If you want to exclude the current year, then the code would be:

bysort id : asrol ebitda, gen(sd_ebitda) stat(sd) window(year 5) min(4) xf(focal)

APARECIDA DE FATIMA ALVES DE LIMA
Guest
Post count: 118

thank you for your reply. Maybe I didn’t ask the right question. In my panel what I need now is the average of the absolute value of the ebitda, for the same period. I need to build a variable with:
= sd_ebitda / ma_ebitda

Viewing 7 posts - 1 through 7 (of 7 total)
• You must be logged in to reply to this topic.