나는 glm
을 수행했으며 각 계수의 표준 오류를 추출하려고합니다. 인터넷에서 함수 se.coef()
을 보았지만 작동하지 않으면 "Error: could not find function "se.coef""
을 반환합니다.glm에서 표준 오류를 추출하십시오
답변
정보는 summary()
에 의해 반환 된 coefficients
개체에 저장됩니다. 당신은 thusly 히를 추출 할 수 있습니다 :
#Example from ?glm
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
#coefficients has the data of interest
> summary(glm.D93)$coefficients
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.044522e+00 0.1708987 1.781478e+01 5.426767e-71
outcome2 -4.542553e-01 0.2021708 -2.246889e+00 2.464711e-02
outcome3 -2.929871e-01 0.1927423 -1.520097e+00 1.284865e-01
treatment2 1.337909e-15 0.2000000 6.689547e-15 1.000000e+00
treatment3 1.421085e-15 0.2000000 7.105427e-15 1.000000e+00
#So extract the second column
> summary(glm.D93)$coefficients[, 2]
(Intercept) outcome2 outcome3 treatment2 treatment3
0.1708987 0.2021708 0.1927423 0.2000000 0.2000000
summary(glm.D93)$coefficients[, 2]
가 반환됩니다 모든 것을 빠른 검토를 위해 names(summary(glm.D93))
에서 살펴 보자. 구체적인 계산 방법을보고 싶다면 summary.glm
을 확인하면됩니다. < 3 통계가 없으면 그 정도의 세부 정보는 필요 없을 것입니다.
'glm.D93' 객체 내에 표준 오류가 저장되어 있습니까? 나는'str()'을 사용하여 눈을 뗄 수 없었다. 아니면'summary()'가 명시 적으로 오류를 계산합니까? –
@ mindless.panda - AFAIK 그들은'summary.glm'에 의해 직접 계산됩니다. 콘솔에 함수를 입력 ('') 한 다음 약 25 줄 아래로 스크롤하면 계산 된 부분이 표시됩니다. – Chase
se.coef()는 실제로 작업을 수행합니다. 하지만 기본 패키지에 없습니다. {arm} 패키지에 있습니다. http://www.inside-r.org/packages/cran/arm/docs/se.ranef
일부 데이터와 예제 코드를 올리는 데 도움이 될 수 있습니다. – screechOwl