SAS/IML
外观
< SAS
IML是SAS的交互式矩阵编程语言。它类似于R、Matlab和Stata/Mata语言。您可以处理矩阵,并对这些矩阵进行任何操作。
data base ;
input x u ;
cards ;
1 -1
2 1
3 -1
4 1
5 -1
;
run ;
proc print data = base ; run ;
data base ;
set base ;
y = 1 + x + u ;
cste = 1 ;
run ;
proc print data = base ; run ;
proc iml;
use base; /*Reads the data*/
read all var {cste x} into x; /*creates matrix*/
read all var {y} into y;
beta=inv(x`*x)*(x`*y); /*computes point estimates*/
print beta;
yhat = x*beta; /*computes predicted values*/
print yhat ;
res = y - yhat ; /*Computes residuals*/
print res ;
SSR = res`*res; /*Computes the sum of squared residuals*/
print SSR ;
hatsigma = SSR / (nrow(y) - ncol(x)); /*Estimates the variance of u*/
print hatsigma ;
sigmabeta = hatsigma * inv(x`*x); /*Computes the variance of the estimator */
print sigmabeta ;
sebeta = sqrt(vecdiag(sigmabeta)); /*Computes standard error for each coefficient*/
print sebeta ;
student = beta / sebeta ; /* Computes the Student t statistic*/
print student ;
quit;
proc reg data = base ;
model y = x / I XPX ;
run ; quit ;
IML包含许多优化例程。
proc iml ;
seed = 123456;
c = j(5,1,seed);
b = uniform(c);
print b;
quit ;