What does predict.glm(, type=“terms”) actually do?
问题 I am confused with the way predict.glm function in R works. According to the help, The "terms" option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale. Thus, if my model has form f(y) = X*beta, then command predict(model, X, type='terms') is expected to produce the same matrix X, multiplied by beta element-wise. For example, if I train the following model test.data = data.frame(y = c(0,0,0,1,1,1,1,1,1), x=c(1,2,3,1,2,2,3,3,3)) model =