繁体   English   中英

SAS中的泊松回归GLM

[英]Poisson Regression GLM in SAS

我正在尝试在SAS中使用Poisson回归通用线性模型。

我是R用户,所以我不知道如何在SAS中执行此操作。 我将发布数据以及已经尝试过的代码:

  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

我尝试在数据上使用几种不同的代码,但是我一直在出错。

该代码不适用于初始输入:

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;

SAS网站上的示例如下:

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;

GENMOD程序如下:

proc genmod data=insure;

      class car age;

      model c = car age / dist   = poisson

                      link   = log

                      offset = ln;

   run;

我想对罚球进行类似的分析。

需要删除美元符号,因为那些符号将变量视为“字符”而不是数字。 将使用“游戏”作为预测变量。 尝试这个:

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;

然后执行PROC:

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

这应该是对“玩家体验的季节变化”或其他对成功的影响的测试,即对“成功”概率随游戏数量增加的线性趋势的测试。 作为对R结果的检验:

    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

因此,系数接近于零(正值表示随着游戏计数的增加,成功的可能性也会增加),并且实际上没有统计证据表明该趋势呈上升趋势。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM