Andrew
Andrew

Reputation: 3

Poisson Regression GLM in SAS

I'm attempting a Poisson Regression general linear model in SAS.

I'm an R user, so I have no idea how to do this stuff in SAS. I'll post the data, along with the code that I've attempted already:

  Game     Success     Attempts
  1        4             5 
  2        5             11
  3        5             14
  4        5             12
  5        2             7
  6        7             10
  7        6             14
  8        9             15
  9        4             12
 10        1              4
 11        13            27
 12        5             17
 13        6             12
 14        9              9
 15        7             12
 16        3             10
 17        8             12
 18        1              6
 19        18            39
 20        3             13
 21        10            17
 22        1              6 
 23        3             12

I've tried using several different codes on the data, but I keep getting errors.

This code doesn't work for the initial input:

options nocenter;

data freethrows;

input $attempt $success;

datalines;

...(this is where I put each attempt and success for each game in each row     for 23 rows)

;

run;

The example on the SAS website is the following:

data insure;

      input n c car$ age;

      ln = log(n);

      datalines;

   500   42  small  1

   1200  37  medium 1

   100    1  large  1

   400  101  small  2

   500   73  medium 2

   300   14  large  2

   ;

   run;

The GENMOD procedure is as follows:

proc genmod data=insure;

      class car age;

      model c = car age / dist   = poisson

                      link   = log

                      offset = ln;

   run;

I'd like to run a similar analysis on the freethrows.

Upvotes: 0

Views: 735

Answers (1)

IRTFM
IRTFM

Reputation: 263301

Need to take out the dollar signs since those force a variable to be considered as "character" rather than numeric. Will use "Game" as the predictor variable. Try this:

data games;
  input Game Success Attempts;
  lnAtt = log(Attempts);
  datalines;
  1        4             5 
  2        5             11
  3        5             14
  4        5             12
  5        2             7
  6        7             10
  7        6             14
  8        9             15
  9        4             12
 10        1              4
 11        13            27
 12        5             17
 13        6             12
 14        9              9
 15        7             12
 16        3             10
 17        8             12
 18        1              6
 19        18            39
 20        3             13
 21        10            17
 22        1              6 
 23        3             12
;
run;

Then execute the PROC:

proc genmod data=games;
      #  remove unless you have categorical variables; class car age;
      model Success = Game  / dist   = poisson
                      link   = log
                      offset = lnAtt;
   run;

This should be a test of the effect of the "seasoning of player experience", or some such, on success, i.e a a test of a linear trend in probability of 'Success' with increasing Game count. As a check against R's results:

    summary(glm(Success ~Game, offset=log(Attempts), family="poisson", data=games) )
#---------------------
Call:
glm(formula = Success ~ Game, family = "poisson", data = games, 
    offset = log(Attempts))

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.1957  -0.7962  -0.2722   0.6774   2.1110  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept) -0.679572   0.189074  -3.594 0.000325 ***
Game        -0.008375   0.013544  -0.618 0.536346    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 18.778  on 22  degrees of freedom
Residual deviance: 18.396  on 21  degrees of freedom
AIC: 100.72

Number of Fisher Scoring iterations: 4

So the coefficient is near zero (where a positive value would have indicated an increasing probability of Success with increase in Game count), and there is really no statistical evidence of an upward trend.

Upvotes: 1

Related Questions