모델에 완벽하게 맞는 데이터 세트를 생성하려면 다음과 같이하십시오 R
.
# y <- exp(B0 + B1 * x1 + B2 * x2)
set.seed(1234)
B0 <- 1.2 # intercept
B1 <- 1.5 # slope for x1
B2 <- -0.5 # slope for x2
y <- rpois(100, 6.5)
x2 <- seq(-0.5, 0.5,,length(y))
x1 <- (log(y) - B0 - B2 * x2) / B1
my.model <- glm(y ~ x1 + x2, family = poisson(link = log))
summary(my.model)
다음을 반환합니다 :
Call:
glm(formula = y ~ x1 + x2, family = poisson(link = log))
Deviance Residuals:
Min 1Q Median 3Q Max
-2.581e-08 -1.490e-08 0.000e+00 0.000e+00 4.215e-08
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.20000 0.08386 14.309 < 2e-16 ***
x1 1.50000 0.16839 8.908 < 2e-16 ***
x2 -0.50000 0.14957 -3.343 0.000829 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 8.8619e+01 on 99 degrees of freedom
Residual deviance: 1.1102e-14 on 97 degrees of freedom
AIC: 362.47
Number of Fisher Scoring iterations: 3