Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Weighted standard deviation calculation

    Dear statalisters,

    I hope someone here is able to help me find out how to calculate a weighted standard deviation. I have included a datasample by Dataex at the end of this post, as it's rather long.

    I've got panel data on stock performance, firms are identified with an id and have observations for each year. I've calculated Abnormal Returns (AR) and sorted stocks from low to high in quintiles by the variable CI (CI_quintile). My aim is to show the abnormal returns to an investment strategy that invests into all the stocks listed in a CI_quintile. The problem is, if I invest a single Dollar into the portfolio this dollar is divded over all these stocks according to their portfolio weight (varname = weight), because a large company makes up a larger share of the portfolio of course.

    An individual stock's weighted Abnormal Return is weight * AR = wAR.

    When doing descriptive statistics, I can do for example:
    Code:
    tabstat AR, by(CI_quintile) statistics(count mean semean median max min) columns(statistics)
    This will show me the unweighted mean, median and standard deviation for each CI_quintile.

    If I want to look at the outcome of a portfolio strategy, I use the following code to calculate the yearly weighted return of an investment strategy into each CI_quintile and create the table below:
    Code:
    gen wAR = weight * AR
    bysort year CI_quintile: egen weighted_total_AR = sum(wAR)
    tabstat weighted_total_AR, by(CI_quintile) statistics (mean semean median max min)
    
    //Because weighted_total_AR is an average, but egen generates observations for all. I just want to look at the first occurence of weighted_total in each year/group.
    bysort year CI_quintile: egen first = _n
    tabstat weighted_total_AR if first ==1, by(CI_quintile) statistics (mean semean median max min)
    Click image for larger version

Name:	temp.PNG
Views:	2
Size:	13.3 KB
ID:	1457737





    But, the standard deviation displayed in the second column is not the right one. This is calculated using the variance between the mean returns of the portfolios.

    What I'm actually interested in is the weighted portfolio standard deviation. I can calculate this for each year's portfolio by hand, doing this:
    Click image for larger version

