Last active
January 28, 2016 04:49
-
-
Save ymattu/d2628ab9d091b5e2e743 to your computer and use it in GitHub Desktop.
iml_linear_regression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc iml; | |
submit/R; | |
attitude; | |
endsubmit; | |
run ImportDataSetFromR("work.attitude","attitude"); | |
use attitude; | |
read all into M; /*attitudeを行列化*/ | |
L = nrow(M); /*Mの行数*/ | |
Y = M[,1]; /*目的変数を作成*/ | |
P = M[,2:7]; /*説明変数を作成*/ | |
E = J(L,1,1); /*行数がMと同じな、要素がすべて1の1列の行列を作る*/ | |
X = E || P; /*EとPを横に結合(説明変数行列完成)*/ | |
/*推定*/ | |
Beta = inv(X` * X) * X` * Y; | |
print Beta; | |
quit; | |
/*attitudeデータセットを表示*/ | |
proc print data=attitude(obs=30); | |
run; | |
/*プロシージャによる推定*/ | |
proc reg data = attitude; | |
model rating = complaints privileges learning raises critical advance; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment