|
|
沙发

楼主 |
发表于 2004-6-4 23:18:00
|
只看该作者
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 |
|