I´m trying to visualize a glm
model with a binomial response variable, I want to put a line in the plots, but neither lines
or abline
work and I don´t know why when I have significant responses according to the model I used. Any idea why plotting a line does not work?
> summary(model2)
Call:
glm(formula = Lövförekomst ~ Areal + Si, family = binomial)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.254 -1.048 -1.012 1.309 1.422
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.2158411 0.0634165 -3.404 0.000665 ***
Areal 0.0009178 0.0002495 3.678 0.000235 ***
Si -0.0117521 0.0038870 -3.023 0.002499 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 16662 on 12237 degrees of freedom
Residual deviance: 16642 on 12235 degrees of freedom
(33 observations deleted due to missingness)
AIC: 16648
Number of Fisher Scoring iterations: 4
> mod <- glm(Lövförekomst~Areal, binomial)
> med <- glm(Lövförekomst~Si, binomial)
> x <- seq(0,9,0.01)
> y <- predict(mod, list(Areal=x), type="response")
> par(mfrow=c(1,2))
> plot(Areal, Lövförekomst)
> x2 <- seq(0,9,0.01)
> y2 <- predict(med, list(Si=x), type="response")
> plot(Si, Lövförekomst)
> lines(x, y)
> lines(x2, y2)