corrpdf

corrpdf computes correlation coefficient probability density function

Syntax

Description

example

y =corrpdf(r, rho, n) An example where x, rho and n are all scalars.

Examples

expand all

  • An example where x, rho and n are all scalars.
  • Find f(r=x|rho=0.1|n=12)

    x=0;
    rho=0.1;
    n=12;
    xs=num2str(x);
    rhos=num2str(rho);
    ns=num2str(n);
    dens=corrpdf(x,rho,n);
    disp(['f(r=' xs '|rho=' rhos, ', n=' ns ')'])
    disp(dens);

    Related Examples

    expand all

  • An example where x is not scalar.
  • x=-1:0.01:1;
    rho=0.8;
    n=12;
    rhos=num2str(rho);
    ns=num2str(n);
    dens=corrpdf(x,rho,n);
    % disp(['f(r=x|rho=' rhos, ', n=' ns ')'])
    plot(x,dens)
    xlabel("x")
    ylabel(['f(r=x|rho=' rhos, ', n=' ns ')'])

  • Show density of r given different values for rho.
  • x=-1:0.01:1;
    rho=[0:0.2:0.8 0.9]';
    n=12;
    rhos=num2str(rho);
    ns=num2str(n);
    close all
    for i=1:length(rho)
    nexttile
    dens=corrpdf(x,rho(i),n);
    plot(x,dens)
    title(['f(r|n=' ns ', rho=' rhos(i,:) ')'])
    xlabel("r")
    end
    sgtitle('Density of the correlation coefficient for different values of rho')
    Click here for the graphical output of this example (link to Ro.S.A. website)

  • An example where rho is not scalar.
  • x=0.3;
    rho=(0:0.1:0.8)';
    n=12;
    xs=string(x);
    rhos=string(rho);
    ns=string(n);
    Dens=corrpdf(x,rho,n);
    nameRows="f(r="+xs+"|rho="+ rhos+ ", n="+ ns+ ")=";
    nameRowsT=array2table(Dens,"RowNames",nameRows);
    disp(nameRowsT)
                                     Dens  
                                   ________
    
        f(r=0.3|rho=0, n=12)=       0.84417
        f(r=0.3|rho=0.1, n=12)=      1.1002
        f(r=0.3|rho=0.2, n=12)=      1.2924
        f(r=0.3|rho=0.3, n=12)=      1.3543
        f(r=0.3|rho=0.4, n=12)=      1.2404
        f(r=0.3|rho=0.5, n=12)=     0.95764
        f(r=0.3|rho=0.6, n=12)=     0.58395
        f(r=0.3|rho=0.7, n=12)=     0.24783
        f(r=0.3|rho=0.8, n=12)=    0.054814
    
    

  • An example where n is not scalar.
  • x=0.3;
    rho=0';
    n=(5:5:50)';
    xs=string(x);
    rhos=string(rho);
    ns=string(n);
    Dens=corrpdf(x,rho,n);
    nameRows="f(r="+xs+"|rho="+ rhos+ ", n="+ ns+ ")=";
    nameRowsT=array2table(Dens,"RowNames",nameRows);
    disp(nameRowsT)

  • An example where n, r and rho have the same dimension.
  • x=(0.2:0.1:0.6)';
    rho=(0.1:0.1:0.5)';
    n= (10:10:50)';
    xs=string(x);
    rhos=string(rho);
    ns=string(n);
    Dens=corrpdf(x,rho,n);
    nameRows="f(r="+xs+"|rho="+ rhos+ ", n="+ ns+ ")=";
    nameRowsT=array2table(Dens,"RowNames",nameRows);
    disp(nameRowsT)

    Input Arguments

    expand all

    r — Value at which the pdf must be evaluated. Scalar, vector or matrix or 3D array.

    See "More About:" for details about the distribution of the correlation coefficient.

    Data Types: single | double

    rho — value of the correlation coefficient in the population. Scalar, vector or matrix or 3D array.

    If rho is not a scalar all the 3 input arguments (r,rho and n) must have the same size or just the numel of one of the 3 input arguments must be greater than 1

    Data Types: single | double

    n — sample size. Scalar, vector or matrix or 3D array.

    If n is not a scalar all the 3 input arguments (r,rho and n) must have the same size or just the numel of one of the 3 input arguments must be greater than 1

    Data Types: single | double

    Output Arguments

    expand all

    y —PDF value. Scalar, vector or matrix or 3D array of the same size of input arguments x, rho and n

    This is the probability density function for r, given n bivariate data coming from bivariate normal distribution with parameter rho.

    References

    Das Gupta, S. (1980). Distribution of the Correlation Coefficient, in: Fienberg, S.E., Hinkley, D.V. (eds) R.A. Fisher: An Appreciation, Lecture Notes in Statistics, vol 1. Springer, New York, NY.

    https://doi.org/10.1007/978-1-4612-6079-0_3

    Acknowledgements

    For additional information see https://mathworld.wolfram.com/CorrelationCoefficientBivariateNormalDistribution.html This function follows the lines of MATLAB code developed by Xu Cui, and the file exchange submission Joshua Carmichael (2022). sample correlation distribution function https://www.mathworks.com/matlabcentral/fileexchange/45785-sample-correlation-distribution-function/

    See Also

    This page has been automatically generated by our routine publishFS