Sampling distribution of the correlation between 2 variables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | *(Q) I would like to resample a bivariate population 1000 times, and for each resample I would calculate the correlation between two variables. I could then plot the sampling distribution. * (A) Posted to SPSSX_L list on 2001/11/16 by Jelani Mandara. DEFINE !sdist (samples=!TOKENS(1) /size=!TOKENS(1) /mean=!TOKENS(1) /sd=!TOKENS(1)). INPUT PROGRAM. LOOP id = 1 TO !samples* !size. END CASE. END LOOP. END FILE. END INPUT PROGRAM. RANK VARIABLES = id /NTILES(!size) /PRINT = NO /TIES = MEAN . SORT CASES BY nid . SPLIT FILE LAYERED BY nid . COMPUTE X = RV.NORMAL(!mean,!sd) . COMPUTE Y = RV.NORMAL(!mean,!sd) . DESCRIPTIVES VARIABLES=x y /SAVE /STATISTICS=MEAN. COMPUTE ZxZy = zx * zy . SPLIT FILE OFF. AGGREGATE /OUTFILE='C:\\samplingdistribution.SAV' /BREAK=nid /zxzy = SUM(zxzy) /N_BREAK=N. GET FILE='C:\\samplingdistribution.SAV'. COMPUTE corr = zxzy / n_break . FREQUENCIES VARIABLES=corr /FORMAT=NOTABLE /STATISTICS=STDDEV VARIANCE MINIMUM MAXIMUM SEMEAN MEAN MEDIAN /HISTOGRAM NORMAL /ORDER ANALYSIS . !ENDDEFINE. !sdist samples=100 size=100 mean =100 sd =15. |
Related pages
...