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

잔글 (Jmnote님이 R언어 glm() 문서를 R glm() 문서로 이동하면서 넘겨주기를 덮어썼습니다)
잔글 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
 
(다른 사용자 한 명의 중간 판 4개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;R glm()
;R glm()
* "Generalized Linear Model"


<source lang='r'>
<syntaxhighlight lang='r' notebook>
library("MASS")
library("MASS")
str(menarche)
str(menarche)
summary(glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial, data=menarche))
summary(glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial, data=menarche))
##
</syntaxhighlight>
## Call:
<syntaxhighlight lang='r' notebook=2>
## 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
</source>
<source lang='r'>
counts <- c(18,17,15,20,10,20,25,13,12)
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
outcome <- gl(3,1,9)
36번째 줄: 14번째 줄:
z <- glm(counts ~ outcome + treatment, family = poisson())
z <- glm(counts ~ outcome + treatment, family = poisson())
summary(z)
summary(z)
##
</syntaxhighlight>
## Call:
<syntaxhighlight lang='r' notebook=2>
## 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)
anova(z)
## Analysis of Deviance Table
</syntaxhighlight>
##
## 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
</source>


==같이 보기==
==같이 보기==
82번째 줄: 23번째 줄:
* [[R summary.glm()]]
* [[R summary.glm()]]
* [[R lm()]]
* [[R lm()]]
* [[R polr()]]
* [[R loglin()]]
* [[R loglin()]]
* [[R loglm()]]
* [[R loglm()]]
87번째 줄: 29번째 줄:
* [[R infert()]]
* [[R infert()]]
* [[R predict.glm()]]
* [[R predict.glm()]]
* [[R 로지스틱 회귀분석]]


==참고==
==참고==

2021년 5월 7일 (금) 19:30 기준 최신판

1 개요[ | ]

R glm()
  • "Generalized Linear Model"
library("MASS")
str(menarche)
summary(glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial, data=menarche))
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)
anova(z)

2 같이 보기[ | ]

3 참고[ | ]

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