<?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: How to test for linear relationship between 2 continuous variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813278#M320937</link>
    <description>&lt;P&gt;Show us a scatterplot, with phony variable names.&lt;/P&gt;</description>
    <pubDate>Fri, 13 May 2022 17:44:38 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-05-13T17:44:38Z</dc:date>
    <item>
      <title>How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813093#M320840</link>
      <description>&lt;P&gt;I have two continuous variables similar to the two below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars; set sashelp.cars; keep horsepower weight; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How can I &lt;STRONG&gt;test&lt;/STRONG&gt; if the relationship between the two is linear? As one might do before running a regression that assumes as much.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 21:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813093#M320840</guid>
      <dc:creator>kpberger</dc:creator>
      <dc:date>2022-05-12T21:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813095#M320841</link>
      <description>Correlation?</description>
      <pubDate>Thu, 12 May 2022 21:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813095#M320841</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-12T21:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813097#M320843</link>
      <description>&lt;P&gt;Old school is to plot the data such as :&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.cars;
  scatter x=weight y=horsepower;
run;&lt;/PRE&gt;
&lt;P&gt;If there is a strong or even medium strength relationship your eye will tell what form is likely.&lt;/P&gt;
&lt;P&gt;The funnel shape from this data indicates something interesting may be going on. So:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.cars;
  scatter x=weight y=horsepower/ group=type;
run;&lt;/PRE&gt;
&lt;P&gt;And it looks like there may be a "better" linear relationship between weight and horsepower when vehicle Type is considered.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 21:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813097#M320843</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-12T21:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813158#M320874</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290700"&gt;@kpberger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How can I &lt;STRONG&gt;test&lt;/STRONG&gt; if the relationship between the two is linear? As one might do before running a regression that assumes as much.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; said, you can always plot the raw data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The linear regression itself is a form of test. There's really no need to perform a formal test for linearity &lt;FONT color="#FF0000"&gt;before&lt;/FONT&gt; fitting a linear regression. If you assume it is linear, then fit the regression, plot the residuals. The advantage of plotting the residuals (as compared to plotting the raw data) is that deviations from linearity can be easier to spot in the residuals.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 10:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813158#M320874</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-13T10:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813270#M320930</link>
      <description>&lt;P&gt;Can use proc gam to test this? Looking at the p-values on the Analysis of Deviance table. For example, if I am trying to predict horsepower using weight:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc gam data=sashelp.cars plots=components(clm commonaxes); model horsepower=spline(weight); run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The p-value for spline(weight) is &amp;lt;0.0001 - is this referring to a rejection of the hypothesis that the relationship is linear/the spline is necessary? I can not tell from documentation/a day of internet searching.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813270#M320930</guid>
      <dc:creator>kpberger</dc:creator>
      <dc:date>2022-05-13T17:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813273#M320932</link>
      <description>&lt;P&gt;Honestly, you have ignored all of our advice to plot the data. Had you done so, I think the answer is relatively clear.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:20:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813273#M320932</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-13T17:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813274#M320933</link>
      <description>&lt;P&gt;Your assumption is incorrect. I have plotted the data. It is still not clear to me whether the relationships are linear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: I clearly asked in the question if there was a test for this. If there is no test, the correct answer to my question is just "there is no test".&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813274#M320933</guid>
      <dc:creator>kpberger</dc:creator>
      <dc:date>2022-05-13T17:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813275#M320934</link>
      <description>&lt;P&gt;After looking at the plot, I can't imagine what other model form (quadratic, spline, non-linear, &lt;EM&gt;etc&lt;/EM&gt;.) would be more appropriate for this data. What do you think is a better model if not linear?&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813275#M320934</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-13T17:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813276#M320935</link>
      <description>&lt;P&gt;The data I am using is not actually from a SAS help file. I offered that as an example to aid responses in being specific with code. The unshareable data I am using involves 30+ comparisons and the relationships are not clear.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813276#M320935</guid>
      <dc:creator>kpberger</dc:creator>
      <dc:date>2022-05-13T17:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813278#M320937</link>
      <description>&lt;P&gt;Show us a scatterplot, with phony variable names.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 17:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813278#M320937</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-13T17:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813279#M320938</link>
      <description>&lt;P&gt;I repeat, correlation, specifically PROC CORR.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;See this blog post.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/08/26/visualizing-correlations-between-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2011/08/26/visualizing-correlations-between-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Visually examine the graphs and/or look at the correlation matrix.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 18:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813279#M320938</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-13T18:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813285#M320942</link>
      <description>&lt;P&gt;This analysis tests for your questions, assuming gaussian independent errors :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glimmix data=sashelp.cars;
effect extraSplineEffect = spline(weight);
model horsepower = 
    weight            /* Is there a linear relationship ? */
    extraSplineEffect /* Is there more than just noise in the residuals ? */
    / htype=1;        /* Test these questions sequentially */
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1652466625803.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71438i138284413B996630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1652466625803.png" alt="PGStats_0-1652466625803.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interpretation, for this example: Yes, there is a linear trend relating horsepower to weight. And yes, there remains more than noise in the residuals once the linear trend is removed.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 18:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813285#M320942</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-05-13T18:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to test for linear relationship between 2 continuous variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813289#M320943</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290700"&gt;@kpberger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The data I am using is not actually from a SAS help file. I offered that as an example to aid responses in being specific with code. The unshareable data I am using involves 30+ comparisons and the relationships are not clear.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"30+ comparisons"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you suggesting 9 or more&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;variables?&amp;nbsp; &lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;It would take 9 variables to generate 36 unique&amp;nbsp; correlations (8 to generate 28).&amp;nbsp; That might change things, since you would be doing multiple comparisons.&amp;nbsp; If you intend some formal "statistical" inference of linear relationship for each of the bivariate relations, then I believe you are at risk of a&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Multiple_comparisons_problem" target="_self"&gt;Multiple Comparisons Problem&lt;/A&gt;.&amp;nbsp; I leave it to others to provide a more authoritative discussion of that possibility.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 18:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-for-linear-relationship-between-2-continuous/m-p/813289#M320943</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-13T18:44:53Z</dc:date>
    </item>
  </channel>
</rss>

