Capítulo 4 - Modelos de Regressão Paramétricos

 data desmame;
 input id tempo cens V3 V2 V7 V11 V4 V1 V6 V10 V8 V9 V5;
 V13=V1*V3;
 V14=V1*V4;
 V16=V1*V6;
 V34=V3*V4;
 V36=V3*V6;
 V38=V3*V8;
 V46=V4*V6;
 V48=V4*V8;
 V68=V6*V8;
 cards;
 1   6   1   0   0   0   1   0   0   0   1   1   1   0
 5   8   1   0   0   0   1   1   1   1   1   1   1   1
 ...
 153 9   0   1   1   0   1   0   0   1   1   1   0   0
 ;
 proc lifereg;
 model tempo*cens(0)= /distribution=gamma;
 run;
 proc lifereg;
 model tempo*cens(0)=V1 /distribution=gamma;
 run;
 proc lifereg;
 model tempo*cens(0)=V2 /distribution=gamma;
 run;
 proc lifereg;
 model tempo*cens(0)= V1 V2 V3 V4 V6 V8 V9 /distribution=gamma;
 run;
 proc lifereg;
 model tempo*cens(0)= V2 V3 V4 V6 V8 V9 /distribution=gamma;
 run;
 proc lifereg;
 model tempo*cens(0))= V3 V4 V6 V8/distribution=gamma;
 run;
 proc lifereg;
 model tempo*cens(0)= V3 V4 V6 V8 V34/distribution=gamma;
 run;

