Hello
I am trying to find the standard deviation (i.e. volatility) of the monthly stock market returns.
Below is my data where date2 is basically date in %tm format - I dont know why it's not displaying it here properly but 336 = 1988m1, 337=1988m2, 338 = 1988m3 ... etc.
lsp is the log of the s&p 500 index
lret is the returns calculated from lsp by:
I have declared the data to be time series by
Whenever I enter the code
I get basically no values and the entire comes up as "348 missing values generated". What am I doing wrong here?
I was replicating someone else's code who converted the daily returns to monthly and then calculated the volatility by the same codes and this problem does not seem to be coming up there.
Thank you!
I am trying to find the standard deviation (i.e. volatility) of the monthly stock market returns.
Below is my data where date2 is basically date in %tm format - I dont know why it's not displaying it here properly but 336 = 1988m1, 337=1988m2, 338 = 1988m3 ... etc.
lsp is the log of the s&p 500 index
lret is the returns calculated from lsp by:
Code:
gen lret = D.lsp
Code:
tsset date2
Code:
egen monsd= sd(lret), by(date2)
I was replicating someone else's code who converted the daily returns to monthly and then calculated the volatility by the same codes and this problem does not seem to be coming up there.
Thank you!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double date2 float(lsp lret) 336 5.508376 . 337 5.585299 .07692337 338 5.602045 .016746044 339 5.570784 -.031260967 340 5.539615 -.03116894 341 5.633396 .09378052 342 5.59326 -.04013538 343 5.573294 -.019966125 344 5.624053 .05075932 345 5.676309 .05225515 346 5.627945 -.04836369 347 5.663551 .035605907 348 5.688466 .02491474 349 5.719295 .03082943 350 5.710824 -.008470535 351 5.781792 .070967674 352 5.81434 .032547474 353 5.846554 .03221464 354 5.872231 .02567625 355 5.90206 .029829025 end format %tm date2
Comment