Hello,

I have a set of variables in which combined produces a prior belief distribution over possible outcomes. See below for a snippet:

Code:
input str24 id float(p_score_0 p_score_1 p_score_2 p_score_3 p_score_4 p_score_5 p_score_6 p_score_7 p_score_8 p_score_9 p_score_10 p_score_11 p_score_12 p_score_13 p_score_14 p_score_15 p_score_16 p_score_17 p_score_18 p_score_19 p_score_20)
"5f3ecc42701f7b169ba22ff9"   0   0   0   0   0   0   0   0 .01 .02 .06 .11 .14 .19  .2 .18 .08 .01   0   0   0
"57bdb5eb467f26000125db79" .01 .02 .02 .02 .03 .04 .04 .06 .08  .1  .1  .1  .1 .08 .06 .04 .03 .02 .02 .02 .01
"5d2a068fd7d4940019e63136"   0   0   0   0   0   0   0  .4  .3   0  .3   0   0   0   0   0   0   0   0   0   0
"5acba4a15cd10500016280ca"   0   0   0   0   0   0   0   0   0   0   0   0   0   0 .14 .33 .23 .22 .06 .02   0
"5ff76d52a4cb3f434e49eabe"   0   0   0   0   0   0   0   0  .1  .5  .1  .1 .07 .08 .05   0   0   0   0   0   0
"5cb5464a6f451e00012da7cf"   0   0   0   0   0   0   0   0   0 .06  .5 .25 .13 .06   0   0   0   0   0   0   0
"5c1a9424a329230001ecaabd"   0   0   0   0   0   0   0   0   0   0   0   0 .02 .03 .05 .05  .1 .15  .4 .15 .05
"5e7e89cc4fd114104a39fb88"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 .15  .8 .05   0   0   0
"6057b1a36c955bab2ad1d5df"   0   0   0   0   0   0   0   0   0   0   0   0   0 .05 .75  .1  .1   0   0   0   0
"56fdff4ee0f9ff000f19c466"   0   0   0   0   0   0   0  .1  .1  .1  .5  .1  .1   0   0   0   0   0   0   0   0
"5fde840829db956469ee680f"   0   0   0   0   0   0   0   0   0   0 .05 .06 .08  .3 .25  .2 .04 .02   0   0   0
"59aee2c57f6c84000151bd9b"   0   0   0   0   0   0   0   0   0   0   0   0   0 .05 .05 .05 .75 .05 .05   0   0
"5eaf02446c144d5e3a4d4562"   0   0   0   0   0   0   0   0   0   0 .05 .15  .6  .1  .1   0   0   0   0   0   0
"60159647df028869091a0d3d"  .6  .1 .06 .03 .01  .2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
"5f4ff67ab2c26c14b484ab03"   0   0   0   0   0   0   0   0   0   0  .1  .1  .5  .1  .1  .1   0   0   0   0   0
"5e5c03ab6a255b3ece760715"   0   0   0   0   0   0   0   0   0   0   0   0  .1  .2  .6  .1   0   0   0   0   0
"5c6d8aa9701e050001338a3e"   0   0   0   0 .02 .02 .04 .05 .12 .15  .3  .2  .1   0   0   0   0   0   0   0   0
"5e8f53644b34ff22d9b3a1c5"   0   0   0   0   0   0   0   0   0   0   0  .2  .2 .05 .05  .5   0   0   0   0   0
"5c2fd11610677f0001dd7efc"   0   0   0   0   0   0   0   0   0 .01 .02 .02 .85 .02 .02 .02 .02 .02   0   0   0
"5ec712b9f6899e15e2ebdc6d"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 .03 .85  .1 .02
The values of each variable represents the probability they think that variable's outcome will occur where the outcome is the numerical value prescribed at the end of the variable names. I am wanting to produce the first four moments of each individuals prior distribution.

I was able to hard code and produce each of the moments, but it was extremely tedious. Is there a more elegant solution using loops? Right now the data is wide format, I guess it could help by reshaping it long and make the j correspond to the outcome value? Still am lost on the most effective way to then compute the moments.

Any help would be greatly appreciated.

Nicholas