I have tried to generate rolling 5th percentile of the variable rateofreturn using tsegen(SSC).
Code:
tsegen pct = rowpctile(L(0/59).rateofreturn,24),p(5)
The result that I get, however, does not match when I do it in Excel. For example, in row 60 Stata gives -.045 whereas Excel gives .1215. Is something wrong with my code?
Code:
tsegen pct = rowpctile(L(0/59).rateofreturn,24),p(5)
The result that I get, however, does not match when I do it in Excel. For example, in row 60 Stata gives -.045 whereas Excel gives .1215. Is something wrong with my code?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(mdate id) double rateofreturn float pct 420 1 .48 . 421 1 .89 . 422 1 1.18 . 423 1 1 . 424 1 1.5 . 425 1 1.6 . 426 1 1.3 . 427 1 1.01 . 428 1 1.44 . 429 1 1.55 . 430 1 1.2 . 431 1 1.51 . 432 1 .97 . 433 1 1.21 . 434 1 .42 . 435 1 .82 . 436 1 1.14 . 437 1 1.09 . 438 1 .18 . 439 1 .62 . 440 1 1.24 . 441 1 1.18 . 442 1 .85 . 443 1 1 .42 444 1 .7 .42 445 1 .84 .42 446 1 .66 .42 447 1 .82 .42 448 1 .71 .42 449 1 1.38 .42 450 1 2.28 .42 451 1 .86 .42 452 1 .66 .42 453 1 .96 .42 454 1 .75 .42 455 1 .76 .42 456 1 .77 .42 457 1 .78 .42 458 1 1.03 .42 459 1 .39 .405 460 1 .43 .42 461 1 .34 .39 462 1 .58 .39 463 1 -.43 .34 464 1 -.55 .18 465 1 -.23 -.23 466 1 1.27 -.23 467 1 1.05 -.23 468 1 1.38 -.23 469 1 .75 -.23 470 1 1.53 -.23 471 1 1.61 -.23 472 1 .51 -.23 473 1 .53 -.23 474 1 .71 -.23 475 1 .14 -.23 476 1 .4 -.23 477 1 .45 -.23 478 1 .89 -.23 479 1 1.53 -.045 480 1 .9 -.045 481 1 1.98 -.045 482 1 .21 -.045 483 1 -.09 -.16 484 1 .1 -.16 485 1 1.01 -.16 486 1 .67 -.16 487 1 .48 -.16 488 1 1 -.16 489 1 .28 -.16 490 1 .05 -.16 491 1 .5 -.16 492 1 1.94 -.16 493 1 1.44 -.16 494 1 1.64 -.16 495 1 1.36 -.16 496 1 -.31 -.27 497 1 -.07 -.27 498 1 .85 -.27 499 1 1.53 -.27 500 1 .4 -.27 501 1 .92 -.27 502 1 .58 -.27 503 1 .21 -.27 504 1 .91 -.27 505 1 -.31 -.31 506 1 .56 -.31 507 1 .75 -.31 508 1 -.13 -.31 509 1 .32 -.31 510 1 -1.6 -.37 511 1 -.77 -.49 512 1 1.57 -.49 513 1 .77 -.49 514 1 2 -.49 515 1 2.02 -.49 516 1 3.45 -.49 517 1 1.02 -.49 518 1 1.09 -.49 519 1 1.22 -.49 end format %tm mdate
Comment