LoginSignup
0
1

More than 1 year has passed since last update.

Proc Logisticの使い方

Last updated at Posted at 2022-02-06

SASあるあるで日本語記事が少なく、英語記事は毎回探して読むのが面倒なのでまとめます。
誤り等ありましたらご指摘をお願いいたします。

基本

proc logistic data = ;
    model y = x ;
run;

詳細

PROC LOGISTIC < options >;
    BY variables ;
    CLASS variable <(v-options)> <variable <(v-options)>... > < / v-options >;
    CONTRAST ’label’ effect values <,... effect values>< =options >;
    FREQ variable ;
    MODEL response = < effects >< / options >;
    MODEL events/trials = < effects >< / options >;
    OUTPUT < OUT=SAS-data-set > < keyword=name:::keyword=name > / < option >;
    < label: > TEST equation1 < , ::: , < equationk >>< /option >;
    UNITS independent1 = list1 < ::: independentk = listk >< /option > ;
    WEIGHT variable </ option >;
RUN;

classステートメント

自動的に説明変数のダミー変数を生成。(=数量値は指定しなくてOK)
CLASSステートメントで PARAM=オプションを指定することでダミー変数の生成方法を指定できる。
PARAMオプションにはREF, EFFECT, GLM等色々あるので参考文献参照。

proc logistic data = Neuralgia ;
 class Treatment Sex / param=effect ;
 model Pain = Treatment Sex ;
run;

modelステートメント

モデルの推定結果の出力

上から順に、2値、2値(逆)、名義
※modelステートメントは一回のプロシジャ実行に付き一つしか記述できません。
下のコードは例であり、このままだとエラーになります。

model y(event='1') = <your model effects>;
model y(order=data) = <your model effects>;
model y(order=data descending) = <your model effects>;
model y(ref='1') = <your model effects>;

Stepwise法

model remiss(event='1')=cell smear infil li blast temp
                / selection=stepwise
                  slentry=0.3
                  slstay=0.35
                  details
                  lackfit;

変数をモデルに入れるには0.3の有意水準が必要で (SLENTRY=0.3)、変数がモデルに残るには0.35の有意水準が必要です (SLSTAY=0.35)。slentryはselection entryの略だろうか。
変数選択プロセスの詳細な説明は、DETAILS オプションを指定することで要求されます。最終的に選択されたモデルのHosmer and Lemeshow適合度検定は、LACKFITオプションを指定することによって要求されます。

estimateステートメント

工事中

strataステートメント

工事中

byステートメント

byで指定するとその変数ごとにそれぞれ回帰する。

予測

*やり方1;
OUTPUT OUT=out P=predict;

*やり方2;
/* 推定したモデルの情報をデータセットMODELに出力 */
   PROC LOGISTIC DATA=A OUTMODEL=model;
     MODEL <モデル式の記述>;
   RUN;
/* データセットBに対する予測値を算出 */
   PROC LOGISTIC INMODEL=model;
     SCORE DATA=B OUT=out;
   RUN;

参考文献

公式マニュアル(英語): https://www.math.wpi.edu/saspdf/stat/chap39.pdf
https://www.sas.com/offices/asiapacific/japan/service/technical/faq/list/body/stat089.html
https://www.sas.com/offices/asiapacific/japan/service/technical/faq/list/body/stat083.html
https://www.yukms.com/biostat/takahasi/rec/archive/semi22.pdf
class:https://www.sas.com/content/dam/SAS/ja_jp/doc/event/sas-user-groups/usergroups14-a-03.pdf
Stepwise法: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_logistic_examples01.htm
参考: https://www.croit.com/wp_croit2/wp-content/uploads/2018/12/04_01.pdf

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1