Capítulo 8 - Censura Intervalar e Dados Grupados

 ==========================================================
 an = ano codificado (73 = 1; 74 = 2; ...; 92 = 13)
 freq = frequencia (uma observacao por linha, logo freq = 1
 ==========================================================

 options nonumber linesize=90 ps=500;
 data mang;
 input obs ano $ ti cens li ui copa $ cavalo $ bloco $ an $ freq ;
 datalines;
 1    85 14    1 12 14    1      1     3  6 1
 2    85 14    1 12 14    1      1     4  6 1
 3    88 17    1 16 17    1      1     5  9 1
 4    90 19    1 18 19    1      1     1 11 1
 5    92 21    0 21  .    1      1     2 13 1
 6    85 14    1 12 14    1      2     3  6 1
 7    85 14    1 12 14    1      2     4  6 1
 8    85 14    1 12 14    1      2     5  6 1
 9    88 17    1 16 17    1      2     1  9 1
 10   88 17    1 16 17    1      2     2  9 1
 11   88 17    1 16 17    1      3     5  9 1
 12   89 18    1 17 18    1      3     1 10 1
 13   90 19    1 18 19    1      3     4 11 1
 14   92 21    0 21  .    1      3     3 13 1
 15   92 21    0 21  .    1      3     2 13 1
 16   81 10    1  4 10    1      4     4  4 1
 17   88 17    1 16 17    1      4     1  9 1
 18   88 17    1 16 17    1      4     5  9 1
 19   92 21    0 21  .    1      4     2 13 1
 20   92 21    0 21  .    1      4     3 13 1
 21   73  2    1  0  2    1      5     1  1 1
 22   85 14    1 12 14    1      5     3  6 1
 23   88 17    1 16 17    1      5     5  9 1
 24   90 19    1 18 19    1      5     4 11 1
 25   92 21    0 21  .    1      5     2 13 1
 26   81 10    1  4 10    1      6     4  4 1
 27   87 16    1 15 16    1      6     5  8 1 
 28   89 18    1 17 18    1      6     1 10 1
 29   90 19    1 18 19    1      6     2 11 1
 30   90 19    1 18 19    1      6     3 11 1
 31   73  2    1  0  2    1      7     5  1 1
 32   87 16    1 15 16    1      7     4  8 1
 33   90 19    1 18 19    1      7     3 11 1
 34   92 21    0 21  .    1      7     2 13 1
 35   92 21    0 21  .    1      7     1 13 1
 36   89 18    1 17 18    2      1     5 10 1
 37   90 19    1 18 19    2      1     4 11 1
 38   92 21    0 21  .    2      1     3 13 1
 39   92 21    0 21  .    2      1     2 13 1
 40   92 21    0 21  .    2      1     1 13 1
 41   87 16    1 15 16    2      2     4  8 1
 42   88 17    1 16 17    2      2     1  9 1
 43   90 19    1 18 19    2      2     5 11 1
 44   92 21    0 21  .    2      2     2 13 1
 45   92 21    0 21  .    2      2     3 13 1
 46   92 21    0 21  .    2      3     1 13 1
 47   92 21    0 21  .    2      3     2 13 1
 48   92 21    0 21  .    2      3     3 13 1
 49   92 21    0 21  .    2      3     4 13 1
 50   92 21    0 21  .    2      3     5 13 1
 51   81 10    1  4 10    2      4     3  4 1
 52   88 17    1 16 17    2      4     5  9 1
 53   89 18    1 17 18    2      4     1 10 1
 54   90 19    1 18 19    2      4     2 11 1
 55   92 21    1 19 21    2      4     4 12 1
 56   73  2    1  0  2    2      5     1  1 1
 57   74  3    1  2  3    2      5     2  2 1
 58   74  3    1  2  3    2      5     3  2 1
 59   88 17    1 16 17    2      5     4  9 1
 60   92 21    0 21  .    2      5     5 13 1
 61   83 12    1 10 12    2      6     5  5 1
 62   90 19    1 18 19    2      6     1 11 1
 63   90 19    1 18 19    2      6     4 11 1
 64   92 21    0 21  .    2      6     2 13 1
 65   92 21    0 21  .    2      6     3 13 1
 66   88 17    1 16 17    2      7     2  9 1
 67   88 17    1 16 17    2      7     5  9 1
 68   90 19    1 18 19    2      7     3 11 1
 69   90 19    1 18 19    2      7     4 11 1
 70   92 21    0 21  .    2      7     1 13 1
 71   73  2    1  0  2    3      1     5  1 1
 72   89 18    1 17 18    3      1     4 10 1
 73   92 21    0 21  .    3      1     3 13 1
 74   92 21    0 21  .    3      1     2 13 1
 75   92 21    0 21  .    3      1     1 13 1
 76   74  3    1  2  3    3      2     4  2 1
 77   74  3    1  2  3    3      2     5  2 1
 78   88 17    1 16 17    3      2     2  9 1
 79   92 21    0 21  .    3      2     1 13 1
 80   92 21    0 21  .    3      2     3 13 1
 81   73  2    1  0  2    3      3     3  1 1
 82   73  2    1  0  2    3      3     5  1 1
 83   88 17    1 16 17    3      3     4  9 1
 84   92 21    0 21  .    3      3     2 13 1
 85   92 21    0 21  .    3      3     1 13 1
 86   74  3    1  2  3    3      4     5  2 1
 87   75  4    1  3  4    3      4     3  3 1
 88   87 16    1 15 16    3      4     4  8 1
 89   90 19    1 18 19    3      4     1 11 1
 90   92 21    0 21  .    3      4     2 13 1
 91   74  3    1  2  3    3      5     2  2 1
 92   74  3    1  2  3    3      5     4  2 1
 93   87 16    1 15 16    3      5     5  8 1
 94   90 19    1 18 19    3      5     3 11 1
 95   92 21    0 21  .    3      5     1 13 1
 96   73  2    1  0  2    3      6     1  1 1
 97   86 15    1 14 15    3      6     3  7 1
 98   90 19    1 18 19    3      6     4 11 1
 99   90 19    1 18 19    3      6     5 11 1
 100  92 21    0 21  .    3      6     2 13 1
 101  73  2    1  0  2    3      7     2  1 1
 102  81 10    1  4 10    3      7     5  4 1
 103  90 19    1 18 19    3      7     1 11 1
 104  90 19    1 18 19    3      7     4 11 1
 105  92 21    1 19 21    3      7     3 12 1
 106  88 17    1 16 17    4      1     5  9 1
 107  90 19    1 18 19    4      1     3 11 1
 108  92 21    0 21  .    4      1     4 13 1
 109  92 21    0 21  .    4      1     2 13 1
 110  92 21    0 21  .    4      1     1 13 1
 111  73  2    1  0  2    4      2     2  1 1
 112  86 15    1 14 15    4      2     1  7 1
 113  86 15    1 14 15    4      2     4  7 1
 114  92 21    0 21  .    4      2     3 13 1
 115  92 21    0 21  .    4      2     5 13 1
 116  86 15    1 14 15    4      3     1  7 1
 117  88 17    1 16 17    4      3     3  9 1
 118  88 17    1 16 17    4      3     4  9 1
 119  90 19    1 18 19    4      3     2 11 1
 120  92 21    1 19 21    4      3     5 12 1
 121  81 10    1  4 10    4      4     2  4 1
 122  85 14    1 12 14    4      4     5  6 1
 123  87 16    1 15 16    4      4     4  8 1
 124  92 21    0 21  .    4      4     1 13 1
 125  92 21    0 21  .    4      4     3 13 1
 126  73  2    1  0  2    4      5     2  1 1
 127  81 10    1  4 10    4      5     4  4 1
 128  85 14    1 12 14    4      5     5  6 1
 129  92 21    0 21  .    4      5     1 13 1
 130  92 21    0 21  .    4      5     3 13 1
 131  87 16    1 15 16    4      6     2  8 1
 132  90 19    1 18 19    4      6     4 11 1
 133  90 19    1 18 19    4      6     5 11 1
 134  92 21    1 19 21    4      6     3 12 1
 135  92 21    1 19 21    4      6     1 12 1
 136  87 16    1 15 16    4      7     4  8 1
 137  87 16    1 15 16    4      7     5  8 1
 138  89 18    1 17 18    4      7     3 10 1
 139  92 21    0 21  .    4      7     1 13 1
 140  92 21    0 21  .    4      7     2 13 1
 141  73  2    1  0  2    5      1     5  1 1
 142  85 14    1 12 14    5      1     1  6 1
 143  89 18    1 17 18    5      1     2 10 1
 144  90 19    1 18 19    5      1     3 11 1
 145  92 21    0 21  .    5      1     4 13 1
 146  85 14    1 12 14    5      2     2  6 1
 147  85 14    1 12 14    5      2     4  6 1
 148  89 18    1 17 18    5      2     3 10 1
 149  92 21    0 21  .    5      2     1 13 1
 150  92 21    0 21  .    5      2     5 13 1
 151  86 15    1 14 15    5      3     1  7 1
 152  86 15    1 14 15    5      3     2  7 1
 153  88 17    1 16 17    5      3     4  9 1
 154  92 21    0 21  .    5      3     3 13 1
 155  92 21    0 21  .    5      3     5 13 1
 156  81 10    1  4 10    5      4     5  4 1
 157  85 14    1 12 14    5      4     2  6 1
 158  86 15    1 14 15    5      4     3  7 1
 159  87 16    1 15 16    5      4     4  8 1
 160  92 21    0 21  .    5      4     1 13 1
 161  73  2    1  0  2    5      5     2  1 1
 162  86 15    1 14 15    5      5     1  7 1
 163  89 18    1 17 18    5      5     5 10 1
 164  92 21    0 21  .    5      5     3 13 1
 165  92 21    0 21  .    5      5     4 13 1
 166  86 15    1 14 15    5      6     1  7 1
 167  88 17    1 16 17    5      6     4  9 1
 168  92 21    1 19 21    5      6     5 12 1
 169  92 21    0 21  .    5      6     2 13 1
 170  92 21    0 21  .    5      6     3 13 1
 171  74  3    1  2  3    5      7     2  2 1
 172  88 17    1 16 17    5      7     3  9 1
 173  92 21    0 21  .    5      7     1 13 1
 174  92 21    0 21  .    5      7     4 13 1
 175  92 21    0 21  .    5      7     5 13 1
 176  85 14    1 12 14    6      1     2  6 1
 177  86 15    1 14 15    6      1     1  7 1
 178  87 16    1 15 16    6      1     4  8 1
 179  88 17    1 16 17    6      1     5  9 1
 180  89 18    1 17 18    6      1     3 10 1
 181  85 14    1 12 14    6      2     1  6 1
 182  85 14    1 12 14    6      2     3  6 1
 183  85 14    1 12 14    6      2     5  6 1
 184  86 15    1 14 15    6      2     2  7 1
 185  90 19    1 18 19    6      2     4 11 1
 186  85 14    1 12 14    6      3     4  6 1
 187  87 16    1 15 16    6      3     5  8 1
 188  88 17    1 16 17    6      3     3  9 1
 189  88 17    1 16 17    6      3     2  9 1
 190  88 17    1 16 17    6      3     1  9 1
 191  85 14    1 12 14    6      4     1  6 1
 192  86 15    1 14 15    6      4     3  7 1
 193  87 16    1 15 16    6      4     2  8 1
 194  88 17    1 16 17    6      4     4  9 1
 195  88 17    1 16 17    6      4     5  9 1
 196  83 12    1 10 12    6      5     4  5 1
 197  85 14    1 12 14    6      5     1  6 1
 198  85 14    1 12 14    6      5     2  6 1
 199  85 14    1 12 14    6      5     3  6 1
 200  85 14    1 12 14    6      5     5  6 1
 201  85 14    1 12 14    6      6     2  6 1
 202  87 16    1 15 16    6      6     4  8 1
 203  87 16    1 15 16    6      6     1  8 1
 204  88 17    1 16 17    6      6     3  9 1
 205  90 19    1 18 19    6      6     5 11 1
 206  81 10    1  4 10    6      7     4  4 1
 207  86 15    1 14 15    6      7     3  7 1
 208  87 16    1 15 16    6      7     5  8 1
 209  88 17    1 16 17    6      7     1  9 1
 210  90 19    1 18 19    6      7     2 11 1
 ;
 run;
 /*proc print data=mang; */
 /* run;*/
   
 data dadmang;
      retain interv1-interv12 0;
      array dd[12] interv1-interv12;
      set mang;
      if an = 13 then do interv=1 to 12;
         y=0; dd[interv]=1;
         output;
         dd[interv]=0;
      end;
      else do interv=1 to an;
         if interv=an then y=1;
         else y=0;
         dd[interv]=1;
         output;
         dd[interv]=0;
      end;
 /*proc print data=dadmang;*/
 /*run;*/
 /*Modelo de Cox */ 
 proc logistic data=intervs descending outest=est1;
      class bloco copa cavalo /param=reference ref=first; 
      model y= interv1-interv12 bloco copa cavalo copa*cavalo/ noint link=cloglog
                                                               technique=newton;
      freq freq;
   run;
 proc logistic data=intervs descending outest=est1;
      class bloco copa cavalo /param=reference ref=first; 
      model y= interv1-interv12 bloco copa cavalo /noint link=cloglog
                                                   technique=newton;
      freq freq;
   run;
 proc logistic data=intervs descending outest=est1;
      class bloco copa / param=reference ref=first;
      model y= interv1-interv12 bloco copa /noint link=cloglog
                                            technique=newton;
      freq freq;
   run;
 /*Modelo logistico*/
 proc logistic data=intervs descending outest=est1;
      class bloco copa / param=reference ref=first;
      model y= interv1-interv12 bloco copa /noint link=logit
                                            technique=newton;
      freq freq;
   run;