Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 05-29-2020 09:23 AM
(180 views)

PROC IML/ CASE SCHILLER/REPEAT SALES INDEX

Posted 2 hours ago (19 views)

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.

Problem is, we have tried to work through the code but cannot make sense of why the matrix approach was applied.

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

Code:

proc iml;

/****************************************

Reading the data into a iml matrix

*****************************************/

Use price3;

/*price = j(2000000,482,0);*/ /*(number of transactions, number of date points,fill with zeros) = creating the size of the matrix price3 */

read all into price;

/************************************************************

Creating the X and Y matrix

Y is a matrix containing all the data for the

first month of the entire time period (bases time step)

and its size one by (number of transactions)

X is a matrix containing the data point from the second

time period to the last time period of all the transactions,

and its size is (time steps -1) by (amount of transactions)

*************************************************************/

X = price[,2:ncol(price)];

Y = Price[,1];

/*************************************************************

In order to compute beta according to the Case Shiller

method You have to change the first price in each row

of the X matrix to a negative value and keep the second

price the same, except if the transactions first price

falls within the bases time period thus in the Y matrix

then the first and only price in the X matrix row stays

positive.

**************************************************************/

do i = 1 to nrow(x);

one = 0;

if y[i,1] > 0 then

do j = 1 to ncol(x);

x[i,j] = x[i,j];

end;

else

do j = 1 to ncol(x);

if one = 0

then x[i,j] = x[i,j]*-1 ;

else x[i,j] = x[i,j];

one = x[i,j]+one;

end;

end;

/*************************************************************

Z is basically the X matrix except that the price is

changed to one thus where there is a negative price in

X there is -1 in Z and where there is a positive price

in X there is a 1 in Z else the rest stays zero.

**************************************************************/

Z = j(nrow(x),ncol(x),1);

do i = 1 to nrow(x);

do j = 1 to ncol(x);

if x[i,j] = 0 then z[i,j] = 0;

if x[i,j] > 0 then z[i,j] = 1;

if x[i,j] < 0 then z[i,j] = -1;

end;

end;

/**************************************************************

Now we compute Beta with the Case Shiller method using

the matrix Y, X and Z

***************************************************************/

B_inv_est = inv(Z`*X)*(Z`*Y);

B_est = 1/B_inv_est;

/**************************************************************

The following steps computes the weighted Beta were

transaction further apart is weighted less than transaction

close to each other, but this calculation uses a lot of space

and thus cannot be computed on my sas server.

***************************************************************/

/*q = Y-(X*B_inv_est);

w = j(nrow(q),nrow(q),0);

do i = 1 to nrow(q);

do j = 1 to nrow(q);

if i = j then w[i,j] = w[i,j]+q[i];

else w[i,j]= 0 ;

end;

end;

B_inv_weight = inv((X`)*(W**2)*X)*((X`)*(W**2)*Y);

B_weight = 1/B_inv_weight;*/

print B_inv_est B_est /*B_inv_weight B_weight*/;

create B_est ; /** create data set **/

append; /** write data in vectors **/

close B_est; /** close the data set **/

quit;

data B_est;

set work.B_EST;

where B_EST > 0.0000001;

N = _N_;

run;

proc expand data=B_est out=B_est_HP_T5 method=none;

id N;

/* by B_est;*/

convert B_est = HP_B_est/ transformout=(HP_T 5);

run;

1 REPLY 1

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Duplicate of

Please respond to the other thread.

📢

**ANNOUNCEMENT**

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.** **

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.