Help us understand the problem. What is going on with this article?

一般化線形回帰の拡張

SAS Viyaで一般線形回帰モデルの拡張を行う方法を紹介します。プログラミング言語はPythonになります。

モデルの生成

モデルは Genmod メソッドを使います。

cars = conn.CASTable('cars')
genmodModel1 = cars.Genmod()

モデルに対してパラメータの設定

genmodModel1.model に対してパラメータを設定します。今回はリンク関数にlogを指定しています。

genmodModel1.model.depvars = 'MSRP'
genmodModel1.model.effects = ['MPG_City']
genmodModel1.model.dist = 'gamma'
genmodModel1.model.link = 'log'
genmodModel1.model.depvars = 'Cylinders'
genmodModel1.model.dist = 'multinomial'
genmodModel1.model.link = 'logit'
genmodModel1.model.effects = ['MPG_City']
genmodModel1.display.names = ['ModelInfo', 'ParameterEstimates']

アウトプットの設定を行う

そして結果の出力用テーブルを用意します。

genmodResult = conn.CASTable('CylinderPredicted', replace=True)
genmodModel1.output.casout = genmodResult
genmodModel1.output.copyVars = 'ALL';
genmodModel1.output.pred = 'Prob_Cylinders'
genmodModel1()
genmodResult[['Prob_Cylinders','_level_','Cylinders','MPG_City']].head(24)

結果は次のように出力されます。

Selected Rows from Table CYLINDERPREDICTED
Prob_Cylinders _LEVEL_ Cylinders MPG_City
0 1.928842e-19 3.0 6.0 17.0
1 1.442488e-02 4.0 6.0 17.0
22 9.999077e-01 8.0 6.0 20.0
23 9.999530e-01 10.0 6.0 20.0

まとめ

SAS Viyaでは簡単に一般化線形回帰が使えますが、よりカスタマイズしたい時にも簡単にできます。ぜひデータ分析に役立ててください。

SAS for Developers | SAS

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした