<?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: Regression Model in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Regression-Model/m-p/652878#M5131</link>
    <description>&lt;P&gt;Duplicate of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/PROC-IML-CASE-SCHILLER-REPEAT-SALES-INDEX/m-p/651691" target="_blank"&gt;https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/PROC-IML-CASE-SCHILLER-REPEAT-SALES-INDEX/m-p/651691&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Please respond to the other thread.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2020 13:38:48 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-06-03T13:38:48Z</dc:date>
    <item>
      <title>Regression Model</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Regression-Model/m-p/651709#M5119</link>
      <description>&lt;DIV class="forum-subj-action"&gt;&lt;DIV class="lia-message-subject lia-component-message-view-widget-subject"&gt;&lt;DIV class="MessageSubject"&gt;&lt;DIV class="MessageSubjectIcons "&gt;&lt;DIV class="lia-message-subject"&gt;PROC IML/ CASE SCHILLER/REPEAT SALES INDEX&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="forum-post"&gt;&lt;DIV class="post-info"&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-IML-CASE-SCHILLER-REPEAT-SALES-INDEX/td-p/651691" target="_blank" rel="noopener"&gt;&lt;SPAN class="message-date-friendly" style="box-sizing: border-box;"&gt;Posted 2 hours ago&lt;/SPAN&gt; &lt;/A&gt;&lt;SPAN class="message-date-views" style="box-sizing: border-box;"&gt;(19 views)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Hi Everyone. I am quite stuck. I inherited a house price index model which is founded on the case schiller methodology and uses a proc iml/matrix function to calculate the betas of the model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem is, we have tried to work through the code but cannot make sense of why the matrix approach was applied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If any, is there something I can use to replace this function with? (I'm taking a shot in the dark here). Also, a lambda of five is used in the HP filter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;/****************************************&lt;BR /&gt;Reading the data into a iml matrix&lt;BR /&gt;*****************************************/&lt;BR /&gt;Use price3;&lt;BR /&gt;/*price = j(2000000,482,0);*/ /*(number of transactions, number of date points,fill with zeros) = creating the size of the matrix price3 */&lt;BR /&gt;read all into price;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/************************************************************&lt;BR /&gt;Creating the X and Y matrix&lt;/P&gt;&lt;P&gt;Y is a matrix containing all the data for the&lt;BR /&gt;first month of the entire time period (bases time step)&lt;BR /&gt;and its size one by (number of transactions)&lt;/P&gt;&lt;P&gt;X is a matrix containing the data point from the second&lt;BR /&gt;time period to the last time period of all the transactions,&lt;BR /&gt;and its size is (time steps -1) by (amount of transactions)&lt;BR /&gt;*************************************************************/&lt;/P&gt;&lt;P&gt;X = price[,2:ncol(price)];&lt;BR /&gt;Y = Price[,1];&lt;/P&gt;&lt;P&gt;/*************************************************************&lt;BR /&gt;In order to compute beta according to the Case Shiller&lt;BR /&gt;method You have to change the first price in each row&lt;BR /&gt;of the X matrix to a negative value and keep the second&lt;BR /&gt;price the same, except if the transactions first price&lt;BR /&gt;falls within the bases time period thus in the Y matrix&lt;BR /&gt;then the first and only price in the X matrix row stays&lt;BR /&gt;positive.&lt;BR /&gt;**************************************************************/&lt;/P&gt;&lt;P&gt;do i = 1 to nrow(x);&lt;BR /&gt;one = 0;&lt;BR /&gt;if y[i,1] &amp;gt; 0 then&lt;BR /&gt;do j = 1 to ncol(x);&lt;BR /&gt;x[i,j] = x[i,j];&lt;BR /&gt;end;&lt;BR /&gt;else&lt;BR /&gt;do j = 1 to ncol(x);&lt;BR /&gt;if one = 0&lt;BR /&gt;then x[i,j] = x[i,j]*-1 ;&lt;BR /&gt;else x[i,j] = x[i,j];&lt;BR /&gt;one = x[i,j]+one;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;/*************************************************************&lt;BR /&gt;Z is basically the X matrix except that the price is&lt;BR /&gt;changed to one thus where there is a negative price in&lt;BR /&gt;X there is -1 in Z and where there is a positive price&lt;BR /&gt;in X there is a 1 in Z else the rest stays zero.&lt;BR /&gt;**************************************************************/&lt;/P&gt;&lt;P&gt;Z = j(nrow(x),ncol(x),1);&lt;BR /&gt;do i = 1 to nrow(x);&lt;BR /&gt;do j = 1 to ncol(x);&lt;BR /&gt;if x[i,j] = 0 then z[i,j] = 0;&lt;BR /&gt;if x[i,j] &amp;gt; 0 then z[i,j] = 1;&lt;BR /&gt;if x[i,j] &amp;lt; 0 then z[i,j] = -1;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;/**************************************************************&lt;BR /&gt;Now we compute Beta with the Case Shiller method using&lt;BR /&gt;the matrix Y, X and Z&lt;BR /&gt;***************************************************************/&lt;/P&gt;&lt;P&gt;B_inv_est = inv(Z`*X)*(Z`*Y);&lt;BR /&gt;B_est = 1/B_inv_est;&lt;/P&gt;&lt;P&gt;/**************************************************************&lt;BR /&gt;The following steps computes the weighted Beta were&lt;BR /&gt;transaction further apart is weighted less than transaction&lt;BR /&gt;close to each other, but this calculation uses a lot of space&lt;BR /&gt;and thus cannot be computed on my sas server.&lt;BR /&gt;***************************************************************/&lt;/P&gt;&lt;P&gt;/*q = Y-(X*B_inv_est);&lt;BR /&gt;w = j(nrow(q),nrow(q),0);&lt;BR /&gt;do i = 1 to nrow(q);&lt;BR /&gt;do j = 1 to nrow(q);&lt;BR /&gt;if i = j then w[i,j] = w[i,j]+q[i];&lt;BR /&gt;else w[i,j]= 0 ;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;B_inv_weight = inv((X`)*(W**2)*X)*((X`)*(W**2)*Y);&lt;BR /&gt;B_weight = 1/B_inv_weight;*/&lt;/P&gt;&lt;P&gt;print B_inv_est B_est /*B_inv_weight B_weight*/;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;create B_est ; /** create data set **/&lt;BR /&gt;append; /** write data in vectors **/&lt;BR /&gt;close B_est; /** close the data set **/&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data B_est;&lt;BR /&gt;set work.B_EST;&lt;BR /&gt;where B_EST &amp;gt; 0.0000001;&lt;BR /&gt;N = _N_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc expand data=B_est out=B_est_HP_T5 method=none;&lt;BR /&gt;id N;&lt;BR /&gt;/* by B_est;*/&lt;BR /&gt;convert B_est = HP_B_est/ transformout=(HP_T 5);&lt;BR /&gt;run;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 29 May 2020 13:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Regression-Model/m-p/651709#M5119</guid>
      <dc:creator>Tzar</dc:creator>
      <dc:date>2020-05-29T13:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regression Model</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Regression-Model/m-p/652878#M5131</link>
      <description>&lt;P&gt;Duplicate of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/PROC-IML-CASE-SCHILLER-REPEAT-SALES-INDEX/m-p/651691" target="_blank"&gt;https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/PROC-IML-CASE-SCHILLER-REPEAT-SALES-INDEX/m-p/651691&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Please respond to the other thread.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Regression-Model/m-p/652878#M5131</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-06-03T13:38:48Z</dc:date>
    </item>
  </channel>
</rss>

