<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Correlation in between x and x2(square) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575063#M12788</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190716"&gt;@CSDoot1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here X is independent random variables and can take any positive value in that case what would be the Pearson's correlation coefficient.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing the actual values of X there is no "closed form" answer to this question.&lt;/P&gt;
&lt;P&gt;If you have not looked at the formula of the Pearson correlation coefficient, then it is time to do so.&lt;/P&gt;
&lt;P&gt;If you don't understand the equation then time to brush up on several elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jul 2019 21:56:45 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-07-19T21:56:45Z</dc:date>
    <item>
      <title>Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575049#M12780</link>
      <description>&lt;P&gt;What would be the Pearson correlation coefficient between x and x2. if X can take only positive values (&amp;gt;0).&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 20:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575049#M12780</guid>
      <dc:creator>CSDoot1</dc:creator>
      <dc:date>2019-07-19T20:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575055#M12784</link>
      <description>&lt;P&gt;Depends on the actual values of x and&amp;nbsp;how many repetitions the individual x values might&amp;nbsp;have.&lt;/P&gt;
&lt;P&gt;You can play with the upper and lower bounds on X in the do loop below and examine output for some feelling.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.junk;
   do x = 1 to 1000;
      x2= x*x;
     output;
   end;
run;

proc corr data=work.junk pearson;
run;&lt;/PRE&gt;
&lt;P&gt;A Spearman correlation would be 1.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 20:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575055#M12784</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-19T20:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575059#M12786</link>
      <description>&lt;P&gt;Here X is independent random variables and can take any positive value in that case what would be the Pearson's correlation coefficient.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 21:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575059#M12786</guid>
      <dc:creator>CSDoot1</dc:creator>
      <dc:date>2019-07-19T21:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575061#M12787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190716"&gt;@CSDoot1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here X is independent random variables and can take any positive value in that case what would be the Pearson's correlation coefficient.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; has given you code to estimate the correlation between x and x^2&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 21:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575061#M12787</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-19T21:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575063#M12788</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190716"&gt;@CSDoot1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here X is independent random variables and can take any positive value in that case what would be the Pearson's correlation coefficient.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing the actual values of X there is no "closed form" answer to this question.&lt;/P&gt;
&lt;P&gt;If you have not looked at the formula of the Pearson correlation coefficient, then it is time to do so.&lt;/P&gt;
&lt;P&gt;If you don't understand the equation then time to brush up on several elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 21:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575063#M12788</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-19T21:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575090#M12793</link>
      <description>&lt;P&gt;Take the formula and replace the components by x and x2 where necessary and see if you can simplify it. That would likely be your answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Pearson_correlation_coefficient" target="_blank"&gt;https://en.wikipedia.org/wiki/Pearson_correlation_coefficient&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG class="mwe-math-fallback-image-inline" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/8376b56be92af81e0b8f503735873c364d03b7a1" border="0" alt="{\displaystyle \rho _{X,Y}={\frac {\operatorname {E} [XY]-\operatorname {E} [X]\operatorname {E} [Y]}{{\sqrt {\operatorname {E} [X^{2}]-[\operatorname {E} [X]]^{2}}}~{\sqrt {\operatorname {E} [Y^{2}]-[\operatorname {E} [Y]]^{2}}}}}.}" aria-hidden="true" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But correlation is intended to measure the strength of a &lt;FONT size="4"&gt;&lt;STRONG&gt;linear relationship&lt;/STRONG&gt;&lt;/FONT&gt;, and x vs x2 is not a linear relationship, it's a quadratic relationship. If you recall from calculus, the range of the X will affect whether it appears as quadratic or linear, smaller ranges can appear linear instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190716"&gt;@CSDoot1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What would be the Pearson correlation coefficient between x and x2. if X can take only positive values (&amp;gt;0).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 01:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575090#M12793</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-20T01:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575133#M12808</link>
      <description>&lt;P&gt;Pearson Correlation is linear correlation NOT non-linear.&lt;/P&gt;
