Date: Wed, 22 Oct 2003 13:10:38 -0500
Reply-To: Robin High <robinh@UNLSERVE.UNL.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Robin High <robinh@UNLSERVE.UNL.EDU>
Subject: Re: SAS/IML
In-Reply-To: <Sea1-F52IIzQtO9vXLs000237f2@hotmail.com>
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sonia,
It seems your IML program is not complete since the regression procedure
is written as a module that begins with START. A few embellishments seem
to make it work:
proc iml;
use inmoodata;
read all var {rp12} into y ;
read all var { x1 x2 x3 } into x;
print x, y;
start reg(x,y);
reset print;
n=nrow(x); /* number of observations */
k=ncol(x); /* number of variables */
xpx=x`*x; /* cross-products */
xpy=x`*y;
xpxi=inv(xpx); /* inverse crossproducts */
b=xpxi*xpy; /* parameter estimates */
yhat=x*b; /* predicted values */
resid=y-yhat; /* residuals */
sse=resid`*resid; /* sum of squared errors */
dfe=n-k; /* degrees of freedom error */
mse=sse/dfe; /* mean squared error */
rmse=sqrt(mse); /* root mean squared error */
covb=xpxi#mse; /* covariance of estimates */
stdb=sqrt(vecdiag(covb)); /* standard errors */
t=b/stdb; /* ttest for estimates=0 */
probt=1-probf(t#t,1,dfe); /* significance probability */
print name b stdb t probt;
finish;
RUN reg(x,y); * The RUN statement executes the module;
quit;
Robin High
University of Oregon
|