Semipartial Correlation UDF

  • I need help in modifying the appended Partial Correlation UDF to Semipartial Correlation UDF.


    A note on Semipartial Correlation (and Partial) can be found at http://www.listendata.com/2017/03/pa...rrelation.html


    The Partial Correlation UDF is:



    Further to add an example, if the correlation matrix for three variables is:


    [TABLE="class: cms_table, width: 270"]

    [tr]


    [TD="align: right"]1.000000
    [/TD]
    [TD="align: right"]0.920000
    [/TD]
    [TD="align: right"]0.870000
    [/TD]

    [/tr]


    [tr]


    [TD="align: right"]0.920000
    [/TD]
    [TD="align: right"]1.000000
    [/TD]
    [TD="align: right"]0.810000
    [/TD]

    [/tr]


    [tr]


    [TD="align: right"]0.870000
    [/TD]
    [TD="align: right"]0.810000
    [/TD]
    [TD="align: right"]1.000000
    [/TD]

    [/tr]


    [/TABLE]



    ... the array function pCorrel() gives the following output.


    [TABLE="class: cms_table, width: 225"]

    [tr]


    [TD="align: right"]-1.00000
    [/TD]
    [TD="align: right"]0.744621
    [/TD]
    [TD="align: right"]0.543004
    [/TD]

    [/tr]


    [tr]


    [TD="align: right"]0.744621
    [/TD]
    [TD="align: right"]-1.00000
    [/TD]
    [TD="align: right"]0.049680
    [/TD]

    [/tr]


    [tr]


    [TD="align: right"]0.543004
    [/TD]
    [TD="align: right"]0.049680
    [/TD]
    [TD="align: right"]-1.00000
    [/TD]

    [/tr]


    [/TABLE]



    .. Now, instead of Partial, I am looking for Semipartial UDF.