SAS中文论坛

标题: 有关矩阵运算符“\”的问题! [打印本页]

作者: shiyiming    时间: 2004-6-4 17:17
标题: 有关矩阵运算符“\”的问题!
sas9的帮助文件中,有关图形绘制的示例程序中存在以下语句:
xx=xx\rg \baccent \ms *xx/n;

其中的运算符(不知是否为运算符还是选项,暂且如此称呼,各位不要见笑)“\”表示什么意思?好像矩阵运算符中没有此项,我找了半天也未找见。或者“\rg”、“\baccent”、“\ms”等作为整体以选项的形式发挥功能?发挥的是什么功能?

我将该完整程序拷入program editor中运行,结果给出错误提示,说“\”为非法操作符,不知又是何原因?

哪位了解此功能?还请多多赐教。谢谢!
作者: shiyiming    时间: 2004-6-4 23:18
标题: baccent
从下面的程序来看“\baccent”好像是transpose的意思,其它的我估计也是一些选项。


A Module for Linear Regression
The previous method may be more familiar to statisticians when different notation is used. A linear model is usually written

y = Xb + e
where y is the vector of responses, X is the design matrix, and b is a vector of unknown parameters estimated by minimizing the sum of squares of e, the error or residual.
The following example illustrates the programming techniques involved in performing linear regression. It is not meant to replace regression procedures such as the REG procedure, which are more efficient for regressions and offer a multitude of diagnostic options.

Suppose that you have response data y measured at five values of the independent variable x and you want to perform a quadratic regression.

Submit the PROC IML statement to begin the procedure.

   > proc iml;

      IML Ready

Input the design matrix X and the data vector y as matrix literals.
   > x={1 1 1,
   >    1 2 4,
   >    1 3 9,
   >    1 4 16,
   >    1 5 25};


              X           5 rows      3 cols    (numeric)

                            1         1         1
                            1         2         4
                            1         3         9
                            1         4        16
                            1         5        25


   > y={1,5,9,23,36};

              Y           5 rows      1 col     (numeric)

                                      1
                                      5
                                      9
                                     23
                                     36

Compute the least-squares estimate of b using the traditional formula.
   > b=inv(x\baccent *x)*x\baccent *y;

              B             3 rows      1 col     (numeric)

                                        2.4
                                       -3.2
                                          2
作者: shiyiming    时间: 2004-6-4 23:54
标题: 示例程序能否正常运行?
感谢回复!

该示例程序能否正常运行呢?在您的机子上。
作者: shiyiming    时间: 2004-6-5 19:01
标题: Re: 示例程序能否正常运行?
[quote="student":85167]感谢回复!

该示例程序能否正常运行呢?在您的机子上。[/quote:85167]
好像也不行,不知道什么原因。
作者: shiyiming    时间: 2010-12-31 14:00
标题: Re: 有关矩阵运算符“\”的问题!
sashelp 中的对照关系

b=inv(x\baccent *x)*x\baccent *y;   ---- 伪码

xpxi=inv(t(x)*x);         /* inverse of X'X          */           --真实编码
beta=xpxi*(t(x)*y);       /* parameter estimate      */

x\baccent  <=====>t(x)        t(x) 既是转置  

用IML干什么呀?
工作只是 base stat  EM EG




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2