Name:	formula.PNG
Views:	2
Size:	6.8 KB
ID:	1457738





    In which 'w' is the weight of a stock in a portfolio, 'M' is equal to 'N' for me. and 'x' are means. The standard deviation of a group CI_quintile should then be the average those individual standard deviations calculated with that formula.

    Doing it by hand is not an option for me, as I will need to do it for a lot of portfolios. Is the only option in Stata to calculate this weighted standard deviation by typing the formulas in by hand?
    I'm hoping someone can help me find a quick way or trick to do this! I've searched the help pages for additional options in calculating standard deviations, etc. but I was unable to find what I'm looking for.

    Data example below, I've made it this long so there's stocks of each quintile in it.
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float id int year float(CI_quintile weight AR wAR)
    7458 1988 1 .003308191 .04755842 1.5733234e-06
    7348 1988 1 .01979438 27.21212 .00538647
    5423 1988 1 .006723564 -25.21848 -.0016955804
    3706 1988 1 .005498273 -3.8384776 -.00021104998
    7495 1988 1 .005953363 40.70152 .002423109
    5709 1988 1 .006956758 26.44152 .0018394728
    7683 1988 1 .002354228 43.05568 .0010136289
    5940 1988 1 .004853771 -7.738739 -.0003756207
    7496 1988 1 .00430986 -12.85874 -.0005541937
    5533 1988 1 .001597837 -27.52244 -.0004397637
    5821 1988 1 .006222964 1.7612606 .00010960262
    5711 1988 1 .02864698 38.50694 .011031074
    7209 1988 1 .007841516 -36.861877 -.00289053
    6417 1988 1 .011576707 -25.737875 -.002979598
    5486 1988 1 .014225017 -34.136192 -.004855879
    5894 1988 1 .0027281865 -36.06244 -.0009838507
    7097 1988 1 .0010399593 -25.13244 -.00026136715
    6978 1988 1 .0019874882 -65.942444 -.0013105983
    5840 1988 1 .00982461 12.952124 .0012724957
    8354 1988 1 .02637184 31.396776 .008279908
    5398 1988 1 .004116211 35.78768 .0014730964
    6304 1988 1 .008858877 -9.938478 -.0008804376
    5949 1988 1 .009482821 21.666206 .0020545677
    5872 1988 1 .04225229 -5.378726 -.002272635
    7206 1988 1 .02326138 -18.393063 -.00427848
    7385 1988 1 .009919709 -18.677795 -.0018527828
    6141 1988 1 .010994663 -21.157877 -.0023262373
    6816 1988 1 .00971225 -34.093796 -.0033112746
    5848 1988 1 .005435659 -11.66874 -.0006342728
    7264 1988 1 .008940009 91.58195 .008187435
    5501 1988 1 .02630546 -9.908727 -.002606536
    8194 1988 1 .0015744547 116.97 .0018416398
    7954 1988 1 .0006245719 -24.11289 -.00015060234
    5524 1988 1 .0018336992 -42.28289 -.000775341
    7757 1988 1 .012448753 59.1412 .007362343
    6032 1988 1 .03246628 111.37627 .036159735
    7085 1988 1 .005526206 -4.744877 -.00026221166
    7083 1988 1 .00499736 18.115747 .000905309
    6821 1988 1 .000877853 19.46686 .0001708904
    7031 1988 1 .004767775 -64.56488 -.003078308
    8037 1988 1 .0007281441 -20.45289 -.00014892654
    3976 1988 1 .002622888 19.17756 .0005030059
    6948 1988 1 .06607924 32.777126 .021658873
    8446 1988 1 .0042028353 -63.46425 -.002667298
    5475 1988 1 .004709554 -14.628477 -.0006889361
    5418 1988 1 .010878066 .01212345 1.318797e-06
    6138 1988 1 .0040314705 27.215406 .0010971811
    6555 1988 1 .00775756 11.361523 .0008813769
    5717 1988 1 .018076962 -16.627876 -.003005815
    5496 1988 1 .03864232 -6.418726 -.002480345
    7254 1988 1 .003252011 484.86795 .01576796
    7145 1988 1 .07200812 -3.9270766 -.002827814
    7294 1988 1 .003709455 -40.03103 -.001484933
    6462 1988 1 .018823624 -1.3978765 -.00026313102
    5870 1988 1 .008651262 -13.30874 -.001151374
    6340 1988 1 .008757503 4.581522 .0004012269
    7923 1988 1 .0027628676 -59.12244 -.001633475
    7154 1988 1 .001613059 -40.30289 -.0006501094
    6665 1988 1 .009262182 -24.833794 -.0023001512
    5974 1988 1 .09308114 .786275 .0007318737
    6946 1988 1 .032222416 47.52064 .015312297
    5604 1988 1 .0037643795 -3.112319 -.0001171595
    8504 1988 1 .004078392 15.433672 .0006294457
    6836 1988 1 .0020328404 45.48768 .000924692
    7217 1988 1 .013693974 32.054104 .004389481
    6607 1988 1 .002903632 20.31768 .0005899506
    6495 1988 1 .003260328 8.757681 .00028552912
    6958 1988 1 .013698054 18.946796 .0025953425
    5523 1988 1 .04979282 3.9112735 .0019475333
    7184 1988 1 .003675088 65.49897 .002407145
    5446 1988 1 .0123105 -19.09788 -.002351044
    6859 1988 1 .003496818 -35.66232 -.0012470464
    5397 1988 1 .0020494745 -46.04244 -.0009436281
    5382 1988 1 .0031159546 45.20768 .001408651
    5781 1988 1 .0020171476 -68.512436 -.001381997
    7149 1988 1 .013541284 -3.033204 -.0004107348
    6056 1988 1 .002672791 -43.60244 -.001165402
    5655 1988 1 .05581209 -18.313065 -.010220904
    5945 1988 2 .00463354 -1.204877 -.00005582845
    6923 1988 2 .04139749 14.199373 .005878184
    7144 1988 2 .0020478633 -57.57103 -.001178976
    6309 1988 2 .0012699616 2.237681 .00002841769
    7311 1988 2 .022528274 33.696278 .00759119
    7204 1988 2 .0028297885 -48.55125 -.0013738978
    5491 1988 2 .05930467 -13.633725 -.008085435
    5824 1988 2 .002104283 -44.38244 -.0009339322
    6362 1988 2 .0011264324 -8.682319 -.00009780045
    6944 1988 2 .04139796 -7.973727 -.00330096
    3869 1988 2 .0022640927 174.80896 .003957837
    6647 1988 2 .03457022 46.43628 .016053123
    6817 1988 2 .009060114 66.086205 .005987485
    6921 1988 2 .02863818 70.34693 .02014608
    5417 1988 2 .016566856 -14.123064 -.002339748
    8473 1988 2 .00104213 -18.272894 -.0001904273
    5412 1988 2 .004920411 -5.548478 -.0002730079
    7151 1988 2 .0041635614 22.27852 .00092758
    7386 1988 2 .002524859 40.87705 .0010320878
    7192 1988 2 .004963919 26.25626 .0013033395
    7405 1988 2 .007562788 -15.563204 -.001177012
    5402 1988 2 .004635505 10.291522 .000477064
    7328 1988 2 .00989378 53.80212 .005323063
    6165 1988 2 .015527252 -31.34708 -.00486734
    7734 1988 2 .002977996 10.388747 .00030937645
    7243 1988 2 .0037797566 28.486946 .0010767372
    5851 1988 2 .00394911 -25.584877 -.0010103749
    8441 1988 2 .0039315196 3.245123 .00012758265
    6970 1988 2 .017720142 -30.607077 -.005423618
    7402 1988 2 .0024529074 -49.38103 -.001211271
    5719 1988 2 .011361913 -31.06619 -.0035297135
    5617 1988 2 .00308466 -37.54874 -.0011582511
    7478 1988 2 .0035551065 -20.288477 -.000721277
    7729 1988 2 .0033146436 -12.550977 -.0004160202
    7413 1988 2 .002824081 -13.994253 -.000395209
    6188 1988 2 .001548599 -11.94232 -.00018493863
    5510 1988 2 .02763647 32.986275 .009116242
    7349 1988 2 .0021389024 5.027107 .00010752492
    6444 1988 2 .001595943 -17.962318 -.00028666836
    8098 1988 2 .010091296 -46.3632 -.004678648
    5858 1988 2 .00995357 -25.07619 -.002495976
    6387 1988 2 .0017723136 -11.55232 -.00020474332
    6047 1988 2 .011706795 -11.537877 -.0013507155
    7228 1988 2 .0036947995 -32.694252 -.001207987
    7444 1988 2 .004679574 -40.86488 -.0019123022
    6818 1988 2 .028311545 -12.187077 -.00345035
    6805 1988 2 .006330253 44.80099 .002836016
    5707 1988 2 .25637916 -20.983725 -.0537979
    7190 1988 2 .003115911 -16.884253 -.0005260983
    5791 1988 2 .015835643 -57.34708 -.009081278
    5845 1988 2 .0030567776 -51.24488 -.001566442
    6648 1988 2 .008569831 -34.613205 -.002966293
    6197 1988 2 .024474245 -26.30873 -.006438862
    8041 1988 2 .005248919 99.51575 .0052235
    7363 1988 2 .002289636 -33.84289 -.000774879
    5442 1988 2 .01524141 -47.93306 -.007305675
    6124 1988 2 .001596411 -24.57232 -.0003922752
    6930 1988 2 .03641654 52.37858 .019074466
    5482 1988 2 .033051092 -11.578727 -.003826896
    8482 1988 2 .010423547 10.012124 .0010436184
    5432 1988 2 .0018044064 -68.802895 -.001241484
    7164 1988 2 .0009581085 -65.68103 -.0006292955
    5495 1988 2 .004479999 -33.118477 -.0014837076
    6919 1988 2 .01121801 5.850806 .000656344
    6651 1988 2 .0021987841 48.70921 .0010710104
    5995 1988 2 .003910561 -12.33874 -.00048251395
    6971 1988 2 .001034832 -25.23244 -.00026111337
    6205 1988 2 .0029855745 -24.16848 -.000721568
    5461 1988 2 .00498731 -10.508478 -.00052409037
    1571 1988 2 .00548985 -43.0032 -.002360811
    8454 1988 2 .00383496 8.991261 .0003448113
    7312 1988 2 .004747315 -10.678477 -.000506941
    5399 1988 2 .02433521 65.471275 .015932571
    6826 1988 2 .00601999 -31.88619 -.0019195458
    7416 1988 2 .002490614 134.89755 .003359778
    5613 1988 2 .0021592996 2.457681 .00005306869
    6789 1988 2 .001412181 180.52898 .002549396
    6012 1988 2 .006848043 -13.387877 -.0009168075
    6913 1988 3 .04084988 31.08292 .012697336
    6793 1988 3 .0042613777 54.11652 .0023061095
    5769 1988 3 .0044555734 -26.13619 -.0011645172
    8524 1988 3 .0017429963 -10.454877 -.0001822281
    6201 1988 3 .05990786 -2.725325 -.0016326838
    8097 1988 3 .004850253 -25.023205 -.001213689
    5485 1988 3 .0787017 -29.518726 -.02323174
    7202 1988 3 .003989745 -36.293793 -.0014480298
    6800 1988 3 .0079699615 17.086206 .001361764
    5756 1988 3 .00467556 -24.70619 -.0011551529
    6949 1988 3 .008540733 9.826796 .0008392804
    6035 1988 3 .023817774 -26.364063 -.006279333
    7427 1988 3 .0014571343 -30.97289 -.0004513166
    7628 1988 3 .0019216284 129.47617 .002488051
    7166 1988 3 .0007566451 2.0971072 .00001586766
    7730 1988 3 .001180102 9.018971 .00010643308
    6017 1988 3 .06806776 2.056275 .0013996603
    5827 1988 3 .0040634973 -1.8178765 -.00007386936
    7428 1988 3 .0021379942 -68.524254 -.0014650446
    6939 1988 3 .00689385 -.673204 -.00004640967
    6979 1988 3 .034165345 -28.513723 -.009741812
    5440 1988 3 .008331418 -17.436193 -.001452682
    5629 1988 3 .007418692 -11.377876 -.0008440896
    5690 1988 3 .0088299615 .6321235 .00005581626
    7327 1988 3 .0013162995 9.077107 .00011948192
    7643 1988 3 .02775778 -4.334364 -.001203123
    5859 1988 3 .0011151162 -34.95232 -.000389759
    8028 1988 3 .00950104 9.851274 .0009359733
    7234 1988 3 .006829689 148.7038 .010156007
    5839 1988 3 .07762425 -16.843725 -.013074816
    6655 1988 3 .018472217 12.077623 .0022310049
    6934 1988 3 .00785568 10.247707 .000805027
    6894 1988 3 .016273174 10.152174 .001652081
    5549 1988 3 .0021736952 6.731261 .0001463171
    7261 1988 3 .010401885 35.372925 .003679451
    7140 1988 3 .008885165 8.083205 .0007182062
    8141 1988 3 .003636674 11.791522 .0004288192
    5614 1988 3 .005748686 -45.30379 -.002604373
    7293 1988 3 .0018526403 45.44512 .0008419346
    7201 1988 3 .01150976 -25.298077 -.002911748
    5721 1988 3 .009840135 -16.103064 -.001584563
    5525 1988 3 .01986303 -6.538726 -.001298789
    7393 1988 3 .06301429 48.50827 .030567145
    6210 1988 3 .03263719 4.267936 .0013929345
    7426 1988 3 .00049524015 -27.93103 -.00013832567
    7373 1988 3 .008607878 33.675205 .002898721
    7783 1988 3 .003173958 7.685747 .0002439424
    7387 1988 3 .0029896726 44.89575 .001342236
    5463 1988 3 .005716034 -19.73619 -.0011281276
    5492 1988 3 .002470293 -29.96874 -.0007403156
    7160 1988 3 .0006015808 -9.761028 -.00005872048
    6943 1988 3 .0037111884 -9.274253 -.000344185
    5826 1988 3 .011805595 -55.00306 -.006493439
    7300 1988 3 .0010871016 -55.03102 -.0005982432
    5855 1988 3 .017826866 -18.453724 -.003289721
    5380 1988 3 .01225065 -12.247077 -.0015003466
    6334 1988 3 .0014612634 7.787681 .00011379852
    6051 1988 3 .002620656 -12.678477 -.0003322593
    6796 1988 3 .003035093 19.335123 .000586839
    5770 1988 3 .006713375 -5.326192 -.0003575673
    6642 1988 3 .0609761 -.5287265 -.0003223968
    6801 1988 3 .004390524 -25.653795 -.0011263359
    5438 1988 3 .01051369 34.106937 .0035858974
    7170 1988 3 .00054701295 -51.56103 -.0002820455
    6156 1988 3 .05557616 -12.989727 -.007219191
    6317 1988 3 .005031617 11.932123 .0006003787
    6942 1988 3 .0015643643 -1.0210284 -.000015972604
    7671 1988 3 .003283729 -50.82487 -.0016689514
    5378 1988 3 .005568911 4.0938077 .0002279805
    5853 1988 3 .0021910374 -11.92874 -.00026136314
    5741 1988 3 .0015700816 -40.49244 -.0006357644
    5554 1988 3 .004331509 -13.497877 -.0005846618
    7171 1988 3 .006491927 -32.823204 -.0021308586
    5610 1988 3 .008699799 -13.027877 -.0011333991
    5416 1988 3 .01258314 -35.613064 -.0044812416
    5720 1988 3 .0012657337 -10.532442 -.00013331267
    8397 1988 3 .005552394 1.3897058 .00007716195
    5624 1988 4 .05806098 -19.793724 -.01149243
    3671 1988 4 .00607062 29.252125 .0017757853
    8402 1988 4 .00122507 -4.913442 -.00006019309
    7362 1988 4 .005687082 10.156796 .00057762535
    7756 1988 4 .0012734267 37.337105 .0004754607
    5708 1988 4 .013533988 -23.97708 -.003245055
    5883 1988 4 .005295252 -50.66379 -.0026827755
    7554 1988 4 .005735876 52.59091 .003016549
    8444 1988 4 .0030944906 4.485123 .00013879171
    7642 1988 4 .004470479 18.65236 .0008338499
    7147 1988 4 .0007827005 -5.032893 -.00003939248
    7289 1988 4 .011478996 29.783806 .003418882
    7251 1988 4 .002458345 68.115746 .00167452
    5654 1988 4 .003510936 -30.404877 -.0010674957
    7457 1988 4 .0019048592 54.96897 .0010470815
    6968 1988 4 .011513387 -36.653202 -.004220025
    8363 1988 4 .004779474 22.485746 .0010747005
    6037 1988 4 .015742868 28.75292 .0045265346
    6558 1988 4 .0015354616 -46.53232 -.0007144859
    6918 1988 4 .03322527 19.520636 .006485784
    7484 1988 4 .0014729643 -16.942442 -.00024955612
    5632 1988 4 .012606042 -8.817077 -.0011114845
    7142 1988 4 .0021627042 18.535107 .0004008595
    5778 1988 4 .0014651957 -22.92244 -.0003358586
    5483 1988 4 .021556865 -24.233727 -.005224032
    6000 1988 4 .0014881522 -17.212318 -.00025614552
    5885 1988 4 .016856385 -4.5930634 -.0007742245
    4063 1988 4 .0015768355 -22.65103 -.00035716945
    7650 1988 4 .004959285 81.96282 .0040647704
    5400 1988 4 .005623101 3.056206 .00017185355
    7162 1988 4 .0018952576 -6.292893 -.00011926654
    6950 1988 4 .018039556 14.067924 .002537791
    7258 1988 4 .003267144 5.416422 .0001769623
    6908 1988 4 .0034998504 2.175123 .00007612605
    7146 1988 4 .011566631 -18.945793 -.0021913901
    6786 1988 4 .002818141 -8.465753 -.0002385768
    6962 1988 4 .00225357 66.50897 .0014988262
    7477 1988 4 .008347234 22.487606 .001877093
    6644 1988 4 .005800119 35.773808 .0020749234
    5500 1988 4 .003786413 -20.97848 -.0007943318
    5738 1988 4 .009033046 -30.967876 -.0027973424
    6822 1988 4 .0043263687 -24.774254 -.0010718255
    6183 1988 4 .0925658 -6.754726 -.006252565
    7893 1988 4 .001762058 -11.462893 -.0002019828
    7745 1988 4 .0018903696 48.33897 .0009137852
    7397 1988 4 .015248388 -48.51708 -.007398072
    6640 1988 4 .004762803 99.62362 .004744877
    7137 1988 4 .009451935 11.291206 .0010672375
    5474 1988 4 .014693768 -32.637077 -.004795616
    8525 1988 4 .0005888366 -40.02603 -.0002356879
    5684 1988 4 .0021408827 -13.76232 -.0002946351
    7377 1988 4 .0032557966 -27.53425 -.0008964593
    6814 1988 4 .05468481 86.95967 .04755374
    5799 1988 4 .064684995 -35.643723 -.02305614
    7181 1988 4 .001225768 -4.4424415 -.00005445403
    7767 1988 4 .00953512 -35.522305 -.003387094
    7390 1988 4 .005521063 -3.578204 -.0001975549
    7431 1988 4 .001687777 -48.02103 -.0008104878
    5546 1988 4 .0021170534 56.63768 .00119905
    5384 1988 4 .00238869 -23.52488 -.0005619363
    5642 1988 4 .02166475 -31.653065 -.006857558
    7163 1988 4 .0025746105 -7.884253 -.0002029888
    6872 1988 4 .008933888 5.572124 .0004978073
    6175 1988 4 .01595096 -19.103064 -.003047122
    5448 1988 4 .006448223 -11.646193 -.0007509724
    7690 1988 4 .002955181 -42.90525 -.0012679278
    6659 1988 4 .027012637 46.80002 .01264192
    6906 1988 4 .006796322 81.7568 .005556455
    6036 1988 4 .12919612 26.363274 .03406033
    6662 1988 4 .05029769 21.634336 .010881572
    6798 1988 4 .05231786 -19.916727 -.010420005
    7352 1988 4 .0017966236 .8171072 .00001468034
    5771 1988 4 .003273778 -22.57874 -.0007391777
    7099 1988 4 .008245458 -41.44788 -.0034175673
    6229 1988 4 .0027012636 13.57126 .00036659554
    7237 1988 4 .007436484 11.206796 .0008333916
    5698 1988 4 .0045691133 -10.80874 -.00049386354
    6844 1988 4 .02384273 -31.42873 -.007493467
    7169 1988 5 .008083384 14.363205 .0011610329
    8531 1988 5 .0010763407 -61.34103 -.0006602384
    7333 1988 5 .005559074 69.531265 .003865294
    6657 1988 5 .015709555 -44.55708 -.006999718
    8432 1988 5 .0019648154 -37.05244 -.000728012
    6952 1988 5 .00607239 -5.656894 -.0003435086
    5676 1988 5 .027412385 -1.4330636 -.0003928369
    4891 1988 5 .01502965 -27.338726 -.0041089146
    5457 1988 5 .016678939 -15.853064 -.002644123
    5627 1988 5 .0045171767 -12.668477 -.0005722575
    5414 1988 5 .019864453 -29.54306 -.005868568
    5489 1988 5 .08767887 -12.523726 -.01098066
    5652 1988 5 .00818786 9.773808 .0008002657
    8516 1988 5 .0036292744 2.645123 .00009599878
    7419 1988 5 .005822697 33.356796 .001942265
    6458 1988 5 .0012275684 -20.79232 -.00025523992
    7297 1988 5 .01499826 54.15762 .0081227
    7183 1988 5 .002504942 49.89811 .0012499185
    5543 1988 5 .002851382 23.08152 .0006581423
    5394 1988 5 .003251825 -38.60488 -.001255363
    6039 1988 5 .0265595 30.192924 .00801909
    7205 1988 5 .006508993 -38.00619 -.0024738205
    7213 1988 5 .0042424863 39.22912 .00166429
    7105 1988 5 .0013341433 -58.99244 -.0007870437
    8154 1988 5 .012183897 21.376205 .002604455
    5646 1988 5 .020772774 -29.163063 -.006057977
    7274 1988 5 .0020792142 -1.5557928 -.000032348264
    5739 1988 5 .007919085 -19.38619 -.001535209
    5479 1988 5 .005437042 -23.05874 -.0012537134
    6652 1988 5 .022722894 -11.581077 -.002631556
    6296 1988 5 .04706541 10.221273 .004810684
    8343 1988 5 .003952148 -5.21874 -.0002062523
    7392 1988 5 .007166286 50.9468 .003650993
    5542 1988 5 .000838956 -32.272892 -.00027075538
    5631 1988 5 .034742303 -34.213726 -.011886636
    5638 1988 5 .010893262 -17.857876 -.0019453053
    7006 1988 5 .00293544 -7.064253 -.0002073669
    6489 1988 5 .005363766 -43.85488 -.002352273
    6959 1988 5 .008517126 12.956797 .0011035466
    5800 1988 5 .00273269 -36.61874 -.0010006765
    8177 1988 5 .004422528 -60.13425 -.0026594545
    5959 1988 5 .06709139 -6.583725 -.0044171126
    5658 1988 5 .004046701 -53.54874 -.0021669574
    5758 1988 5 .01260056 -60.70619 -.00764932
    5498 1988 5 .019687654 -33.863728 -.006666973
    5780 1988 5 .0025808895 2.2412605 .00005784446
    7136 1988 5 .0021366521 19.97711 .0004268413
    7936 1988 5 .017677996 -28.888725 -.005106948
    7167 1988 5 .011817516 35.426796 .0041865674
    7161 1988 5 .006111222 -4.203204 -.00025686712
    7044 1988 5 .0012725074 -2.482319 -.000031587693
    7070 1988 5 .0041681603 3.071522 .00012802597
    8469 1988 5 .0009190065 -33.05103 -.0003037411
    6220 1988 5 .003648357 -21.878477 -.000798205
    6895 1988 5 .01134599 20.411106 .0023158423
    7165 1988 5 .0009305514 -47.31603 -.0004403
    7238 1988 5 .006276189 -50.9338 -.003196701
    7888 1988 5 .002253436 -4.7310286 -.0001066107
    5649 1988 5 .06367889 -22.983725 -.014635782
    5616 1988 5 .01350955 10.573808 .0014284737
    6176 1988 5 .04494316 23.071924 .010369252
    6815 1988 5 .0026754425 11.98006 .0003205196
    5383 1988 5 .05657749 4.3412733 .002456183
    6206 1988 5 .007973183 -8.053204 -.0006420967
    5518 1988 5 .0016337364 -41.03232 -.00067036
    5626 1988 5 .02612137 -42.73373 -.011162634
    6092 1988 5 .002454278 -20.61244 -.0005058866
    5748 1988 5 .017545564 34.69292 .006087069
    5944 1988 5 .012790716 2.6538076 .000339441
    7266 1988 5 .013038692 14.093807 .001837648
    5405 1988 5 .002873613 67.12152 .0019288127
    7277 1988 5 .0226874 131.61694 .029860463
    7672 1988 5 .0014592282 22.51768 .0003285844
    7227 1988 5 .005988808 -20.276304 -.001214309
    8509 1988 5 .003483581 137.14513 .004777561
    6674 1988 5 .02666846 -25.893724 -.006905457
    6810 1988 5 .008821299 33.444523 .0029502416
    7169 1989 1 .026088715 44.665 .011652525
    6304 1989 1 .00771959 -9.9 -.0007642394
    6000 1989 1 .0017870337 -8.860001 -.0001583312
    5461 1989 1 .009031327 -27.83375 -.002513757
    7458 1989 1 .0038669384 20.1116 .0007777033
    6816 1989 1 .010155418 -24.95973 -.002534765
    7181 1989 1 .0023925565 -17.099154 -.0004091069
    5652 1989 1 .01419654 -14.320545 -.002033022
    6946 1989 1 .03730627 .9969214 .0003719142
    7756 1989 1 .0039347988 48.33084 .0019017216
    7650 1989 1 .011827474 -25.427935 -.003007482
    8484 1989 1 .0040036207 -8.10708 -.00032457674
    6821 1989 1 .0014844098 50.75104 .0007533535
    7628 1989 1 .00632502 -18.197924 -.0011510223
    5940 1989 1 .004935669 -26.048 -.0012856432
    6607 1989 1 .0027870804 -7.667996 -.0002137132
    5448 1989 1 .008897667 -18.288336 -.001627235
    7683 1989 1 .003135448 -.55575687 -.00001742547
    5756 1989 1 .012118147 15.621665 .0018930563
    7164 1989 1 .002370715 47.18672 .0011186627
    5738 1989 1 .0097543 -46.02949 -.0044898544
    7433 1989 1 .007230282 1.5829195 .00011444953
    8398 1989 1 .00128234 -13.59328 -.00017431207
    6948 1989 1 .04039405 -57.38797 -.023181325
    7426 1989 1 .0020418533 44.05125 .0008994618
    7496 1989 1 .011042684 42.57 .004700871
    6197 1989 1 .03762538 -5.613753 -.0021121958
    7363 1989 1 .007087555 67.88555 .004811426
    6138 1989 1 .0037527846 -21.775354 -.0008171821
    6836 1989 1 .0025242935 11.338243 .00028621053
    6796 1989 1 .011673208 19.600466 .0022880032
    7312 1989 1 .011361793 5.616252 .0006381069
    8482 1989 1 .017583923 -33.360004 -.005865998
    7672 1989 1 .004710796 -18.657925 -.0008789368
    5501 1989 1 .02730045 -16.98617 -.0046373
    7757 1989 1 .00996049 -62.48813 -.006224125
    7149 1989 1 .01364363 -16.285837 -.0022219792
    5475 1989 1 .006492198 18.660002 .0012114443
    6188 1989 1 .002455884 14.088 .00034598485
    5974 1989 1 .12648721 2.762488 .003494194
    6944 1989 1 .06907121 -9.85567 -.00680743
    7085 1989 1 .003987686 -13.26534 -.00052898005
    5720 1989 1 .002545036 -5.028398 -.00012797453
    7217 1989 1 .015618722 -12.150582 -.0018977656
    7254 1989 1 .005691749 62.25142 .003543194
    8531 1989 1 .001857092 1.3467197 .000025009826
    6640 1989 1 .008214256 -27.410284 -.0022515508
    5862 1989 1 .002922389 -21.86833 -.0006390777
    7416 1989 1 .004921658 .3537169 .000017408738
    6872 1989 1 .019402415 6.389994 .001239813
    8514 1989 1 .01400079 34.512966 .004832088
    7006 1989 1 .0039931806 -46.7801 -.001868014
    7144 1989 1 .005290769 -.3370806 -.000017834156
    7209 1989 1 .0085446285 4.3580055 .0003723754
    7745 1989 1 .005944782 48.72698 .002896713
    7031 1989 1 .0013105005 -61.32054 -.000803606
    5486 1989 1 .01510867 12.340512 .0018644874
    8194 1989 1 .002485006 32.297443 .0008025934
    6826 1989 1 .013000468 -12.513748 -.0016268458
    5423 1989 1 .005128261 -23.965 -.0012289877
    5920 1989 1 .005405746 8.400096 .0004540879
    6383 1989 1 .003368426 7.151668 .00024089865
    1571 1989 1 .008939565 -50.5573 -.0045196027
    7767 1989 1 .015624766 -41.4489 -.006476294
    5778 1989 1 .002501765 -1.1020019 -.000027569495
    6286 1989 1 .002905767 -38.00328 -.0011042869
    5848 1989 1 .0043545985 -17.061995 -.0007429814
    7190 1989 1 .008908107 16.349094 .001456395
    5949 1989 1 .006943043 -34.996284 -.002429807
    7386 1989 1 .006954857 46.54272 .003236979
    5432 1989 1 .0026918836 17.859463 .000480756
    5546 1989 1 .0038483934 -18.571756 -.0007147143
    5894 1989 1 .0014853714 -22.564 -.0003351592
    6926 1989 1 .005381981 -27.289904 -.0014687375
    4063 1989 1 .003162235 2.6484454 .00008375008
    7154 1989 1 .0014550128 2.8294635 .00004116906
    7293 1989 1 .007206242 28.92644 .0020845092
    6651 1989 1 .004246764 -19.09472 -.0008109077
    3706 1989 1 .003678743 -24.972 -.0009186557
    7377 1989 1 .005867993 27.22292 .001597439
    7690 1989 1 .0040071923 -47.93108 -.0019206906
    5412 1989 1 .005992175 -26.92 -.0016130934
    5709 1989 1 .010813965 38.9516 .0042122123
    7643 1989 1 .09222806 5.089854 .004694274
    3671 1989 1 .012384918 -22.748404 -.002817371
    7206 1989 1 .031833626 28.65433 .009121712
    7390 1989 2 .005273794 -12.060838 -.0006360637
    7264 1989 2 .005712387 -25.24261 -.0014419556
    6205 1989 2 .0021875934 -12.025 -.00026305811
    5855 1989 2 .02129368 -33.009 -.00702883
    7352 1989 2 .0023920285 7.119897 .00017030997
    7431 1989 2 .0015024922 -13.252995 -.0001991252
    6934 1989 2 .012313752 -15.43812 -.0019010116
    7044 1989 2 .0006745656 -12.6 -.00008499526
    7251 1989 2 .003100922 -30.682505 -.0009514406
    7163 1989 2 .00337834 10.3735 .000350452
    7328 1989 2 .007641471 -16.498404 -.0012607208
    8524 1989 2 .002493548 11.125556 .00027742112
    7642 1989 2 .004656721 7.383255 .0003438176
    7671 1989 2 .00651066 .7762522 .00005053914
    5405 1989 2 .0034687656 22.992077 .0007975412
    6317 1989 2 .008145512 18.259995 .00148737
    5870 1989 2 .004111515 3.3480055 .00013765374
    5649 1989 2 .06085714 -1.4989974 -.000912247
    8363 1989 2 .007868862 52.01782 .00409321
    7213 1989 2 .002673004 -46.74128 -.0012493965
    6950 1989 2 .02087567 -2.994668 -.000625157
    8041 1989 2 .00554842 -27.315035 -.001515553
    7151 1989 2 .0045993677 -22.624403 -.0010405795
    8473 1989 2 .0018168894 52.158 .0009476531
    5484 1989 2 .002844367 .1649995 4.693192e-06
    5944 1989 2 .009971262 4.3994555 .00043868125
    end



    Last edited by Jesse Tielens; 11 Aug 2018, 14:22.

  • #2
    Without having delved too deeply into it, I think the main problem is that you have used the -semean- statistic in your -tabstat- command. -semean- calculates the standard error of the mean, which is not the standard deviation. To get the standard deviation, use -sd- in your -statistics()- option, not -semean-.

    Also, it may not be necessary to dance around the weighting by explicitly calculating wAR and descriptive statistics from there. The -tabstat- command accepts -aweights-, which may give you what you are looking for. If not, look, instead at using -summarize-, which accepts -iweights-. One of these is likely to be what you want, with less work on your part to get it.

    Comment

    Working...
    X