|
|
|
||||
|
Help the Stat Consulting Group by
giving a gift
| |||||
|
Loading
|
|||||
options nocenter ;
data test ;
input y x0 x1 x2 ;
cards;
7 1 2 1
15 1 4 4
20 1 3 7
15 1 6 3
12 1 5 2
8 1 1 2
;
run;
proc iml;
* Read data into IML ;
use test;
read all ;
* combine x0 x1 x2 into a matrix X ;
x = x0 || x1 || x2;
print x;
* now get b ;
b = INV(x`*x)*(x`*y) ;
yp = x * b ;
ye = y - yp ;
print "predictor variables";
print x;
print "predicted variable";
print y;
print "parameter estimates";
print b;
print "predicted value of Y";
print yp ;
print "error in prediction of Y";
print ye ;
*writing out b as a data set;
create c var {parameter} ;
append from b;
quit;
proc print data = c;
run;
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services