&lt;P&gt;But yours is non-linear . I remembered&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; wrote a blog about testing such non-linear correlation.&lt;/P&gt;
&lt;P&gt;Ha. It is called distance correlation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/04/04/distance-correlation.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/04/04/distance-correlation.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 12:00:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575133#M12808</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-20T12:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation in between x and x2(square)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575599#M12897</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190716"&gt;@CSDoot1&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190716"&gt;@CSDoot1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here X is independent random variables and can take any positive value in that case what would be the Pearson's correlation coefficient.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As others have pointed out, the answer to your question depends on the data (if it's about the &lt;EM&gt;empirical&lt;/EM&gt; correlation) or on the distribution of X (if it's about the &lt;EM&gt;random variables&lt;/EM&gt; X and X²). For the latter case&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has shown the relevant formula. It contains various expected values, so you see that the Pearson correlation coefficient &lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt; may not even &lt;EM&gt;exist&lt;/EM&gt; for certain distributions of X (e.g. Cauchy distribution).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for demonstration let's assume that X has a &lt;EM&gt;continuous&lt;/EM&gt; distribution with a probability density f(x)&amp;gt;0 for all x&amp;gt;0 and&amp;nbsp;f(x)=0 for all x&amp;lt;0 such that the first four moments about the origin (and hence the Pearson correlation coefficient) exist. Under these assumptions the set of possible values of&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;&amp;nbsp;equals the open interval &lt;STRONG&gt;(0, 1)&lt;/STRONG&gt;&amp;nbsp;(i.e., for any value 0&amp;lt;q&amp;lt;1 there's a distribution such that &lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;=q).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's why:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Our assumptions imply that the first four&amp;nbsp;moments about the origin (i.e. E[Xⁿ] for n=1, 2, 3, 4) and also Var(X) are positive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, we see that &lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;&amp;gt;0: The numerator in the formula, in our case: E[X³]−E[X]E[X²], is positive. This follows from the fact that E[X]²&amp;lt;E[X²] (because Var(X)&amp;gt;0), hence E[X]&amp;lt;√E[X²] and&amp;nbsp;E[X]E[X²]&amp;lt;E[X²]^(3/2). The latter term is ≤E[X³] by Lyapounov's inequality (a special case of which states: E[X²]^(1/2) ≤ E[|X|³]^(1/3); see, e.g., Billingsley, Probability and Measure, 3rd ed., p. 81).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second,&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;&amp;lt;1: Indeed,&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;=1 would imply P(X²=aX+b)=1 for some numbers a, b by a well known result found in textbooks on mathematical statistics (see, e.g., Casella, Berger: Statistical Inference, 2nd ed., Theorem 4.5.7b). But x²&amp;gt;ax+b for all x&amp;gt;k and a suitable k=k(a,b)&amp;gt;0 and we have P(X&amp;gt;k)&amp;gt;0 by our assumption on f.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's easy to find distributions for which&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt; takes &lt;EM&gt;large&lt;/EM&gt; values (&amp;lt;1).&lt;/P&gt;
&lt;P&gt;Example: The &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n164yyfgppedmkn1320boncqkh6r.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p11okoej6vilhyn1jz6khbjp1a4f" target="_blank" rel="noopener"&gt;gamma distribution&lt;/A&gt; with parameters &lt;EM&gt;a&lt;/EM&gt;, &lt;FONT face="symbol"&gt;l&amp;nbsp;&lt;/FONT&gt;&amp;gt; 0. A straight-forward calculation shows that in this case&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;=sqrt((a+1)/(a+3/2))&lt;/PRE&gt;
&lt;P&gt;(irrespective of scale parameter &lt;FONT face="symbol"&gt;l&lt;/FONT&gt;) -- an expression whose values cover the range (√(2/3), 1), i.e. (0.816..., 1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found it more difficult to construct a family of distributions for which&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt; takes &lt;EM&gt;small&lt;/EM&gt;&amp;nbsp;values (&amp;gt;0). This mixture of a &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n164yyfgppedmkn1320boncqkh6r.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1ps7yx8mxsa4xn1bcjru7gkuqzs" target="_blank" rel="noopener"&gt;uniform distribution&lt;/A&gt; and an &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n164yyfgppedmkn1320boncqkh6r.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n0z1nc8fb3mabsn1szvx0zrs1ola" target="_blank" rel="noopener"&gt;exponential distribution&lt;/A&gt;&amp;nbsp;seems to have this feature (for certain parameter values specified later): With parameters 0&amp;lt;c&amp;lt;1 and r≥1 define f(x)=1/c−c^(r−1) for 0≤x≤c and f(x)=c^r exp(c−x) for x&amp;gt;c.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After calculating the terms in the correlation coefficient formula (see SAS code below) it turns out that &lt;EM&gt;for 3&amp;lt;r&amp;lt;4&lt;/EM&gt; the lowest order terms (with respect to c) in the numerator and denominator are c³/12 and (under the square root) 2c^(r+2), respectively. Since 3&amp;gt;(r+2)/2, the limit of&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;&amp;nbsp;for c→0 is 0 (which is also true for some other values of r). On the other side we have&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;&amp;nbsp;→ 3/sqrt(10)=0.94868... for c→1 (irrespective of r) and for large values of r such as r=6:&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt;&amp;nbsp;→ sqrt(15)/4=0.96824... for c→0, thus overlapping the range found for the gamma distributions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is SAS code to compute and plot&amp;nbsp;&lt;FONT face="symbol"&gt;r&lt;/FONT&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;X,X²&lt;/FONT&gt; against c for selected values of r:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pearson(drop=i j);
array _r[6] _temporary_ (1, 2.7, 3.5, 5, 6, 8);
do j=1 to dim(_r);
  r=_r[j];
  do i=1 to 500;
    c=i/500;
    m1=c**r/2*(c+2)+c/2;
    m2=2*c**r/3*(c**2+3*c+3)+c**2/3;
    m3=3*c**r/4*(c**3+4*c**2+8*c+8)+c**3/4;
    m4=4*c**r/5*(c**4+5*c**3+15*c**2+30*c+30)+c**4/5;
    rho=(m3-m1*m2)/sqrt((m2-m1**2)*(m4-m2**2));
    output;
  end;
end;
lim1=sqrt(15)/4;
ref1='sqrt(15)/4';
lim2=3/sqrt(10);
ref2='3/sqrt(10)';
output;
run;

proc sgplot data=pearson;
series x=c y=rho / group=r;
refline lim1 / label=ref1;
refline lim2 / label=ref2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code for a simulation of the above family of distributions (&lt;EM&gt;caveat&lt;/EM&gt;: numerical instability for extreme values of the parameters, e.g. small values of c&lt;FONT face="arial,helvetica,sans-serif"&gt;)&lt;/FONT&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let c=0.1;
%let r=5;

data sim(drop=i);
call streaminit(27182818);
do i=1 to 1e7;
  if rand('bern',1-&amp;amp;c**&amp;amp;r) then x=rand('uniform',0,&amp;amp;c);
  else x=rand('expo',1)+&amp;amp;c;
  x2=x**2;
  output;
end;
run;

proc corr data=sim;
var x x2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[Edit: Fixed the hyperlink to the documentation on the uniform distribution.]&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 09:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation-in-between-x-and-x2-square/m-p/575599#M12897</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-07-23T09:22:26Z</dc:date>
    </item>
  </channel>
</rss>

