"R glm()"의 두 판 사이의 차이

83번째 줄: 83번째 줄:
* [[R summary.glm()]]
* [[R summary.glm()]]
* [[R lm()]]
* [[R lm()]]
* [[R polr()]]
* [[R loglin()]]
* [[R loglin()]]
* [[R loglm()]]
* [[R loglm()]]

2020년 4월 12일 (일) 17:41 판

1 개요

R glm()
  • "Generalized Linear Model"
library("MASS")
str(menarche)
summary(glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial, data=menarche))
## 
## Call:
## glm(formula = cbind(Menarche, Total - Menarche) ~ Age, family = binomial, 
##     data = menarche)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0363  -0.9953  -0.4900   0.7780   1.3675  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -21.22639    0.77068  -27.54   <2e-16 ***
## Age         1.63197    0.05895   27.68   <2e-16 ***
## ---
## Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 3693.884  on 24  degrees of freedom
## Residual deviance:   26.703  on 23  degrees of freedom
## AIC: 114.76
## 
## Number of Fisher Scoring iterations: 4
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
z <- glm(counts ~ outcome + treatment, family = poisson())
summary(z)
## 
## Call:
## glm(formula = counts ~ outcome + treatment, family = poisson())
## 
## Deviance Residuals: 
##        1         2         3         4         5         6         7         8         9  
## -0.67125   0.96272  -0.16965  -0.21999  -0.95552   1.04939   0.84715  -0.09167  -0.96656  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.045e+00  1.709e-01  17.815   <2e-16 ***
##   outcome2  -4.543e-01  2.022e-01  -2.247   0.0246 *  
##   outcome3  -2.930e-01  1.927e-01  -1.520   0.1285    
## treatment2   1.338e-15  2.000e-01   0.000   1.0000    
## treatment3   1.421e-15  2.000e-01   0.000   1.0000    
## ---
##   Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
## Null deviance: 10.5814  on 8  degrees of freedom
## Residual deviance:  5.1291  on 4  degrees of freedom
## AIC: 56.761
## 
## Number of Fisher Scoring iterations: 4

anova(z)
## Analysis of Deviance Table
## 
## Model: poisson, link: log
## 
## Response: counts
## 
## Terms added sequentially (first to last)
## 
## 
## Df Deviance Resid. Df Resid. Dev
## NULL                          8    10.5814
## outcome    2   5.4523         6     5.1291
## treatment  2   0.0000         4     5.1291

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}