문제

Want to predict a value but this is clearly not the solution. I am doing a multiple choice test and 0.304... is not an answer.How to use predict() correctly?

library(glm2)
data(crabs)
fit= glm(Satellites~Width,data=crabs, family="poisson")
plot(Satellites~Width,data=crabs)
abline(fit)
predict(fit, newdata=data.frame(Width=c(22)))
1 
0.3042347 
도움이 되었습니까?

해결책

Function predict() for Poisson regression (for GLM in general) by default will calculate the values on the scale of the linear predictors, i.e. the log scale in this case (see help file for predict.glm).

predict(fit, newdata=data.frame(Width=c(22)))
        1 
0.3042347 

To get the predicted values on the scale of the response variable, you should add argument type="response" to function predict().

predict(fit, newdata=data.frame(Width=c(22)),type="response")
       1 
1.355587 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top